Commit e5e26dd5 authored by Jingoo Han's avatar Jingoo Han Committed by Jonathan Cameron

staging: iio: replace strict_strto*() with kstrto*()

The usage of strict_strto*() is not preferred, because
strict_strto*() is obsolete. Thus, kstrto*() should be
used.

Previously, there were only strict_strtol(), strict_strtoul(),
strict_strtoull(), and strict_strtoll(). Thus, when converting
to the variables, only long, unsigned long, unsigned long long,
and long long can be used.

However, kstrto*() provides various functions handling all types
of variables. Therefore, the types of variables can be changed
properly.
Signed-off-by: default avatarJingoo Han <jg1.han@samsung.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 07914c84
...@@ -624,9 +624,9 @@ static ssize_t sca3000_set_frequency(struct device *dev, ...@@ -624,9 +624,9 @@ static ssize_t sca3000_set_frequency(struct device *dev,
struct sca3000_state *st = iio_priv(indio_dev); struct sca3000_state *st = iio_priv(indio_dev);
int ret, base_freq = 0; int ret, base_freq = 0;
int ctrlval; int ctrlval;
long val; int val;
ret = strict_strtol(buf, 10, &val); ret = kstrtoint(buf, 10, &val);
if (ret) if (ret)
return ret; return ret;
...@@ -931,12 +931,12 @@ static ssize_t sca3000_set_free_fall_mode(struct device *dev, ...@@ -931,12 +931,12 @@ static ssize_t sca3000_set_free_fall_mode(struct device *dev,
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev); struct sca3000_state *st = iio_priv(indio_dev);
long val; u8 val;
int ret; int ret;
u8 protect_mask = SCA3000_FREE_FALL_DETECT; u8 protect_mask = SCA3000_FREE_FALL_DETECT;
mutex_lock(&st->lock); mutex_lock(&st->lock);
ret = strict_strtol(buf, 10, &val); ret = kstrtou8(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
......
...@@ -177,11 +177,11 @@ static ssize_t sca3000_set_ring_int(struct device *dev, ...@@ -177,11 +177,11 @@ static ssize_t sca3000_set_ring_int(struct device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct sca3000_state *st = iio_priv(indio_dev); struct sca3000_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
long val; u8 val;
int ret; int ret;
mutex_lock(&st->lock); mutex_lock(&st->lock);
ret = strict_strtol(buf, 10, &val); ret = kstrtou8(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_INT_MASK, 1); ret = sca3000_read_data_short(st, SCA3000_REG_ADDR_INT_MASK, 1);
......
...@@ -412,13 +412,13 @@ static ssize_t adt7316_store_ad_channel(struct device *dev, ...@@ -412,13 +412,13 @@ static ssize_t adt7316_store_ad_channel(struct device *dev,
struct iio_dev *dev_info = dev_to_iio_dev(dev); struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info); struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 config2; u8 config2;
unsigned long data = 0; u8 data;
int ret; int ret;
if (!(chip->config2 & ADT7316_AD_SINGLE_CH_MODE)) if (!(chip->config2 & ADT7316_AD_SINGLE_CH_MODE))
return -EPERM; return -EPERM;
ret = strict_strtoul(buf, 10, &data); ret = kstrtou8(buf, 10, &data);
if (ret) if (ret)
return -EINVAL; return -EINVAL;
...@@ -823,10 +823,10 @@ static ssize_t adt7316_store_DAC_2Vref_ch_mask(struct device *dev, ...@@ -823,10 +823,10 @@ static ssize_t adt7316_store_DAC_2Vref_ch_mask(struct device *dev,
struct iio_dev *dev_info = dev_to_iio_dev(dev); struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info); struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 dac_config; u8 dac_config;
unsigned long data = 0; u8 data;
int ret; int ret;
ret = strict_strtoul(buf, 16, &data); ret = kstrtou8(buf, 16, &data);
if (ret || data > ADT7316_DA_2VREF_CH_MASK) if (ret || data > ADT7316_DA_2VREF_CH_MASK)
return -EINVAL; return -EINVAL;
...@@ -878,13 +878,13 @@ static ssize_t adt7316_store_DAC_update_mode(struct device *dev, ...@@ -878,13 +878,13 @@ static ssize_t adt7316_store_DAC_update_mode(struct device *dev,
struct iio_dev *dev_info = dev_to_iio_dev(dev); struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info); struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 dac_config; u8 dac_config;
unsigned long data; u8 data;
int ret; int ret;
if (!(chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA)) if (!(chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA))
return -EPERM; return -EPERM;
ret = strict_strtoul(buf, 10, &data); ret = kstrtou8(buf, 10, &data);
if (ret || data > ADT7316_DA_EN_MODE_MASK) if (ret || data > ADT7316_DA_EN_MODE_MASK)
return -EINVAL; return -EINVAL;
...@@ -933,7 +933,7 @@ static ssize_t adt7316_store_update_DAC(struct device *dev, ...@@ -933,7 +933,7 @@ static ssize_t adt7316_store_update_DAC(struct device *dev,
struct iio_dev *dev_info = dev_to_iio_dev(dev); struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info); struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 ldac_config; u8 ldac_config;
unsigned long data; u8 data;
int ret; int ret;
if (chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA) { if (chip->config3 & ADT7316_DA_EN_VIA_DAC_LDCA) {
...@@ -941,7 +941,7 @@ static ssize_t adt7316_store_update_DAC(struct device *dev, ...@@ -941,7 +941,7 @@ static ssize_t adt7316_store_update_DAC(struct device *dev,
ADT7316_DA_EN_MODE_LDAC) ADT7316_DA_EN_MODE_LDAC)
return -EPERM; return -EPERM;
ret = strict_strtoul(buf, 16, &data); ret = kstrtou8(buf, 16, &data);
if (ret || data > ADT7316_LDAC_EN_DA_MASK) if (ret || data > ADT7316_LDAC_EN_DA_MASK)
return -EINVAL; return -EINVAL;
...@@ -1079,11 +1079,11 @@ static ssize_t adt7316_store_DAC_internal_Vref(struct device *dev, ...@@ -1079,11 +1079,11 @@ static ssize_t adt7316_store_DAC_internal_Vref(struct device *dev,
struct iio_dev *dev_info = dev_to_iio_dev(dev); struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info); struct adt7316_chip_info *chip = iio_priv(dev_info);
u8 ldac_config; u8 ldac_config;
unsigned long data; u8 data;
int ret; int ret;
if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) { if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX) {
ret = strict_strtoul(buf, 16, &data); ret = kstrtou8(buf, 16, &data);
if (ret || data > 3) if (ret || data > 3)
return -EINVAL; return -EINVAL;
...@@ -1093,7 +1093,7 @@ static ssize_t adt7316_store_DAC_internal_Vref(struct device *dev, ...@@ -1093,7 +1093,7 @@ static ssize_t adt7316_store_DAC_internal_Vref(struct device *dev,
else if (data & 0x2) else if (data & 0x2)
ldac_config |= ADT7516_DAC_CD_IN_VREF; ldac_config |= ADT7516_DAC_CD_IN_VREF;
} else { } else {
ret = strict_strtoul(buf, 16, &data); ret = kstrtou8(buf, 16, &data);
if (ret) if (ret)
return -EINVAL; return -EINVAL;
...@@ -1281,11 +1281,11 @@ static ssize_t adt7316_show_temp_offset(struct adt7316_chip_info *chip, ...@@ -1281,11 +1281,11 @@ static ssize_t adt7316_show_temp_offset(struct adt7316_chip_info *chip,
static ssize_t adt7316_store_temp_offset(struct adt7316_chip_info *chip, static ssize_t adt7316_store_temp_offset(struct adt7316_chip_info *chip,
int offset_addr, const char *buf, size_t len) int offset_addr, const char *buf, size_t len)
{ {
long data; int data;
u8 val; u8 val;
int ret; int ret;
ret = strict_strtol(buf, 10, &data); ret = kstrtoint(buf, 10, &data);
if (ret || data > 127 || data < -128) if (ret || data > 127 || data < -128)
return -EINVAL; return -EINVAL;
...@@ -1442,7 +1442,7 @@ static ssize_t adt7316_store_DAC(struct adt7316_chip_info *chip, ...@@ -1442,7 +1442,7 @@ static ssize_t adt7316_store_DAC(struct adt7316_chip_info *chip,
int channel, const char *buf, size_t len) int channel, const char *buf, size_t len)
{ {
u8 msb, lsb, offset; u8 msb, lsb, offset;
unsigned long data; u16 data;
int ret; int ret;
if (channel >= ADT7316_DA_MSB_DATA_REGS || if (channel >= ADT7316_DA_MSB_DATA_REGS ||
...@@ -1454,7 +1454,7 @@ static ssize_t adt7316_store_DAC(struct adt7316_chip_info *chip, ...@@ -1454,7 +1454,7 @@ static ssize_t adt7316_store_DAC(struct adt7316_chip_info *chip,
offset = chip->dac_bits - 8; offset = chip->dac_bits - 8;
ret = strict_strtoul(buf, 10, &data); ret = kstrtou16(buf, 10, &data);
if (ret || data >= (1 << chip->dac_bits)) if (ret || data >= (1 << chip->dac_bits))
return -EINVAL; return -EINVAL;
...@@ -1830,11 +1830,11 @@ static ssize_t adt7316_set_int_mask(struct device *dev, ...@@ -1830,11 +1830,11 @@ static ssize_t adt7316_set_int_mask(struct device *dev,
{ {
struct iio_dev *dev_info = dev_to_iio_dev(dev); struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info); struct adt7316_chip_info *chip = iio_priv(dev_info);
unsigned long data; u16 data;
int ret; int ret;
u8 mask; u8 mask;
ret = strict_strtoul(buf, 16, &data); ret = kstrtou16(buf, 16, &data);
if (ret || data >= ADT7316_VDD_INT_MASK + 1) if (ret || data >= ADT7316_VDD_INT_MASK + 1)
return -EINVAL; return -EINVAL;
...@@ -1901,7 +1901,7 @@ static inline ssize_t adt7316_set_ad_bound(struct device *dev, ...@@ -1901,7 +1901,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_to_iio_dev(dev); struct iio_dev *dev_info = dev_to_iio_dev(dev);
struct adt7316_chip_info *chip = iio_priv(dev_info); struct adt7316_chip_info *chip = iio_priv(dev_info);
long data; int data;
u8 val; u8 val;
int ret; int ret;
...@@ -1909,7 +1909,7 @@ static inline ssize_t adt7316_set_ad_bound(struct device *dev, ...@@ -1909,7 +1909,7 @@ static inline ssize_t adt7316_set_ad_bound(struct device *dev,
this_attr->address > ADT7316_EX_TEMP_LOW) this_attr->address > ADT7316_EX_TEMP_LOW)
return -EPERM; return -EPERM;
ret = strict_strtol(buf, 10, &data); ret = kstrtoint(buf, 10, &data);
if (ret) if (ret)
return -EINVAL; return -EINVAL;
......
...@@ -81,9 +81,9 @@ static ssize_t ad9832_write(struct device *dev, ...@@ -81,9 +81,9 @@ static ssize_t ad9832_write(struct device *dev,
struct ad9832_state *st = iio_priv(indio_dev); struct ad9832_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret; int ret;
long val; unsigned long val;
ret = strict_strtoul(buf, 10, &val); ret = kstrtoul(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
......
...@@ -70,9 +70,9 @@ static ssize_t ad9834_write(struct device *dev, ...@@ -70,9 +70,9 @@ static ssize_t ad9834_write(struct device *dev,
struct ad9834_state *st = iio_priv(indio_dev); struct ad9834_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
int ret; int ret;
long val; unsigned long val;
ret = strict_strtoul(buf, 10, &val); ret = kstrtoul(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
......
...@@ -323,10 +323,10 @@ static ssize_t ad5933_store_frequency(struct device *dev, ...@@ -323,10 +323,10 @@ static ssize_t ad5933_store_frequency(struct device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad5933_state *st = iio_priv(indio_dev); struct ad5933_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
long val; unsigned long val;
int ret; int ret;
ret = strict_strtoul(buf, 10, &val); ret = kstrtoul(buf, 10, &val);
if (ret) if (ret)
return ret; return ret;
...@@ -400,12 +400,12 @@ static ssize_t ad5933_store(struct device *dev, ...@@ -400,12 +400,12 @@ static ssize_t ad5933_store(struct device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ad5933_state *st = iio_priv(indio_dev); struct ad5933_state *st = iio_priv(indio_dev);
struct iio_dev_attr *this_attr = to_iio_dev_attr(attr); struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
long val; u16 val;
int i, ret = 0; int i, ret = 0;
unsigned short dat; unsigned short dat;
if (this_attr->address != AD5933_IN_PGA_GAIN) { if (this_attr->address != AD5933_IN_PGA_GAIN) {
ret = strict_strtol(buf, 10, &val); ret = kstrtou16(buf, 10, &val);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -434,7 +434,7 @@ static ssize_t ad5933_store(struct device *dev, ...@@ -434,7 +434,7 @@ static ssize_t ad5933_store(struct device *dev,
ret = ad5933_cmd(st, 0); ret = ad5933_cmd(st, 0);
break; break;
case AD5933_OUT_SETTLING_CYCLES: case AD5933_OUT_SETTLING_CYCLES:
val = clamp(val, 0L, 0x7FFL); val = clamp(val, (u16)0, (u16)0x7FF);
st->settling_cycles = val; st->settling_cycles = val;
/* 2x, 4x handling, see datasheet */ /* 2x, 4x handling, see datasheet */
...@@ -448,7 +448,7 @@ static ssize_t ad5933_store(struct device *dev, ...@@ -448,7 +448,7 @@ static ssize_t ad5933_store(struct device *dev,
AD5933_REG_SETTLING_CYCLES, 2, (u8 *)&dat); AD5933_REG_SETTLING_CYCLES, 2, (u8 *)&dat);
break; break;
case AD5933_FREQ_POINTS: case AD5933_FREQ_POINTS:
val = clamp(val, 0L, 511L); val = clamp(val, (u16)0, (u16)511);
st->freq_points = val; st->freq_points = val;
dat = cpu_to_be16(val); dat = cpu_to_be16(val);
......
...@@ -240,7 +240,7 @@ static ssize_t store_range(struct device *dev, ...@@ -240,7 +240,7 @@ static ssize_t store_range(struct device *dev,
unsigned long lval; unsigned long lval;
unsigned int new_range; unsigned int new_range;
if (strict_strtoul(buf, 10, &lval)) if (kstrtoul(buf, 10, &lval))
return -EINVAL; return -EINVAL;
if (!(lval == 1000UL || lval == 4000UL || if (!(lval == 1000UL || lval == 4000UL ||
...@@ -279,18 +279,18 @@ static ssize_t store_resolution(struct device *dev, ...@@ -279,18 +279,18 @@ static ssize_t store_resolution(struct device *dev,
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct isl29018_chip *chip = iio_priv(indio_dev); struct isl29018_chip *chip = iio_priv(indio_dev);
int status; int status;
unsigned long lval; unsigned int val;
unsigned int new_adc_bit; unsigned int new_adc_bit;
if (strict_strtoul(buf, 10, &lval)) if (kstrtouint(buf, 10, &val))
return -EINVAL; return -EINVAL;
if (!(lval == 4 || lval == 8 || lval == 12 || lval == 16)) { if (!(val == 4 || val == 8 || val == 12 || val == 16)) {
dev_err(dev, "The resolution is not supported\n"); dev_err(dev, "The resolution is not supported\n");
return -EINVAL; return -EINVAL;
} }
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
status = isl29018_set_resolution(chip, lval, &new_adc_bit); status = isl29018_set_resolution(chip, val, &new_adc_bit);
if (status < 0) { if (status < 0) {
mutex_unlock(&chip->lock); mutex_unlock(&chip->lock);
dev_err(dev, "Error in setting resolution\n"); dev_err(dev, "Error in setting resolution\n");
...@@ -319,11 +319,11 @@ static ssize_t store_prox_infrared_suppression(struct device *dev, ...@@ -319,11 +319,11 @@ static ssize_t store_prox_infrared_suppression(struct device *dev,
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct isl29018_chip *chip = iio_priv(indio_dev); struct isl29018_chip *chip = iio_priv(indio_dev);
unsigned long lval; int val;
if (strict_strtoul(buf, 10, &lval)) if (kstrtoint(buf, 10, &val))
return -EINVAL; return -EINVAL;
if (!(lval == 0UL || lval == 1UL)) { if (!(val == 0 || val == 1)) {
dev_err(dev, "The mode is not supported\n"); dev_err(dev, "The mode is not supported\n");
return -EINVAL; return -EINVAL;
} }
...@@ -331,7 +331,7 @@ static ssize_t store_prox_infrared_suppression(struct device *dev, ...@@ -331,7 +331,7 @@ static ssize_t store_prox_infrared_suppression(struct device *dev,
/* get the "proximity scheme" i.e. if the chip does on chip /* get the "proximity scheme" i.e. if the chip does on chip
infrared suppression (1 means perform on chip suppression) */ infrared suppression (1 means perform on chip suppression) */
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
chip->prox_scheme = (int)lval; chip->prox_scheme = val;
mutex_unlock(&chip->lock); mutex_unlock(&chip->lock);
return count; return count;
......
...@@ -493,9 +493,9 @@ static ssize_t taos_power_state_store(struct device *dev, ...@@ -493,9 +493,9 @@ static ssize_t taos_power_state_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len) struct device_attribute *attr, const char *buf, size_t len)
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
unsigned long value; int value;
if (strict_strtoul(buf, 0, &value)) if (kstrtoint(buf, 0, &value))
return -EINVAL; return -EINVAL;
if (value == 0) if (value == 0)
...@@ -536,9 +536,9 @@ static ssize_t taos_gain_store(struct device *dev, ...@@ -536,9 +536,9 @@ static ssize_t taos_gain_store(struct device *dev,
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev); struct tsl2583_chip *chip = iio_priv(indio_dev);
unsigned long value; int value;
if (strict_strtoul(buf, 0, &value)) if (kstrtoint(buf, 0, &value))
return -EINVAL; return -EINVAL;
switch (value) { switch (value) {
...@@ -582,9 +582,9 @@ static ssize_t taos_als_time_store(struct device *dev, ...@@ -582,9 +582,9 @@ static ssize_t taos_als_time_store(struct device *dev,
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev); struct tsl2583_chip *chip = iio_priv(indio_dev);
unsigned long value; int value;
if (strict_strtoul(buf, 0, &value)) if (kstrtoint(buf, 0, &value))
return -EINVAL; return -EINVAL;
if ((value < 50) || (value > 650)) if ((value < 50) || (value > 650))
...@@ -619,9 +619,9 @@ static ssize_t taos_als_trim_store(struct device *dev, ...@@ -619,9 +619,9 @@ static ssize_t taos_als_trim_store(struct device *dev,
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev); struct tsl2583_chip *chip = iio_priv(indio_dev);
unsigned long value; int value;
if (strict_strtoul(buf, 0, &value)) if (kstrtoint(buf, 0, &value))
return -EINVAL; return -EINVAL;
if (value) if (value)
...@@ -644,9 +644,9 @@ static ssize_t taos_als_cal_target_store(struct device *dev, ...@@ -644,9 +644,9 @@ static ssize_t taos_als_cal_target_store(struct device *dev,
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct tsl2583_chip *chip = iio_priv(indio_dev); struct tsl2583_chip *chip = iio_priv(indio_dev);
unsigned long value; int value;
if (strict_strtoul(buf, 0, &value)) if (kstrtoint(buf, 0, &value))
return -EINVAL; return -EINVAL;
if (value) if (value)
...@@ -671,9 +671,9 @@ static ssize_t taos_do_calibrate(struct device *dev, ...@@ -671,9 +671,9 @@ static ssize_t taos_do_calibrate(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len) struct device_attribute *attr, const char *buf, size_t len)
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
unsigned long value; int value;
if (strict_strtoul(buf, 0, &value)) if (kstrtoint(buf, 0, &value))
return -EINVAL; return -EINVAL;
if (value == 1) if (value == 1)
......
...@@ -186,9 +186,9 @@ static ssize_t ade7753_write_8bit(struct device *dev, ...@@ -186,9 +186,9 @@ static ssize_t ade7753_write_8bit(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);
int ret; int ret;
long val; u8 val;
ret = strict_strtol(buf, 10, &val); ret = kstrtou8(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = ade7753_spi_write_reg_8(dev, this_attr->address, val); ret = ade7753_spi_write_reg_8(dev, this_attr->address, val);
...@@ -204,9 +204,9 @@ static ssize_t ade7753_write_16bit(struct device *dev, ...@@ -204,9 +204,9 @@ static ssize_t ade7753_write_16bit(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);
int ret; int ret;
long val; u16 val;
ret = strict_strtol(buf, 10, &val); ret = kstrtou16(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = ade7753_spi_write_reg_16(dev, this_attr->address, val); ret = ade7753_spi_write_reg_16(dev, this_attr->address, val);
...@@ -399,11 +399,11 @@ static ssize_t ade7753_write_frequency(struct device *dev, ...@@ -399,11 +399,11 @@ static ssize_t ade7753_write_frequency(struct device *dev,
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7753_state *st = iio_priv(indio_dev); struct ade7753_state *st = iio_priv(indio_dev);
unsigned long val; u16 val;
int ret; int ret;
u16 reg, t; u16 reg, t;
ret = strict_strtol(buf, 10, &val); ret = kstrtou16(buf, 10, &val);
if (ret) if (ret)
return ret; return ret;
if (val == 0) if (val == 0)
......
...@@ -186,9 +186,9 @@ static ssize_t ade7754_write_8bit(struct device *dev, ...@@ -186,9 +186,9 @@ static ssize_t ade7754_write_8bit(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);
int ret; int ret;
long val; u8 val;
ret = strict_strtol(buf, 10, &val); ret = kstrtou8(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = ade7754_spi_write_reg_8(dev, this_attr->address, val); ret = ade7754_spi_write_reg_8(dev, this_attr->address, val);
...@@ -204,9 +204,9 @@ static ssize_t ade7754_write_16bit(struct device *dev, ...@@ -204,9 +204,9 @@ static ssize_t ade7754_write_16bit(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);
int ret; int ret;
long val; u16 val;
ret = strict_strtol(buf, 10, &val); ret = kstrtou16(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = ade7754_spi_write_reg_16(dev, this_attr->address, val); ret = ade7754_spi_write_reg_16(dev, this_attr->address, val);
...@@ -419,11 +419,11 @@ static ssize_t ade7754_write_frequency(struct device *dev, ...@@ -419,11 +419,11 @@ static ssize_t ade7754_write_frequency(struct device *dev,
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7754_state *st = iio_priv(indio_dev); struct ade7754_state *st = iio_priv(indio_dev);
unsigned long val; u16 val;
int ret; int ret;
u8 reg, t; u8 reg, t;
ret = strict_strtol(buf, 10, &val); ret = kstrtou16(buf, 10, &val);
if (ret) if (ret)
return ret; return ret;
if (val == 0) if (val == 0)
......
...@@ -269,9 +269,9 @@ static ssize_t ade7758_write_8bit(struct device *dev, ...@@ -269,9 +269,9 @@ static ssize_t ade7758_write_8bit(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);
int ret; int ret;
long val; u8 val;
ret = strict_strtol(buf, 10, &val); ret = kstrtou8(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = ade7758_spi_write_reg_8(dev, this_attr->address, val); ret = ade7758_spi_write_reg_8(dev, this_attr->address, val);
...@@ -287,9 +287,9 @@ static ssize_t ade7758_write_16bit(struct device *dev, ...@@ -287,9 +287,9 @@ static ssize_t ade7758_write_16bit(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);
int ret; int ret;
long val; u16 val;
ret = strict_strtol(buf, 10, &val); ret = kstrtou16(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = ade7758_spi_write_reg_16(dev, this_attr->address, val); ret = ade7758_spi_write_reg_16(dev, this_attr->address, val);
...@@ -502,11 +502,11 @@ static ssize_t ade7758_write_frequency(struct device *dev, ...@@ -502,11 +502,11 @@ static ssize_t ade7758_write_frequency(struct device *dev,
size_t len) size_t len)
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
unsigned long val; u16 val;
int ret; int ret;
u8 reg, t; u8 reg, t;
ret = strict_strtol(buf, 10, &val); ret = kstrtou16(buf, 10, &val);
if (ret) if (ret)
return ret; return ret;
......
...@@ -185,9 +185,9 @@ static ssize_t ade7759_write_8bit(struct device *dev, ...@@ -185,9 +185,9 @@ static ssize_t ade7759_write_8bit(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);
int ret; int ret;
long val; u8 val;
ret = strict_strtol(buf, 10, &val); ret = kstrtou8(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = ade7759_spi_write_reg_8(dev, this_attr->address, val); ret = ade7759_spi_write_reg_8(dev, this_attr->address, val);
...@@ -203,9 +203,9 @@ static ssize_t ade7759_write_16bit(struct device *dev, ...@@ -203,9 +203,9 @@ static ssize_t ade7759_write_16bit(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);
int ret; int ret;
long val; u16 val;
ret = strict_strtol(buf, 10, &val); ret = kstrtou16(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = ade7759_spi_write_reg_16(dev, this_attr->address, val); ret = ade7759_spi_write_reg_16(dev, this_attr->address, val);
...@@ -360,11 +360,11 @@ static ssize_t ade7759_write_frequency(struct device *dev, ...@@ -360,11 +360,11 @@ static ssize_t ade7759_write_frequency(struct device *dev,
{ {
struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct ade7759_state *st = iio_priv(indio_dev); struct ade7759_state *st = iio_priv(indio_dev);
unsigned long val; u16 val;
int ret; int ret;
u16 reg, t; u16 reg, t;
ret = strict_strtol(buf, 10, &val); ret = kstrtou16(buf, 10, &val);
if (ret) if (ret)
return ret; return ret;
if (val == 0) if (val == 0)
......
...@@ -100,9 +100,9 @@ static ssize_t ade7854_write_8bit(struct device *dev, ...@@ -100,9 +100,9 @@ static ssize_t ade7854_write_8bit(struct device *dev,
struct ade7854_state *st = iio_priv(indio_dev); struct ade7854_state *st = iio_priv(indio_dev);
int ret; int ret;
long val; u8 val;
ret = strict_strtol(buf, 10, &val); ret = kstrtou8(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = st->write_reg_8(dev, this_attr->address, val); ret = st->write_reg_8(dev, this_attr->address, val);
...@@ -121,9 +121,9 @@ static ssize_t ade7854_write_16bit(struct device *dev, ...@@ -121,9 +121,9 @@ static ssize_t ade7854_write_16bit(struct device *dev,
struct ade7854_state *st = iio_priv(indio_dev); struct ade7854_state *st = iio_priv(indio_dev);
int ret; int ret;
long val; u16 val;
ret = strict_strtol(buf, 10, &val); ret = kstrtou16(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = st->write_reg_16(dev, this_attr->address, val); ret = st->write_reg_16(dev, this_attr->address, val);
...@@ -142,9 +142,9 @@ static ssize_t ade7854_write_24bit(struct device *dev, ...@@ -142,9 +142,9 @@ static ssize_t ade7854_write_24bit(struct device *dev,
struct ade7854_state *st = iio_priv(indio_dev); struct ade7854_state *st = iio_priv(indio_dev);
int ret; int ret;
long val; u32 val;
ret = strict_strtol(buf, 10, &val); ret = kstrtou32(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = st->write_reg_24(dev, this_attr->address, val); ret = st->write_reg_24(dev, this_attr->address, val);
...@@ -163,9 +163,9 @@ static ssize_t ade7854_write_32bit(struct device *dev, ...@@ -163,9 +163,9 @@ static ssize_t ade7854_write_32bit(struct device *dev,
struct ade7854_state *st = iio_priv(indio_dev); struct ade7854_state *st = iio_priv(indio_dev);
int ret; int ret;
long val; u32 val;
ret = strict_strtol(buf, 10, &val); ret = kstrtou32(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
ret = st->write_reg_32(dev, this_attr->address, val); ret = st->write_reg_32(dev, this_attr->address, val);
......
...@@ -206,10 +206,10 @@ static ssize_t ad2s1210_store_fclkin(struct device *dev, ...@@ -206,10 +206,10 @@ static ssize_t ad2s1210_store_fclkin(struct device *dev,
size_t len) size_t len)
{ {
struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
unsigned long fclkin; unsigned int fclkin;
int ret; int ret;
ret = strict_strtoul(buf, 10, &fclkin); ret = kstrtouint(buf, 10, &fclkin);
if (ret) if (ret)
return ret; return ret;
if (fclkin < AD2S1210_MIN_CLKIN || fclkin > AD2S1210_MAX_CLKIN) { if (fclkin < AD2S1210_MIN_CLKIN || fclkin > AD2S1210_MAX_CLKIN) {
...@@ -243,10 +243,10 @@ static ssize_t ad2s1210_store_fexcit(struct device *dev, ...@@ -243,10 +243,10 @@ static ssize_t ad2s1210_store_fexcit(struct device *dev,
const char *buf, size_t len) const char *buf, size_t len)
{ {
struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
unsigned long fexcit; unsigned int fexcit;
int ret; int ret;
ret = strict_strtoul(buf, 10, &fexcit); ret = kstrtouint(buf, 10, &fexcit);
if (ret < 0) if (ret < 0)
return ret; return ret;
if (fexcit < AD2S1210_MIN_EXCIT || fexcit > AD2S1210_MAX_EXCIT) { if (fexcit < AD2S1210_MIN_EXCIT || fexcit > AD2S1210_MAX_EXCIT) {
...@@ -282,11 +282,11 @@ static ssize_t ad2s1210_store_control(struct device *dev, ...@@ -282,11 +282,11 @@ static ssize_t ad2s1210_store_control(struct device *dev,
const char *buf, size_t len) const char *buf, size_t len)
{ {
struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
unsigned long udata; unsigned char udata;
unsigned char data; unsigned char data;
int ret; int ret;
ret = strict_strtoul(buf, 16, &udata); ret = kstrtou8(buf, 16, &udata);
if (ret) if (ret)
return -EINVAL; return -EINVAL;
...@@ -337,10 +337,10 @@ static ssize_t ad2s1210_store_resolution(struct device *dev, ...@@ -337,10 +337,10 @@ static ssize_t ad2s1210_store_resolution(struct device *dev,
{ {
struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
unsigned char data; unsigned char data;
unsigned long udata; unsigned char udata;
int ret; int ret;
ret = strict_strtoul(buf, 10, &udata); ret = kstrtou8(buf, 10, &udata);
if (ret || udata < 10 || udata > 16) { if (ret || udata < 10 || udata > 16) {
pr_err("ad2s1210: resolution out of range\n"); pr_err("ad2s1210: resolution out of range\n");
return -EINVAL; return -EINVAL;
...@@ -438,11 +438,11 @@ static ssize_t ad2s1210_store_reg(struct device *dev, ...@@ -438,11 +438,11 @@ static ssize_t ad2s1210_store_reg(struct device *dev,
struct device_attribute *attr, const char *buf, size_t len) struct device_attribute *attr, const char *buf, size_t len)
{ {
struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev)); struct ad2s1210_state *st = iio_priv(dev_to_iio_dev(dev));
unsigned long data; unsigned char data;
int ret; int ret;
struct iio_dev_attr *iattr = to_iio_dev_attr(attr); struct iio_dev_attr *iattr = to_iio_dev_attr(attr);
ret = strict_strtoul(buf, 10, &data); ret = kstrtou8(buf, 10, &data);
if (ret) if (ret)
return -EINVAL; return -EINVAL;
mutex_lock(&st->lock); mutex_lock(&st->lock);
......
...@@ -83,32 +83,28 @@ static ssize_t iio_bfin_tmr_frequency_store(struct device *dev, ...@@ -83,32 +83,28 @@ static ssize_t iio_bfin_tmr_frequency_store(struct device *dev,
{ {
struct iio_trigger *trig = to_iio_trigger(dev); struct iio_trigger *trig = to_iio_trigger(dev);
struct bfin_tmr_state *st = iio_trigger_get_drvdata(trig); struct bfin_tmr_state *st = iio_trigger_get_drvdata(trig);
unsigned long val; unsigned int val;
bool enabled; bool enabled;
int ret; int ret;
ret = strict_strtoul(buf, 10, &val); ret = kstrtouint(buf, 10, &val);
if (ret) if (ret)
goto error_ret; return ret;
if (val > 100000) { if (val > 100000) {
ret = -EINVAL; return -EINVAL;
goto error_ret;
}
enabled = get_enabled_gptimers() & st->t->bit; enabled = get_enabled_gptimers() & st->t->bit;
if (enabled) if (enabled)
disable_gptimers(st->t->bit); disable_gptimers(st->t->bit);
if (!val) if (val == 0)
goto error_ret; return count;
val = get_sclk() / val; val = get_sclk() / val;
if (val <= 4 || val <= st->duty) { if (val <= 4 || val <= st->duty)
ret = -EINVAL; return -EINVAL;
goto error_ret;
}
set_gptimer_period(st->t->id, val); set_gptimer_period(st->t->id, val);
set_gptimer_pwidth(st->t->id, val - st->duty); set_gptimer_pwidth(st->t->id, val - st->duty);
...@@ -116,8 +112,7 @@ static ssize_t iio_bfin_tmr_frequency_store(struct device *dev, ...@@ -116,8 +112,7 @@ static ssize_t iio_bfin_tmr_frequency_store(struct device *dev,
if (enabled) if (enabled)
enable_gptimers(st->t->bit); enable_gptimers(st->t->bit);
error_ret: return count;
return ret ? ret : count;
} }
static ssize_t iio_bfin_tmr_frequency_show(struct device *dev, static ssize_t iio_bfin_tmr_frequency_show(struct device *dev,
......
...@@ -53,10 +53,10 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev, ...@@ -53,10 +53,10 @@ static ssize_t iio_trig_periodic_write_freq(struct device *dev,
{ {
struct iio_trigger *trig = to_iio_trigger(dev); struct iio_trigger *trig = to_iio_trigger(dev);
struct iio_prtc_trigger_info *trig_info = iio_trigger_get_drvdata(trig); struct iio_prtc_trigger_info *trig_info = iio_trigger_get_drvdata(trig);
unsigned long val; int val;
int ret; int ret;
ret = strict_strtoul(buf, 10, &val); ret = kstrtoint(buf, 10, &val);
if (ret) if (ret)
goto error_ret; goto error_ret;
......
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