Commit 70be4291 authored by Jonathan Cameron's avatar Jonathan Cameron Committed by Greg Kroah-Hartman

staging:iio:addac:adt7316: allocate chip state with iio_dev and use iio_priv to access.

Various minor cleanups needed to deal with removal of iio_dev pointer from chip state.
Signed-off-by: default avatarJonathan Cameron <jic23@cam.ac.uk>
Acked-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7978f9f8
...@@ -174,7 +174,6 @@ ...@@ -174,7 +174,6 @@
*/ */
struct adt7316_chip_info { struct adt7316_chip_info {
struct iio_dev *indio_dev;
struct adt7316_bus bus; struct adt7316_bus bus;
u16 ldac_pin; u16 ldac_pin;
u16 int_mask; /* 0x2f */ u16 int_mask; /* 0x2f */
...@@ -220,7 +219,7 @@ static ssize_t adt7316_show_enabled(struct device *dev, ...@@ -220,7 +219,7 @@ static ssize_t adt7316_show_enabled(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n", !!(chip->config1 & ADT7316_EN)); return sprintf(buf, "%d\n", !!(chip->config1 & ADT7316_EN));
} }
...@@ -252,7 +251,7 @@ static ssize_t adt7316_store_enabled(struct device *dev, ...@@ -252,7 +251,7 @@ static ssize_t adt7316_store_enabled(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
int enable; int enable;
if (!memcmp(buf, "1", 1)) if (!memcmp(buf, "1", 1))
...@@ -276,7 +275,7 @@ static ssize_t adt7316_show_select_ex_temp(struct device *dev, ...@@ -276,7 +275,7 @@ static ssize_t adt7316_show_select_ex_temp(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
if ((chip->id & ID_FAMILY_MASK) != ID_ADT75XX) if ((chip->id & ID_FAMILY_MASK) != ID_ADT75XX)
return -EPERM; return -EPERM;
...@@ -290,7 +289,7 @@ static ssize_t adt7316_store_select_ex_temp(struct device *dev, ...@@ -290,7 +289,7 @@ static ssize_t adt7316_store_select_ex_temp(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config1; u8 config1;
int ret; int ret;
...@@ -320,7 +319,7 @@ static ssize_t adt7316_show_mode(struct device *dev, ...@@ -320,7 +319,7 @@ static ssize_t adt7316_show_mode(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
if (chip->config2 & ADT7316_AD_SINGLE_CH_MODE) if (chip->config2 & ADT7316_AD_SINGLE_CH_MODE)
return sprintf(buf, "single_channel\n"); return sprintf(buf, "single_channel\n");
...@@ -334,7 +333,7 @@ static ssize_t adt7316_store_mode(struct device *dev, ...@@ -334,7 +333,7 @@ static ssize_t adt7316_store_mode(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config2; u8 config2;
int ret; int ret;
...@@ -370,7 +369,7 @@ static ssize_t adt7316_show_ad_channel(struct device *dev, ...@@ -370,7 +369,7 @@ static ssize_t adt7316_show_ad_channel(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
if (!(chip->config2 & ADT7316_AD_SINGLE_CH_MODE)) if (!(chip->config2 & ADT7316_AD_SINGLE_CH_MODE))
return -EPERM; return -EPERM;
...@@ -409,7 +408,7 @@ static ssize_t adt7316_store_ad_channel(struct device *dev, ...@@ -409,7 +408,7 @@ static ssize_t adt7316_store_ad_channel(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config2; u8 config2;
unsigned long data = 0; unsigned long data = 0;
int ret; int ret;
...@@ -455,7 +454,7 @@ static ssize_t adt7316_show_all_ad_channels(struct device *dev, ...@@ -455,7 +454,7 @@ static ssize_t adt7316_show_all_ad_channels(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
if (!(chip->config2 & ADT7316_AD_SINGLE_CH_MODE)) if (!(chip->config2 & ADT7316_AD_SINGLE_CH_MODE))
return -EPERM; return -EPERM;
...@@ -477,7 +476,7 @@ static ssize_t adt7316_show_disable_averaging(struct device *dev, ...@@ -477,7 +476,7 @@ static ssize_t adt7316_show_disable_averaging(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n", return sprintf(buf, "%d\n",
!!(chip->config2 & ADT7316_DISABLE_AVERAGING)); !!(chip->config2 & ADT7316_DISABLE_AVERAGING));
...@@ -489,7 +488,7 @@ static ssize_t adt7316_store_disable_averaging(struct device *dev, ...@@ -489,7 +488,7 @@ static ssize_t adt7316_store_disable_averaging(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config2; u8 config2;
int ret; int ret;
...@@ -516,7 +515,7 @@ static ssize_t adt7316_show_enable_smbus_timeout(struct device *dev, ...@@ -516,7 +515,7 @@ static ssize_t adt7316_show_enable_smbus_timeout(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n", return sprintf(buf, "%d\n",
!!(chip->config2 & ADT7316_EN_SMBUS_TIMEOUT)); !!(chip->config2 & ADT7316_EN_SMBUS_TIMEOUT));
...@@ -528,7 +527,7 @@ static ssize_t adt7316_store_enable_smbus_timeout(struct device *dev, ...@@ -528,7 +527,7 @@ static ssize_t adt7316_store_enable_smbus_timeout(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config2; u8 config2;
int ret; int ret;
...@@ -557,7 +556,7 @@ static ssize_t adt7316_store_reset(struct device *dev, ...@@ -557,7 +556,7 @@ static ssize_t adt7316_store_reset(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config2; u8 config2;
int ret; int ret;
...@@ -580,7 +579,7 @@ static ssize_t adt7316_show_powerdown(struct device *dev, ...@@ -580,7 +579,7 @@ static ssize_t adt7316_show_powerdown(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n", !!(chip->config1 & ADT7316_PD)); return sprintf(buf, "%d\n", !!(chip->config1 & ADT7316_PD));
} }
...@@ -591,7 +590,7 @@ static ssize_t adt7316_store_powerdown(struct device *dev, ...@@ -591,7 +590,7 @@ static ssize_t adt7316_store_powerdown(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config1; u8 config1;
int ret; int ret;
...@@ -618,7 +617,7 @@ static ssize_t adt7316_show_fast_ad_clock(struct device *dev, ...@@ -618,7 +617,7 @@ static ssize_t adt7316_show_fast_ad_clock(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n", !!(chip->config3 & ADT7316_ADCLK_22_5)); return sprintf(buf, "%d\n", !!(chip->config3 & ADT7316_ADCLK_22_5));
} }
...@@ -629,7 +628,7 @@ static ssize_t adt7316_store_fast_ad_clock(struct device *dev, ...@@ -629,7 +628,7 @@ static ssize_t adt7316_store_fast_ad_clock(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config3; u8 config3;
int ret; int ret;
...@@ -656,7 +655,7 @@ static ssize_t adt7316_show_da_high_resolution(struct device *dev, ...@@ -656,7 +655,7 @@ static ssize_t adt7316_show_da_high_resolution(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
if (chip->config3 & ADT7316_DA_HIGH_RESOLUTION) { if (chip->config3 & ADT7316_DA_HIGH_RESOLUTION) {
if (chip->id == ID_ADT7316 || chip->id == ID_ADT7516) if (chip->id == ID_ADT7316 || chip->id == ID_ADT7516)
...@@ -674,7 +673,7 @@ static ssize_t adt7316_store_da_high_resolution(struct device *dev, ...@@ -674,7 +673,7 @@ static ssize_t adt7316_store_da_high_resolution(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config3; u8 config3;
int ret; int ret;
...@@ -708,7 +707,7 @@ static ssize_t adt7316_show_AIN_internal_Vref(struct device *dev, ...@@ -708,7 +707,7 @@ static ssize_t adt7316_show_AIN_internal_Vref(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
if ((chip->id & ID_FAMILY_MASK) != ID_ADT75XX) if ((chip->id & ID_FAMILY_MASK) != ID_ADT75XX)
return -EPERM; return -EPERM;
...@@ -723,7 +722,7 @@ static ssize_t adt7316_store_AIN_internal_Vref(struct device *dev, ...@@ -723,7 +722,7 @@ static ssize_t adt7316_store_AIN_internal_Vref(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config3; u8 config3;
int ret; int ret;
...@@ -755,7 +754,7 @@ static ssize_t adt7316_show_enable_prop_DACA(struct device *dev, ...@@ -755,7 +754,7 @@ static ssize_t adt7316_show_enable_prop_DACA(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n", return sprintf(buf, "%d\n",
!!(chip->config3 & ADT7316_EN_IN_TEMP_PROP_DACA)); !!(chip->config3 & ADT7316_EN_IN_TEMP_PROP_DACA));
...@@ -767,7 +766,7 @@ static ssize_t adt7316_store_enable_prop_DACA(struct device *dev, ...@@ -767,7 +766,7 @@ static ssize_t adt7316_store_enable_prop_DACA(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config3; u8 config3;
int ret; int ret;
...@@ -794,7 +793,7 @@ static ssize_t adt7316_show_enable_prop_DACB(struct device *dev, ...@@ -794,7 +793,7 @@ static ssize_t adt7316_show_enable_prop_DACB(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n", return sprintf(buf, "%d\n",
!!(chip->config3 & ADT7316_EN_EX_TEMP_PROP_DACB)); !!(chip->config3 & ADT7316_EN_EX_TEMP_PROP_DACB));
...@@ -806,7 +805,7 @@ static ssize_t adt7316_store_enable_prop_DACB(struct device *dev, ...@@ -806,7 +805,7 @@ static ssize_t adt7316_store_enable_prop_DACB(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config3; u8 config3;
int ret; int ret;
...@@ -833,7 +832,7 @@ static ssize_t adt7316_show_DAC_2Vref_ch_mask(struct device *dev, ...@@ -833,7 +832,7 @@ static ssize_t adt7316_show_DAC_2Vref_ch_mask(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "0x%x\n", return sprintf(buf, "0x%x\n",
chip->dac_config & ADT7316_DA_2VREF_CH_MASK); chip->dac_config & ADT7316_DA_2VREF_CH_MASK);
...@@ -845,7 +844,7 @@ static ssize_t adt7316_store_DAC_2Vref_ch_mask(struct device *dev, ...@@ -845,7 +844,7 @@ static ssize_t adt7316_store_DAC_2Vref_ch_mask(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 dac_config; u8 dac_config;
unsigned long data = 0; unsigned long data = 0;
int ret; int ret;
...@@ -876,7 +875,7 @@ static ssize_t adt7316_show_DAC_update_mode(struct device *dev, ...@@ -876,7 +875,7 @@ static ssize_t adt7316_show_DAC_update_mode(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
if (!(chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA)) if (!(chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA))
return sprintf(buf, "manual\n"); return sprintf(buf, "manual\n");
...@@ -900,7 +899,7 @@ static ssize_t adt7316_store_DAC_update_mode(struct device *dev, ...@@ -900,7 +899,7 @@ static ssize_t adt7316_store_DAC_update_mode(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 dac_config; u8 dac_config;
unsigned long data; unsigned long data;
int ret; int ret;
...@@ -934,7 +933,7 @@ static ssize_t adt7316_show_all_DAC_update_modes(struct device *dev, ...@@ -934,7 +933,7 @@ static ssize_t adt7316_show_all_DAC_update_modes(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
if (chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA) if (chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA)
return sprintf(buf, "0 - auto at any MSB DAC writing\n" return sprintf(buf, "0 - auto at any MSB DAC writing\n"
...@@ -955,7 +954,7 @@ static ssize_t adt7316_store_update_DAC(struct device *dev, ...@@ -955,7 +954,7 @@ static ssize_t adt7316_store_update_DAC(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 ldac_config; u8 ldac_config;
unsigned long data; unsigned long data;
int ret; int ret;
...@@ -994,7 +993,7 @@ static ssize_t adt7316_show_DA_AB_Vref_bypass(struct device *dev, ...@@ -994,7 +993,7 @@ static ssize_t adt7316_show_DA_AB_Vref_bypass(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
return -EPERM; return -EPERM;
...@@ -1009,7 +1008,7 @@ static ssize_t adt7316_store_DA_AB_Vref_bypass(struct device *dev, ...@@ -1009,7 +1008,7 @@ static ssize_t adt7316_store_DA_AB_Vref_bypass(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 dac_config; u8 dac_config;
int ret; int ret;
...@@ -1039,7 +1038,7 @@ static ssize_t adt7316_show_DA_CD_Vref_bypass(struct device *dev, ...@@ -1039,7 +1038,7 @@ static ssize_t adt7316_show_DA_CD_Vref_bypass(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
return -EPERM; return -EPERM;
...@@ -1054,7 +1053,7 @@ static ssize_t adt7316_store_DA_CD_Vref_bypass(struct device *dev, ...@@ -1054,7 +1053,7 @@ static ssize_t adt7316_store_DA_CD_Vref_bypass(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 dac_config; u8 dac_config;
int ret; int ret;
...@@ -1084,7 +1083,7 @@ static ssize_t adt7316_show_DAC_internal_Vref(struct device *dev, ...@@ -1084,7 +1083,7 @@ static ssize_t adt7316_show_DAC_internal_Vref(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
return sprintf(buf, "0x%x\n", return sprintf(buf, "0x%x\n",
...@@ -1101,7 +1100,7 @@ static ssize_t adt7316_store_DAC_internal_Vref(struct device *dev, ...@@ -1101,7 +1100,7 @@ static ssize_t adt7316_store_DAC_internal_Vref(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 ldac_config; u8 ldac_config;
unsigned long data; unsigned long data;
int ret; int ret;
...@@ -1220,7 +1219,7 @@ static ssize_t adt7316_show_VDD(struct device *dev, ...@@ -1220,7 +1219,7 @@ static ssize_t adt7316_show_VDD(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_ad(chip, ADT7316_AD_SINGLE_CH_VDD, buf); return adt7316_show_ad(chip, ADT7316_AD_SINGLE_CH_VDD, buf);
} }
...@@ -1231,7 +1230,7 @@ static ssize_t adt7316_show_in_temp(struct device *dev, ...@@ -1231,7 +1230,7 @@ static ssize_t adt7316_show_in_temp(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_ad(chip, ADT7316_AD_SINGLE_CH_IN, buf); return adt7316_show_ad(chip, ADT7316_AD_SINGLE_CH_IN, buf);
} }
...@@ -1243,7 +1242,7 @@ static ssize_t adt7316_show_ex_temp_AIN1(struct device *dev, ...@@ -1243,7 +1242,7 @@ static ssize_t adt7316_show_ex_temp_AIN1(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_ad(chip, ADT7316_AD_SINGLE_CH_EX, buf); return adt7316_show_ad(chip, ADT7316_AD_SINGLE_CH_EX, buf);
} }
...@@ -1256,7 +1255,7 @@ static ssize_t adt7316_show_AIN2(struct device *dev, ...@@ -1256,7 +1255,7 @@ static ssize_t adt7316_show_AIN2(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_ad(chip, ADT7516_AD_SINGLE_CH_AIN2, buf); return adt7316_show_ad(chip, ADT7516_AD_SINGLE_CH_AIN2, buf);
} }
...@@ -1267,7 +1266,7 @@ static ssize_t adt7316_show_AIN3(struct device *dev, ...@@ -1267,7 +1266,7 @@ static ssize_t adt7316_show_AIN3(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_ad(chip, ADT7516_AD_SINGLE_CH_AIN3, buf); return adt7316_show_ad(chip, ADT7516_AD_SINGLE_CH_AIN3, buf);
} }
...@@ -1278,7 +1277,7 @@ static ssize_t adt7316_show_AIN4(struct device *dev, ...@@ -1278,7 +1277,7 @@ static ssize_t adt7316_show_AIN4(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_ad(chip, ADT7516_AD_SINGLE_CH_AIN4, buf); return adt7316_show_ad(chip, ADT7516_AD_SINGLE_CH_AIN4, buf);
} }
...@@ -1330,7 +1329,7 @@ static ssize_t adt7316_show_in_temp_offset(struct device *dev, ...@@ -1330,7 +1329,7 @@ static ssize_t adt7316_show_in_temp_offset(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_temp_offset(chip, ADT7316_IN_TEMP_OFFSET, buf); return adt7316_show_temp_offset(chip, ADT7316_IN_TEMP_OFFSET, buf);
} }
...@@ -1341,7 +1340,7 @@ static ssize_t adt7316_store_in_temp_offset(struct device *dev, ...@@ -1341,7 +1340,7 @@ static ssize_t adt7316_store_in_temp_offset(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_temp_offset(chip, ADT7316_IN_TEMP_OFFSET, buf, len); return adt7316_store_temp_offset(chip, ADT7316_IN_TEMP_OFFSET, buf, len);
} }
...@@ -1355,7 +1354,7 @@ static ssize_t adt7316_show_ex_temp_offset(struct device *dev, ...@@ -1355,7 +1354,7 @@ static ssize_t adt7316_show_ex_temp_offset(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_temp_offset(chip, ADT7316_EX_TEMP_OFFSET, buf); return adt7316_show_temp_offset(chip, ADT7316_EX_TEMP_OFFSET, buf);
} }
...@@ -1366,7 +1365,7 @@ static ssize_t adt7316_store_ex_temp_offset(struct device *dev, ...@@ -1366,7 +1365,7 @@ static ssize_t adt7316_store_ex_temp_offset(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_temp_offset(chip, ADT7316_EX_TEMP_OFFSET, buf, len); return adt7316_store_temp_offset(chip, ADT7316_EX_TEMP_OFFSET, buf, len);
} }
...@@ -1380,7 +1379,7 @@ static ssize_t adt7316_show_in_analog_temp_offset(struct device *dev, ...@@ -1380,7 +1379,7 @@ static ssize_t adt7316_show_in_analog_temp_offset(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_temp_offset(chip, return adt7316_show_temp_offset(chip,
ADT7316_IN_ANALOG_TEMP_OFFSET, buf); ADT7316_IN_ANALOG_TEMP_OFFSET, buf);
...@@ -1392,7 +1391,7 @@ static ssize_t adt7316_store_in_analog_temp_offset(struct device *dev, ...@@ -1392,7 +1391,7 @@ static ssize_t adt7316_store_in_analog_temp_offset(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_temp_offset(chip, return adt7316_store_temp_offset(chip,
ADT7316_IN_ANALOG_TEMP_OFFSET, buf, len); ADT7316_IN_ANALOG_TEMP_OFFSET, buf, len);
...@@ -1407,7 +1406,7 @@ static ssize_t adt7316_show_ex_analog_temp_offset(struct device *dev, ...@@ -1407,7 +1406,7 @@ static ssize_t adt7316_show_ex_analog_temp_offset(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_temp_offset(chip, return adt7316_show_temp_offset(chip,
ADT7316_EX_ANALOG_TEMP_OFFSET, buf); ADT7316_EX_ANALOG_TEMP_OFFSET, buf);
...@@ -1419,7 +1418,7 @@ static ssize_t adt7316_store_ex_analog_temp_offset(struct device *dev, ...@@ -1419,7 +1418,7 @@ static ssize_t adt7316_store_ex_analog_temp_offset(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_temp_offset(chip, return adt7316_store_temp_offset(chip,
ADT7316_EX_ANALOG_TEMP_OFFSET, buf, len); ADT7316_EX_ANALOG_TEMP_OFFSET, buf, len);
...@@ -1504,7 +1503,7 @@ static ssize_t adt7316_show_DAC_A(struct device *dev, ...@@ -1504,7 +1503,7 @@ static ssize_t adt7316_show_DAC_A(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_DAC(chip, 0, buf); return adt7316_show_DAC(chip, 0, buf);
} }
...@@ -1515,7 +1514,7 @@ static ssize_t adt7316_store_DAC_A(struct device *dev, ...@@ -1515,7 +1514,7 @@ static ssize_t adt7316_store_DAC_A(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_DAC(chip, 0, buf, len); return adt7316_store_DAC(chip, 0, buf, len);
} }
...@@ -1528,7 +1527,7 @@ static ssize_t adt7316_show_DAC_B(struct device *dev, ...@@ -1528,7 +1527,7 @@ static ssize_t adt7316_show_DAC_B(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_DAC(chip, 1, buf); return adt7316_show_DAC(chip, 1, buf);
} }
...@@ -1539,7 +1538,7 @@ static ssize_t adt7316_store_DAC_B(struct device *dev, ...@@ -1539,7 +1538,7 @@ static ssize_t adt7316_store_DAC_B(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_DAC(chip, 1, buf, len); return adt7316_store_DAC(chip, 1, buf, len);
} }
...@@ -1552,7 +1551,7 @@ static ssize_t adt7316_show_DAC_C(struct device *dev, ...@@ -1552,7 +1551,7 @@ static ssize_t adt7316_show_DAC_C(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_DAC(chip, 2, buf); return adt7316_show_DAC(chip, 2, buf);
} }
...@@ -1563,7 +1562,7 @@ static ssize_t adt7316_store_DAC_C(struct device *dev, ...@@ -1563,7 +1562,7 @@ static ssize_t adt7316_store_DAC_C(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_DAC(chip, 2, buf, len); return adt7316_store_DAC(chip, 2, buf, len);
} }
...@@ -1576,7 +1575,7 @@ static ssize_t adt7316_show_DAC_D(struct device *dev, ...@@ -1576,7 +1575,7 @@ static ssize_t adt7316_show_DAC_D(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_show_DAC(chip, 3, buf); return adt7316_show_DAC(chip, 3, buf);
} }
...@@ -1587,7 +1586,7 @@ static ssize_t adt7316_store_DAC_D(struct device *dev, ...@@ -1587,7 +1586,7 @@ static ssize_t adt7316_store_DAC_D(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return adt7316_store_DAC(chip, 3, buf, len); return adt7316_store_DAC(chip, 3, buf, len);
} }
...@@ -1600,7 +1599,7 @@ static ssize_t adt7316_show_device_id(struct device *dev, ...@@ -1600,7 +1599,7 @@ static ssize_t adt7316_show_device_id(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 id; u8 id;
int ret; int ret;
...@@ -1618,7 +1617,7 @@ static ssize_t adt7316_show_manufactorer_id(struct device *dev, ...@@ -1618,7 +1617,7 @@ static ssize_t adt7316_show_manufactorer_id(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 id; u8 id;
int ret; int ret;
...@@ -1637,7 +1636,7 @@ static ssize_t adt7316_show_device_rev(struct device *dev, ...@@ -1637,7 +1636,7 @@ static ssize_t adt7316_show_device_rev(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 rev; u8 rev;
int ret; int ret;
...@@ -1655,7 +1654,7 @@ static ssize_t adt7316_show_bus_type(struct device *dev, ...@@ -1655,7 +1654,7 @@ static ssize_t adt7316_show_bus_type(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 stat; u8 stat;
int ret; int ret;
...@@ -1765,7 +1764,7 @@ static const struct attribute_group adt7516_attribute_group = { ...@@ -1765,7 +1764,7 @@ static const struct attribute_group adt7516_attribute_group = {
static irqreturn_t adt7316_event_handler(int irq, void *private) static irqreturn_t adt7316_event_handler(int irq, void *private)
{ {
struct iio_dev *indio_dev = private; struct iio_dev *indio_dev = private;
struct adt7316_chip_info *chip = iio_dev_get_devdata(indio_dev); struct adt7316_chip_info *chip = iio_priv(indio_dev);
u8 stat1, stat2; u8 stat1, stat2;
int ret; int ret;
s64 time; s64 time;
...@@ -1777,43 +1776,43 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) ...@@ -1777,43 +1776,43 @@ static irqreturn_t adt7316_event_handler(int irq, void *private)
time = iio_get_time_ns(); time = iio_get_time_ns();
if (stat1 & (1 << 0)) if (stat1 & (1 << 0))
iio_push_event(chip->indio_dev, 0, iio_push_event(indio_dev, 0,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
IIO_EV_TYPE_THRESH, IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING), IIO_EV_DIR_RISING),
time); time);
if (stat1 & (1 << 1)) if (stat1 & (1 << 1))
iio_push_event(chip->indio_dev, 0, iio_push_event(indio_dev, 0,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 0,
IIO_EV_TYPE_THRESH, IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING), IIO_EV_DIR_FALLING),
time); time);
if (stat1 & (1 << 2)) if (stat1 & (1 << 2))
iio_push_event(chip->indio_dev, 0, iio_push_event(indio_dev, 0,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1,
IIO_EV_TYPE_THRESH, IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING), IIO_EV_DIR_RISING),
time); time);
if (stat1 & (1 << 3)) if (stat1 & (1 << 3))
iio_push_event(chip->indio_dev, 0, iio_push_event(indio_dev, 0,
IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1, IIO_UNMOD_EVENT_CODE(IIO_TEMP, 1,
IIO_EV_TYPE_THRESH, IIO_EV_TYPE_THRESH,
IIO_EV_DIR_FALLING), IIO_EV_DIR_FALLING),
time); time);
if (stat1 & (1 << 5)) if (stat1 & (1 << 5))
iio_push_event(chip->indio_dev, 0, iio_push_event(indio_dev, 0,
IIO_UNMOD_EVENT_CODE(IIO_IN, 1, IIO_UNMOD_EVENT_CODE(IIO_IN, 1,
IIO_EV_TYPE_THRESH, IIO_EV_TYPE_THRESH,
IIO_EV_DIR_EITHER), IIO_EV_DIR_EITHER),
time); time);
if (stat1 & (1 << 6)) if (stat1 & (1 << 6))
iio_push_event(chip->indio_dev, 0, iio_push_event(indio_dev, 0,
IIO_UNMOD_EVENT_CODE(IIO_IN, 2, IIO_UNMOD_EVENT_CODE(IIO_IN, 2,
IIO_EV_TYPE_THRESH, IIO_EV_TYPE_THRESH,
IIO_EV_DIR_EITHER), IIO_EV_DIR_EITHER),
time); time);
if (stat1 & (1 << 7)) if (stat1 & (1 << 7))
iio_push_event(chip->indio_dev, 0, iio_push_event(indio_dev, 0,
IIO_UNMOD_EVENT_CODE(IIO_IN, 3, IIO_UNMOD_EVENT_CODE(IIO_IN, 3,
IIO_EV_TYPE_THRESH, IIO_EV_TYPE_THRESH,
IIO_EV_DIR_EITHER), IIO_EV_DIR_EITHER),
...@@ -1822,7 +1821,7 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) ...@@ -1822,7 +1821,7 @@ static irqreturn_t adt7316_event_handler(int irq, void *private)
ret = chip->bus.read(chip->bus.client, ADT7316_INT_STAT2, &stat2); ret = chip->bus.read(chip->bus.client, ADT7316_INT_STAT2, &stat2);
if (!ret) { if (!ret) {
if (stat2 & ADT7316_INT_MASK2_VDD) if (stat2 & ADT7316_INT_MASK2_VDD)
iio_push_event(chip->indio_dev, 0, iio_push_event(indio_dev, 0,
IIO_UNMOD_EVENT_CODE(IIO_IN, IIO_UNMOD_EVENT_CODE(IIO_IN,
0, 0,
IIO_EV_TYPE_THRESH, IIO_EV_TYPE_THRESH,
...@@ -1841,7 +1840,7 @@ static ssize_t adt7316_show_int_mask(struct device *dev, ...@@ -1841,7 +1840,7 @@ static ssize_t adt7316_show_int_mask(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "0x%x\n", chip->int_mask); return sprintf(buf, "0x%x\n", chip->int_mask);
} }
...@@ -1855,7 +1854,7 @@ static ssize_t adt7316_set_int_mask(struct device *dev, ...@@ -1855,7 +1854,7 @@ static ssize_t adt7316_set_int_mask(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
unsigned long data; unsigned long data;
int ret; int ret;
u8 mask; u8 mask;
...@@ -1895,7 +1894,7 @@ static inline ssize_t adt7316_show_ad_bound(struct device *dev, ...@@ -1895,7 +1894,7 @@ static inline ssize_t adt7316_show_ad_bound(struct device *dev,
{ {
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 val; u8 val;
int data; int data;
int ret; int ret;
...@@ -1926,7 +1925,7 @@ static inline ssize_t adt7316_set_ad_bound(struct device *dev, ...@@ -1926,7 +1925,7 @@ static inline ssize_t adt7316_set_ad_bound(struct device *dev,
{ {
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
long data; long data;
u8 val; u8 val;
int ret; int ret;
...@@ -1965,7 +1964,7 @@ static ssize_t adt7316_show_int_enabled(struct device *dev, ...@@ -1965,7 +1964,7 @@ static ssize_t adt7316_show_int_enabled(struct device *dev,
char *buf) char *buf)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return sprintf(buf, "%d\n", !!(chip->config1 & ADT7316_INT_EN)); return sprintf(buf, "%d\n", !!(chip->config1 & ADT7316_INT_EN));
} }
...@@ -1976,7 +1975,7 @@ static ssize_t adt7316_set_int_enabled(struct device *dev, ...@@ -1976,7 +1975,7 @@ static ssize_t adt7316_set_int_enabled(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config1; u8 config1;
int ret; int ret;
...@@ -2090,7 +2089,7 @@ static struct attribute_group adt7516_event_attribute_group = { ...@@ -2090,7 +2089,7 @@ static struct attribute_group adt7516_event_attribute_group = {
int adt7316_disable(struct device *dev) int adt7316_disable(struct device *dev)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return _adt7316_store_enabled(chip, 0); return _adt7316_store_enabled(chip, 0);
} }
...@@ -2099,7 +2098,7 @@ EXPORT_SYMBOL(adt7316_disable); ...@@ -2099,7 +2098,7 @@ EXPORT_SYMBOL(adt7316_disable);
int adt7316_enable(struct device *dev) int adt7316_enable(struct device *dev)
{ {
struct iio_dev *dev_info = dev_get_drvdata(dev); struct iio_dev *dev_info = dev_get_drvdata(dev);
struct adt7316_chip_info *chip = dev_info->dev_data; struct adt7316_chip_info *chip = iio_priv(dev_info);
return _adt7316_store_enabled(chip, 1); return _adt7316_store_enabled(chip, 1);
} }
...@@ -2127,16 +2126,18 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus, ...@@ -2127,16 +2126,18 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus,
const char *name) const char *name)
{ {
struct adt7316_chip_info *chip; struct adt7316_chip_info *chip;
struct iio_dev *indio_dev;
unsigned short *adt7316_platform_data = dev->platform_data; unsigned short *adt7316_platform_data = dev->platform_data;
int ret = 0; int ret = 0;
chip = kzalloc(sizeof(struct adt7316_chip_info), GFP_KERNEL); indio_dev = iio_allocate_device(sizeof(*chip));
if (indio_dev == NULL) {
if (chip == NULL) ret = -ENOMEM;
return -ENOMEM; goto error_ret;
}
chip = iio_priv(indio_dev);
/* this is only used for device removal purposes */ /* this is only used for device removal purposes */
dev_set_drvdata(dev, chip); dev_set_drvdata(dev, indio_dev);
chip->bus = *bus; chip->bus = *bus;
...@@ -2157,22 +2158,15 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus, ...@@ -2157,22 +2158,15 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus,
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
chip->int_mask |= ADT7516_AIN_INT_MASK; chip->int_mask |= ADT7516_AIN_INT_MASK;
chip->indio_dev = iio_allocate_device(0); indio_dev->dev.parent = dev;
if (chip->indio_dev == NULL) {
ret = -ENOMEM;
goto error_free_chip;
}
chip->indio_dev->dev.parent = dev;
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
chip->indio_dev->info = &adt7516_info; indio_dev->info = &adt7516_info;
else else
chip->indio_dev->info = &adt7316_info; indio_dev->info = &adt7316_info;
chip->indio_dev->name = name; indio_dev->name = name;
chip->indio_dev->dev_data = (void *)chip; indio_dev->modes = INDIO_DIRECT_MODE;
chip->indio_dev->modes = INDIO_DIRECT_MODE;
ret = iio_device_register(chip->indio_dev); ret = iio_device_register(indio_dev);
if (ret) if (ret)
goto error_free_dev; goto error_free_dev;
...@@ -2184,8 +2178,8 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus, ...@@ -2184,8 +2178,8 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus,
NULL, NULL,
&adt7316_event_handler, &adt7316_event_handler,
chip->bus.irq_flags | IRQF_ONESHOT, chip->bus.irq_flags | IRQF_ONESHOT,
chip->indio_dev->name, indio_dev->name,
chip->indio_dev); indio_dev);
if (ret) if (ret)
goto error_unreg_dev; goto error_unreg_dev;
...@@ -2206,35 +2200,31 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus, ...@@ -2206,35 +2200,31 @@ int __devinit adt7316_probe(struct device *dev, struct adt7316_bus *bus,
} }
dev_info(dev, "%s temperature sensor, ADC and DAC registered.\n", dev_info(dev, "%s temperature sensor, ADC and DAC registered.\n",
chip->indio_dev->name); indio_dev->name);
return 0; return 0;
error_unreg_irq: error_unreg_irq:
free_irq(chip->bus.irq, chip->indio_dev); free_irq(chip->bus.irq, indio_dev);
error_unreg_dev: error_unreg_dev:
iio_device_unregister(chip->indio_dev); iio_device_unregister(indio_dev);
error_free_dev: error_free_dev:
iio_free_device(chip->indio_dev); iio_free_device(indio_dev);
error_free_chip: error_ret:
kfree(chip);
return ret; return ret;
} }
EXPORT_SYMBOL(adt7316_probe); EXPORT_SYMBOL(adt7316_probe);
int __devexit adt7316_remove(struct device *dev) int __devexit adt7316_remove(struct device *dev)
{ {
struct iio_dev *indio_dev = dev_get_drvdata(dev);
struct iio_dev *dev_info = dev_get_drvdata(dev); struct adt7316_chip_info *chip = iio_priv(indio_dev);
struct adt7316_chip_info *chip = dev_info->dev_data;
dev_set_drvdata(dev, NULL); dev_set_drvdata(dev, NULL);
if (chip->bus.irq) if (chip->bus.irq)
free_irq(chip->bus.irq, chip->indio_dev); free_irq(chip->bus.irq, indio_dev);
iio_device_unregister(chip->indio_dev); iio_device_unregister(indio_dev);
iio_free_device(chip->indio_dev); iio_free_device(indio_dev);
kfree(chip);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment