Skip to content

Commit

Permalink
misc: replace strict_strtoul() with kstrtoul()
Browse files Browse the repository at this point in the history
The usage of strict_strtoul() is not preferred, because
strict_strtoul() is obsolete. Thus, kstrtoul() should be
used.

Signed-off-by: Jingoo Han <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Jingoo Han authored and gregkh committed Jun 6, 2013
1 parent 4cd5773 commit f7b4127
Show file tree
Hide file tree
Showing 14 changed files with 154 additions and 83 deletions.
2 changes: 1 addition & 1 deletion drivers/misc/ad525x_dpot.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
5 changes: 3 additions & 2 deletions drivers/misc/apds9802als.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
37 changes: 24 additions & 13 deletions drivers/misc/apds990x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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);
Expand Down
59 changes: 38 additions & 21 deletions drivers/misc/bh1770glc.c
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,9 @@ static ssize_t bh1770_power_state_store(struct device *dev,
unsigned long value;
ssize_t ret;

if (strict_strtoul(buf, 0, &value))
return -EINVAL;
ret = kstrtoul(buf, 0, &value);
if (ret)
return ret;

mutex_lock(&chip->mutex);
if (value) {
Expand Down Expand Up @@ -726,9 +727,11 @@ static ssize_t bh1770_prox_enable_store(struct device *dev,
{
struct bh1770_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);
/* Assume no proximity. Sensor will tell real state soon */
Expand Down Expand Up @@ -824,9 +827,11 @@ static ssize_t bh1770_set_prox_rate_above(struct device *dev,
{
struct bh1770_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);
chip->prox_rate_threshold = bh1770_prox_rate_validate(value);
Expand All @@ -840,9 +845,11 @@ static ssize_t bh1770_set_prox_rate_below(struct device *dev,
{
struct bh1770_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);
chip->prox_rate = bh1770_prox_rate_validate(value);
Expand All @@ -865,8 +872,10 @@ static ssize_t bh1770_set_prox_thres(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;

if (value > BH1770_PROX_RANGE)
return -EINVAL;

Expand All @@ -893,9 +902,11 @@ static ssize_t bh1770_prox_persistence_store(struct device *dev,
{
struct bh1770_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 > BH1770_PROX_MAX_PERSISTENCE)
return -EINVAL;
Expand All @@ -918,9 +929,11 @@ static ssize_t bh1770_prox_abs_thres_store(struct device *dev,
{
struct bh1770_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 > BH1770_PROX_RANGE)
return -EINVAL;
Expand Down Expand Up @@ -963,9 +976,11 @@ static ssize_t bh1770_lux_calib_store(struct device *dev,
unsigned long value;
u32 old_calib;
u32 new_corr;
int ret;

if (strict_strtoul(buf, 0, &value))
return -EINVAL;
ret = kstrtoul(buf, 0, &value);
if (ret)
return ret;

mutex_lock(&chip->mutex);
old_calib = chip->lux_calib;
Expand Down Expand Up @@ -1012,8 +1027,9 @@ static ssize_t bh1770_set_lux_rate(struct device *dev,
unsigned long rate_hz;
int ret, i;

if (strict_strtoul(buf, 0, &rate_hz))
return -EINVAL;
ret = kstrtoul(buf, 0, &rate_hz);
if (ret)
return ret;

for (i = 0; i < ARRAY_SIZE(lux_rates_hz) - 1; i++)
if (rate_hz >= lux_rates_hz[i])
Expand Down Expand Up @@ -1047,11 +1063,12 @@ static ssize_t bh1770_get_lux_thresh_below(struct device *dev,
static ssize_t bh1770_set_lux_thresh(struct bh1770_chip *chip, u16 *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 > BH1770_LUX_RANGE)
return -EINVAL;
Expand Down
2 changes: 1 addition & 1 deletion drivers/misc/bh1780gli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
10 changes: 6 additions & 4 deletions drivers/misc/carma/carma-fpga-program.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down
4 changes: 2 additions & 2 deletions drivers/misc/carma/carma-fpga.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
5 changes: 3 additions & 2 deletions drivers/misc/hmc6352.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 20 additions & 4 deletions drivers/misc/isl29003.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ static ssize_t isl29003_store_range(struct device *dev,
unsigned long val;
int ret;

if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
ret = kstrtoul(buf, 10, &val);
if (ret)
return ret;

if (val > 3)
return -EINVAL;

ret = isl29003_set_range(client, val);
Expand Down Expand Up @@ -239,7 +243,11 @@ static ssize_t isl29003_store_resolution(struct device *dev,
unsigned long val;
int ret;

if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
ret = kstrtoul(buf, 10, &val);
if (ret)
return ret;

if (val > 3)
return -EINVAL;

ret = isl29003_set_resolution(client, val);
Expand Down Expand Up @@ -267,7 +275,11 @@ static ssize_t isl29003_store_mode(struct device *dev,
unsigned long val;
int ret;

if ((strict_strtoul(buf, 10, &val) < 0) || (val > 2))
ret = kstrtoul(buf, 10, &val);
if (ret)
return ret;

if (val > 2)
return -EINVAL;

ret = isl29003_set_mode(client, val);
Expand Down Expand Up @@ -298,7 +310,11 @@ static ssize_t isl29003_store_power_state(struct device *dev,
unsigned long val;
int ret;

if ((strict_strtoul(buf, 10, &val) < 0) || (val > 1))
ret = kstrtoul(buf, 10, &val);
if (ret)
return ret;

if (val > 1)
return -EINVAL;

ret = isl29003_set_power_state(client, val);
Expand Down
6 changes: 4 additions & 2 deletions drivers/misc/isl29020.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions drivers/misc/lis3lv02d/lis3lv02d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Loading

0 comments on commit f7b4127

Please sign in to comment.