misc: replace strict_strtoul() with kstrtoul()
Subsystems (3)
PATCH v2 1/1 misc: replace strict_strtoul() with kstrtoul()
The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used.
---
Changes since v1:
- Used return code from kstrtoul().
drivers/misc/ad525x_dpot.c | 2 +- drivers/misc/apds9802als.c | 5 +-- drivers/misc/apds990x.c | 37 ++++++++++++------- drivers/misc/bh1770glc.c | 59 ++++++++++++++++++++----------- drivers/misc/bh1780gli.c | 2 +- drivers/misc/carma/carma-fpga-program.c | 10 +++--- drivers/misc/carma/carma-fpga.c | 4 +-- drivers/misc/hmc6352.c | 5 +-- drivers/misc/isl29003.c | 20 ++++++----- drivers/misc/isl29020.c | 6 ++-- drivers/misc/lis3lv02d/lis3lv02d.c | 6 ++-- drivers/misc/sgi-gru/gruprocfs.c | 7 ++-- drivers/misc/spear13xx_pcie_gadget.c | 57 +++++++++++++++++++---------- drivers/misc/ti_dac7512.c | 6 ++-- 14 files changed, 146 insertions(+), 80 deletions(-)
drivers/misc/ad525x_dpot.c +1 -1
@@ -470,7 +470,7 @@ static ssize_t sysfs_set_reg(struct device *dev, !test_bit(DPOT_RDAC_MASK & reg, data->otp_en_mask))return -EPERM ; - err =strict_strtoul (buf,10 , &value); + err =kstrtoul (buf,10 , &value);if (err)return err;
drivers/misc/apds9802als.c +3 -2
@@ -126,8 +126,9 @@ static ssize_t als_sensing_range_store(struct device *dev,int ret_val;unsigned long val; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + ret_val =kstrtoul (buf,10 , &val); +if (ret_val) +return ret_val;if (val <4096 ) val =1 ;
drivers/misc/apds990x.c +24 -13
@@ -696,9 +696,11 @@ static ssize_t apds990x_lux_calib_store(struct device *dev, {struct apds990x_chip *chip =dev_get_drvdata (dev);unsigned long value; +int ret; -if (strict_strtoul (buf,0 , &value)) -return -EINVAL ; + ret =kstrtoul (buf,0 , &value); +if (ret) +return ret; chip->lux_calib = value;
@@ -759,8 +761,9 @@ static ssize_t apds990x_rate_store(struct device *dev,unsigned long value;int ret; -if (strict_strtoul (buf,0 , &value)) -return -EINVAL ; + ret =kstrtoul (buf,0 , &value); +if (ret) +return ret;mutex_lock (&chip->mutex); ret =apds990x_set_arate (chip, value);
@@ -813,9 +816,11 @@ static ssize_t apds990x_prox_enable_store(struct device *dev, {struct apds990x_chip *chip =dev_get_drvdata (dev);unsigned long value; +int ret; -if (strict_strtoul (buf,0 , &value)) -return -EINVAL ; + ret =kstrtoul (buf,0 , &value); +if (ret) +return ret;mutex_lock (&chip->mutex);
@@ -892,11 +897,12 @@ static ssize_t apds990x_lux_thresh_below_show(struct device *dev,static ssize_t apds990x_set_lux_thresh (struct apds990x_chip *chip,u32 *target,const char *buf) { -int ret =0 ;unsigned long thresh; +int ret; -if (strict_strtoul (buf,0 , &thresh)) -return -EINVAL ; + ret =kstrtoul (buf,0 , &thresh); +if (ret) +return ret;if (thresh >APDS_RANGE )return -EINVAL ;
@@ -957,9 +963,11 @@ static ssize_t apds990x_prox_threshold_store(struct device *dev, {struct apds990x_chip *chip =dev_get_drvdata (dev);unsigned long value; +int ret; -if (strict_strtoul (buf,0 , &value)) -return -EINVAL ; + ret =kstrtoul (buf,0 , &value); +if (ret) +return ret;if ((value >APDS_RANGE ) || (value ==0 ) || (value <APDS_PROX_HYSTERESIS ))
@@ -990,9 +998,12 @@ static ssize_t apds990x_power_state_store(struct device *dev, {struct apds990x_chip *chip =dev_get_drvdata (dev);unsigned long value; +int ret; + + ret =kstrtoul (buf,0 , &value); +if (ret) +return ret; -if (strict_strtoul (buf,0 , &value)) -return -EINVAL ;if (value) {pm_runtime_get_sync (dev);mutex_lock (&chip->mutex);
drivers/misc/bh1770glc.c +38 -21
127 lines not on this page · raw message
drivers/misc/bh1780gli.c +1 -1
@@ -107,7 +107,7 @@ static ssize_t bh1780_store_power_state(struct device *dev,unsigned long val;int error; - error =strict_strtoul (buf,0 , &val); + error =kstrtoul (buf,0 , &val);if (error)return error;
drivers/misc/carma/carma-fpga-program.c +6 -4
@@ -830,8 +830,9 @@ static ssize_t penable_store(struct device *dev, struct device_attribute *attr,unsigned long val;int ret; -if (strict_strtoul (buf,0 , &val)) -return -EINVAL ; + ret =kstrtoul (buf,0 , &val); +if (ret) +return ret;if (val) { ret =fpga_enable_power_supplies (priv);
@@ -859,8 +860,9 @@ static ssize_t program_store(struct device *dev, struct device_attribute *attr,unsigned long val;int ret; -if (strict_strtoul (buf,0 , &val)) -return -EINVAL ; + ret =kstrtoul (buf,0 , &val); +if (ret) +return ret;/* We can't have an image writer and be programming simultaneously */ if (mutex_lock_interruptible (&priv->lock))
drivers/misc/carma/carma-fpga.c +2 -2
@@ -1002,10 +1002,10 @@ static ssize_t data_en_set(struct device *dev, struct device_attribute *attr,unsigned long enable;int ret; - ret =strict_strtoul (buf,0 , &enable); + ret =kstrtoul (buf,0 , &enable);if (ret) {dev_err (priv->dev,"unable to parse enable input\n" ); -return -EINVAL ; +return ret; }/* protect against concurrent enable/disable */
drivers/misc/hmc6352.c +3 -2
@@ -46,8 +46,9 @@ static int compass_store(struct device *dev, const char *buf, size_t count,int ret;unsigned long val; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + ret =kstrtoul (buf,10 , &val); +if (ret) +return ret;if (val >=strlen (map))return -EINVAL ;mutex_lock (&compass_mutex);
drivers/misc/isl29003.c +12 -8
@@ -208,8 +208,9 @@ static ssize_t isl29003_store_range(struct device *dev,unsigned long val;int ret; -if ((strict_strtoul (buf,10 , &val) <0 ) || (val >3 )) -return -EINVAL ; + ret = (kstrtoul (buf,10 , &val) <0 ) || (val >3 ); +if (ret) +return ret; ret =isl29003_set_range (client, val);if (ret <0 )
@@ -239,8 +240,9 @@ static ssize_t isl29003_store_resolution(struct device *dev,unsigned long val;int ret; -if ((strict_strtoul (buf,10 , &val) <0 ) || (val >3 )) -return -EINVAL ; + ret = (kstrtoul (buf,10 , &val) <0 ) || (val >3 ); +if (ret) +return ret; ret =isl29003_set_resolution (client, val);if (ret <0 )
@@ -267,8 +269,9 @@ static ssize_t isl29003_store_mode(struct device *dev,unsigned long val;int ret; -if ((strict_strtoul (buf,10 , &val) <0 ) || (val >2 )) -return -EINVAL ; + ret = (kstrtoul (buf,10 , &val) <0 ) || (val >2 ); +if (ret) +return ret; ret =isl29003_set_mode (client, val);if (ret <0 )
@@ -298,8 +301,9 @@ static ssize_t isl29003_store_power_state(struct device *dev,unsigned long val;int ret; -if ((strict_strtoul (buf,10 , &val) <0 ) || (val >1 )) -return -EINVAL ; + ret = (kstrtoul (buf,10 , &val) <0 ) || (val >1 ); +if (ret) +return ret; ret =isl29003_set_power_state (client, val);return ret ? ret : count;
drivers/misc/isl29020.c +4 -2
@@ -90,8 +90,10 @@ static ssize_t als_sensing_range_store(struct device *dev,int ret_val;unsigned long val; -if (strict_strtoul (buf,10 , &val)) -return -EINVAL ; + ret_val =kstrtoul (buf,10 , &val); +if (ret_val) +return ret_val; +if (val <1 || val >64000 )return -EINVAL ;
drivers/misc/lis3lv02d/lis3lv02d.c +4 -2
@@ -831,9 +831,11 @@ static ssize_t lis3lv02d_rate_set(struct device *dev, {struct lis3lv02d *lis3 =dev_get_drvdata (dev);unsigned long rate; +int ret; -if (strict_strtoul (buf,0 , &rate)) -return -EINVAL ; + ret =kstrtoul (buf,0 , &rate); +if (ret) +return ret;lis3lv02d_sysfs_poweron (lis3);if (lis3lv02d_set_odr (lis3, rate))
drivers/misc/sgi-gru/gruprocfs.c +5 -2
@@ -161,14 +161,17 @@ static ssize_t options_write(struct file *file, const char __user *userbuf, size_t count, loff_t *data) { char buf[20]; +int ret;if (count >=sizeof (buf))return -EINVAL ;if (copy_from_user (buf, userbuf, count))return -EFAULT ; buf[count] ='\0' ; -if (strict_strtoul (buf,0 , &gru_options)) -return -EINVAL ; + + ret =kstrtoul (buf,0 , &gru_options); +if (ret) +return ret;return count; }
drivers/misc/spear13xx_pcie_gadget.c +39 -18
119 lines not on this page · raw message
drivers/misc/ti_dac7512.c +4 -2
@@ -33,9 +33,11 @@ static ssize_t dac7512_store_val(struct device *dev,struct spi_device *spi =to_spi_device (dev);unsigned char tmp[2 ];unsigned long val; +int ret; -if (strict_strtoul (buf,10 , &val) <0 ) -return -EINVAL ; + ret =kstrtoul (buf,10 , &val); +if (ret) +return ret; tmp[0 ] = val >>8 ; tmp[1 ] = val &0xff ;
Signature · 1 line
1.7.10.4
Quoted 5 lines · Jingoo Han
The usage of
strict_strtoul()is not preferred, becausestrict_strtoul()is obsolete. Thus,kstrtoul()should be used.Signed-off-by Jingoo Han <[email protected]>
There are few issues. Afrter addressing them take my
drivers/misc/isl29003.c static ssize_t isl29003_store_range(struct device *dev, · line 213
Quoted 11 lines
drivers/misc/isl29003.c +3
-2@@ -208,8 +208,9 @@ static ssize_t isl29003_store_range(struct device *dev,unsigned long val;int ret; -if ((strict_strtoul (buf,10 , &val) <0 ) || (val >3 )) -return -EINVAL ; + ret = (kstrtoul (buf,10 , &val) <0 ) || (val >3 ); +if (ret) +return ret;
It's not correct.
You have to get return code from kstrtoul() separately and use it, after check top boundary and return -EINVAL.
Three more cases below.
Quoted 44 lines
drivers/misc/isl29003.c +9
-6@@ -239,8 +240,9 @@ static ssize_t isl29003_store_resolution(struct device *dev,unsigned long val;int ret; -if ((strict_strtoul (buf,10 , &val) <0 ) || (val >3 )) -return -EINVAL ; + ret = (kstrtoul (buf,10 , &val) <0 ) || (val >3 ); +if (ret) +return ret; ret =isl29003_set_resolution (client, val);if (ret <0 )@@ -267,8 +269,9 @@ static ssize_t isl29003_store_mode(struct device *dev,unsigned long val;int ret; -if ((strict_strtoul (buf,10 , &val) <0 ) || (val >2 )) -return -EINVAL ; + ret = (kstrtoul (buf,10 , &val) <0 ) || (val >2 ); +if (ret) +return ret; ret =isl29003_set_mode (client, val);if (ret <0 )@@ -298,8 +301,9 @@ static ssize_t isl29003_store_power_state(struct device *dev,unsigned long val;int ret; -if ((strict_strtoul (buf,10 , &val) <0 ) || (val >1 )) -return -EINVAL ; + ret = (kstrtoul (buf,10 , &val) <0 ) || (val >1 ); +if (ret) +return ret; ret =isl29003_set_power_state (client, val);return ret ? ret : count;drivers/misc/sgi-gru/gruprocfs.c +1
-0@@ -161,14 +161,17 @@ static ssize_t options_write(struct file *file, const char __user *userbuf, size_t count, loff_t *data) { char buf[20]; +int ret;
drivers/misc/sgi-gru/gruprocfs.c static ssize_t options_write(struct file *file, const char __user *userbuf, · line 172
Quoted 10 lines
drivers/misc/sgi-gru/gruprocfs.c +2
-2if (count >=sizeof (buf))return -EINVAL ;if (copy_from_user (buf, userbuf, count))return -EFAULT ; buf[count] ='\0' ; -if (strict_strtoul (buf,0 , &gru_options)) -return -EINVAL ; + + ret =kstrtoul (buf,0 , &gru_options);
kstrtoul_from_user(), please.
drivers/misc/sgi-gru/gruprocfs.c static ssize_t options_write(struct file *file, const char __user *userbuf, · line 177
Quoted 5 lines
drivers/misc/sgi-gru/gruprocfs.c +2
-0+if (ret) +return ret;return count; }
--
With Best Regards,
Andy Shevchenko