Skip to contentSkip to conversation

misc: replace strict_strtoul() with kstrtoul()

PATCH In review Jingoo Han 2 participants 2 messages Jun 1, 2013 – Jun 2, 2013

Subsystems (3)
lore
Share & tools
lore

Jingoo Han

author
#0 lore raw

PATCH 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.

---
 drivers/misc/ad525x_dpot.c              |    2 +-
 drivers/misc/apds9802als.c              |    2 +-
 drivers/misc/apds990x.c                 |   12 ++++++------
 drivers/misc/bh1770glc.c                |   20 ++++++++++----------
 drivers/misc/bh1780gli.c                |    2 +-
 drivers/misc/carma/carma-fpga-program.c |    4 ++--
 drivers/misc/carma/carma-fpga.c         |    2 +-
 drivers/misc/hmc6352.c                  |    2 +-
 drivers/misc/isl29003.c                 |    8 ++++----
 drivers/misc/isl29020.c                 |    2 +-
 drivers/misc/lis3lv02d/lis3lv02d.c      |    2 +-
 drivers/misc/sgi-gru/gruprocfs.c        |    2 +-
 drivers/misc/spear13xx_pcie_gadget.c    |   18 +++++++++---------
 drivers/misc/ti_dac7512.c               |    2 +-
 14 files changed, 40 insertions(+), 40 deletions(-)
drivers/misc/ad525x_dpot.c +1 -1
index 8f99e8e..0daadcf 100644
@@ -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 +1 -1
index 5b5fd84..4be1c79 100644
@@ -126,7 +126,7 @@ static ssize_t als_sensing_range_store(struct device *dev,
 	int ret_val;
 	unsigned long val;
 
-	if (strict_strtoul(buf, 10, &val))
+	if (kstrtoul(buf, 10, &val))
 		return -EINVAL;
 
 	if (val < 4096)
drivers/misc/apds990x.c +6 -6
index 98f9bb2..3684331 100644
@@ -697,7 +697,7 @@ static ssize_t apds990x_lux_calib_store(struct device *dev,
 	struct apds990x_chip *chip = dev_get_drvdata(dev);
 	unsigned long value;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
 	chip->lux_calib = value;
@@ -759,7 +759,7 @@ static ssize_t apds990x_rate_store(struct device *dev,
 	unsigned long value;
 	int ret;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
 	mutex_lock(&chip->mutex);
@@ -814,7 +814,7 @@ static ssize_t apds990x_prox_enable_store(struct device *dev,
 	struct apds990x_chip *chip =  dev_get_drvdata(dev);
 	unsigned long value;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
 	mutex_lock(&chip->mutex);
@@ -895,7 +895,7 @@ static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target,
 	int ret = 0;
 	unsigned long thresh;
 
-	if (strict_strtoul(buf, 0, &thresh))
+	if (kstrtoul(buf, 0, &thresh))
 		return -EINVAL;
 
 	if (thresh > APDS_RANGE)
@@ -958,7 +958,7 @@ static ssize_t apds990x_prox_threshold_store(struct device *dev,
 	struct apds990x_chip *chip =  dev_get_drvdata(dev);
 	unsigned long value;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
 	if ((value > APDS_RANGE) || (value == 0) ||
@@ -991,7 +991,7 @@ static ssize_t apds990x_power_state_store(struct device *dev,
 	struct apds990x_chip *chip =  dev_get_drvdata(dev);
 	unsigned long value;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 	if (value) {
 		pm_runtime_get_sync(dev);
drivers/misc/bh1770glc.c +10 -10
index f4975f7..fddd4d6 100644
@@ -651,7 +651,7 @@ static ssize_t bh1770_power_state_store(struct device *dev,
 	unsigned long value;
 	ssize_t ret;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
 	mutex_lock(&chip->mutex);
@@ -727,7 +727,7 @@ static ssize_t bh1770_prox_enable_store(struct device *dev,
 	struct bh1770_chip *chip =  dev_get_drvdata(dev);
 	unsigned long value;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
 	mutex_lock(&chip->mutex);
@@ -825,7 +825,7 @@ static ssize_t bh1770_set_prox_rate_above(struct device *dev,
 	struct bh1770_chip *chip =  dev_get_drvdata(dev);
 	unsigned long value;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
 	mutex_lock(&chip->mutex);
@@ -841,7 +841,7 @@ static ssize_t bh1770_set_prox_rate_below(struct device *dev,
 	struct bh1770_chip *chip =  dev_get_drvdata(dev);
 	unsigned long value;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
 	mutex_lock(&chip->mutex);
@@ -865,7 +865,7 @@ static ssize_t bh1770_set_prox_thres(struct device *dev,
 	unsigned long value;
 	int ret;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 	if (value > BH1770_PROX_RANGE)
 		return -EINVAL;
@@ -894,7 +894,7 @@ static ssize_t bh1770_prox_persistence_store(struct device *dev,
 	struct bh1770_chip *chip = dev_get_drvdata(dev);
 	unsigned long value;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
 	if (value > BH1770_PROX_MAX_PERSISTENCE)
@@ -919,7 +919,7 @@ static ssize_t bh1770_prox_abs_thres_store(struct device *dev,
 	struct bh1770_chip *chip = dev_get_drvdata(dev);
 	unsigned long value;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
 	if (value > BH1770_PROX_RANGE)
@@ -964,7 +964,7 @@ static ssize_t bh1770_lux_calib_store(struct device *dev,
 	u32 old_calib;
 	u32 new_corr;
 
-	if (strict_strtoul(buf, 0, &value))
+	if (kstrtoul(buf, 0, &value))
 		return -EINVAL;
 
 	mutex_lock(&chip->mutex);
@@ -1012,7 +1012,7 @@ static ssize_t bh1770_set_lux_rate(struct device *dev,
 	unsigned long rate_hz;
 	int ret, i;
 
-	if (strict_strtoul(buf, 0, &rate_hz))
+	if (kstrtoul(buf, 0, &rate_hz))
 		return -EINVAL;
 
 	for (i = 0; i < ARRAY_SIZE(lux_rates_hz) - 1; i++)
@@ -1050,7 +1050,7 @@ static ssize_t bh1770_set_lux_thresh(struct bh1770_chip *chip, u16 *target,
 	int ret = 0;
 	unsigned long thresh;
 
-	if (strict_strtoul(buf, 0, &thresh))
+	if (kstrtoul(buf, 0, &thresh))
 		return -EINVAL;
 
 	if (thresh > BH1770_LUX_RANGE)
drivers/misc/bh1780gli.c +1 -1
index 818f3a0..057580e 100644
@@ -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 +2 -2
index fa017cf..421c044 100644
@@ -830,7 +830,7 @@ static ssize_t penable_store(struct device *dev, struct device_attribute *attr,
 	unsigned long val;
 	int ret;
 
-	if (strict_strtoul(buf, 0, &val))
+	if (kstrtoul(buf, 0, &val))
 		return -EINVAL;
 
 	if (val) {
@@ -859,7 +859,7 @@ static ssize_t program_store(struct device *dev, struct device_attribute *attr,
 	unsigned long val;
 	int ret;
 
-	if (strict_strtoul(buf, 0, &val))
+	if (kstrtoul(buf, 0, &val))
 		return -EINVAL;
 
 	/* We can't have an image writer and be programming simultaneously */
drivers/misc/carma/carma-fpga.c +1 -1
index a2128af..2c57566 100644
@@ -1002,7 +1002,7 @@ 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;
drivers/misc/hmc6352.c +1 -1
index 423cd40..95e28b7 100644
@@ -46,7 +46,7 @@ static int compass_store(struct device *dev, const char *buf, size_t count,
 	int ret;
 	unsigned long val;
 
-	if (strict_strtoul(buf, 10, &val))
+	if (kstrtoul(buf, 10, &val))
 		return -EINVAL;
 	if (val >= strlen(map))
 		return -EINVAL;
drivers/misc/isl29003.c +4 -4
index c5145b3..943133f 100644
@@ -208,7 +208,7 @@ static ssize_t isl29003_store_range(struct device *dev,
 	unsigned long val;
 	int ret;
 
-	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
+	if ((kstrtoul(buf, 10, &val) < 0) || (val > 3))
 		return -EINVAL;
 
 	ret = isl29003_set_range(client, val);
@@ -239,7 +239,7 @@ static ssize_t isl29003_store_resolution(struct device *dev,
 	unsigned long val;
 	int ret;
 
-	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 3))
+	if ((kstrtoul(buf, 10, &val) < 0) || (val > 3))
 		return -EINVAL;
 
 	ret = isl29003_set_resolution(client, val);
@@ -267,7 +267,7 @@ static ssize_t isl29003_store_mode(struct device *dev,
 	unsigned long val;
 	int ret;
 
-	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 2))
+	if ((kstrtoul(buf, 10, &val) < 0) || (val > 2))
 		return -EINVAL;
 
 	ret = isl29003_set_mode(client, val);
@@ -298,7 +298,7 @@ static ssize_t isl29003_store_power_state(struct device *dev,
 	unsigned long val;
 	int ret;
 
-	if ((strict_strtoul(buf, 10, &val) < 0) || (val > 1))
+	if ((kstrtoul(buf, 10, &val) < 0) || (val > 1))
 		return -EINVAL;
 
 	ret = isl29003_set_power_state(client, val);
drivers/misc/isl29020.c +1 -1
index 0aa08c7..e4fdc39 100644
@@ -90,7 +90,7 @@ static ssize_t als_sensing_range_store(struct device *dev,
 	int ret_val;
 	unsigned long val;
 
-	if (strict_strtoul(buf, 10, &val))
+	if (kstrtoul(buf, 10, &val))
 		return -EINVAL;
 	if (val < 1 || val > 64000)
 		return -EINVAL;
drivers/misc/lis3lv02d/lis3lv02d.c +1 -1
index 4cd4a3d..57ef5ea 100644
@@ -832,7 +832,7 @@ static ssize_t lis3lv02d_rate_set(struct device *dev,
 	struct lis3lv02d *lis3 = dev_get_drvdata(dev);
 	unsigned long rate;
 
-	if (strict_strtoul(buf, 0, &rate))
+	if (kstrtoul(buf, 0, &rate))
 		return -EINVAL;
 
 	lis3lv02d_sysfs_poweron(lis3);
drivers/misc/sgi-gru/gruprocfs.c +1 -1
index 797d796..87f1d57 100644
@@ -167,7 +167,7 @@ static ssize_t options_write(struct file *file, const char __user *userbuf,
 	if (copy_from_user(buf, userbuf, count))
 		return -EFAULT;
 	buf[count] = '\0';
-	if (strict_strtoul(buf, 0, &gru_options))
+	if (kstrtoul(buf, 0, &gru_options))
 		return -EINVAL;
 
 	return count;
drivers/misc/spear13xx_pcie_gadget.c +9 -9
index 84a8dab..c55dbb6 100644
@@ -316,7 +316,7 @@ static ssize_t pcie_gadget_store_no_of_msi(
 		struct spear_pcie_gadget_config *config,
 		const char *buf, size_t count)
 {
-	if (strict_strtoul(buf, 0, &config->requested_msi))
+	if (kstrtoul(buf, 0, &config->requested_msi))
 		return -EINVAL;
 	if (config->requested_msi > 32)
 		config->requested_msi = 32;
@@ -331,7 +331,7 @@ static ssize_t pcie_gadget_store_inta(
 	struct pcie_app_reg __iomem *app_reg = config->va_app_base;
 	ulong en;
 
-	if (strict_strtoul(buf, 0, &en))
+	if (kstrtoul(buf, 0, &en))
 		return -EINVAL;
 
 	if (en)
@@ -352,7 +352,7 @@ static ssize_t pcie_gadget_store_send_msi(
 	ulong vector;
 	u32 ven_msi;
 
-	if (strict_strtoul(buf, 0, &vector))
+	if (kstrtoul(buf, 0, &vector))
 		return -EINVAL;
 
 	if (!config->configured_msi)
@@ -396,7 +396,7 @@ static ssize_t pcie_gadget_store_vendor_id(
 {
 	ulong id;
 
-	if (strict_strtoul(buf, 0, &id))
+	if (kstrtoul(buf, 0, &id))
 		return -EINVAL;
 
 	spear_dbi_write_reg(config, PCI_VENDOR_ID, 2, id);
@@ -421,7 +421,7 @@ static ssize_t pcie_gadget_store_device_id(
 {
 	ulong id;
 
-	if (strict_strtoul(buf, 0, &id))
+	if (kstrtoul(buf, 0, &id))
 		return -EINVAL;
 
 	spear_dbi_write_reg(config, PCI_DEVICE_ID, 2, id);
@@ -444,7 +444,7 @@ static ssize_t pcie_gadget_store_bar0_size(
 	u32 pos, pos1;
 	u32 no_of_bit = 0;
 
-	if (strict_strtoul(buf, 0, &size))
+	if (kstrtoul(buf, 0, &size))
 		return -EINVAL;
 	/* min bar size is 256 */
 	if (size <= 0x100)
@@ -491,7 +491,7 @@ static ssize_t pcie_gadget_store_bar0_address(
 	struct pcie_app_reg __iomem *app_reg = config->va_app_base;
 	ulong address;
 
-	if (strict_strtoul(buf, 0, &address))
+	if (kstrtoul(buf, 0, &address))
 		return -EINVAL;
 
 	address &= ~(config->bar0_size - 1);
@@ -519,7 +519,7 @@ static ssize_t pcie_gadget_store_bar0_rw_offset(
 {
 	ulong offset;
 
-	if (strict_strtoul(buf, 0, &offset))
+	if (kstrtoul(buf, 0, &offset))
 		return -EINVAL;
 
 	if (offset % 4)
@@ -550,7 +550,7 @@ static ssize_t pcie_gadget_store_bar0_data(
 {
 	ulong data;
 
-	if (strict_strtoul(buf, 0, &data))
+	if (kstrtoul(buf, 0, &data))
 		return -EINVAL;
 
 	if (!config->va_bar0_address)
drivers/misc/ti_dac7512.c +1 -1
index 1d86407..09aa6fd 100644
@@ -34,7 +34,7 @@ static ssize_t dac7512_store_val(struct device *dev,
 	unsigned char tmp[2];
 	unsigned long val;
 
-	if (strict_strtoul(buf, 10, &val) < 0)
+	if (kstrtoul(buf, 10, &val) < 0)
 		return -EINVAL;
 
 	tmp[0] = val >> 8;
Signature · 1 line
1.7.10.4
#1 lore raw

drivers/misc/apds9802als.c static ssize_t als_sensing_range_store(struct device *dev, · line 130

Quoted 13 lines · Jingoo Han

The usage of strict_strtoul() is not preferred, because strict_strtoul() is obsolete. Thus, kstrtoul() should be used.

drivers/misc/apds9802als.c +1 -1
@@ -126,7 +126,7 @@ static ssize_t als_sensing_range_store(struct device *dev,
        int ret_val;
        unsigned long val;
 
-       if (strict_strtoul(buf, 10, &val))
+       if (kstrtoul(buf, 10, &val))
                return -EINVAL;

ret_val = kstrtoul();
if (ret_val)
return ret_val;

drivers/misc/apds990x.c static ssize_t apds990x_lux_calib_store(struct device *dev, · line 701

Quoted 9 lines
drivers/misc/apds990x.c +1 -1
@@ -697,7 +697,7 @@ static ssize_t apds990x_lux_calib_store(struct device *dev,
        struct apds990x_chip *chip = dev_get_drvdata(dev);
        unsigned long value;
 
-       if (strict_strtoul(buf, 0, &value))
+       if (kstrtoul(buf, 0, &value))
                return -EINVAL;

Ditto. Here and across entire patch.

drivers/misc/apds990x.c static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target, · line 895

Quoted 2 lines
drivers/misc/apds990x.c +0 -0
@@ -895,7 +895,7 @@ static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target,
        int ret = 0;

Remove this assignment...

drivers/misc/apds990x.c static ssize_t apds990x_set_lux_thresh(struct apds990x_chip *chip, u32 *target, · line 899

Quoted 5 lines
drivers/misc/apds990x.c +1 -1
        unsigned long thresh;
 
-       if (strict_strtoul(buf, 0, &thresh))
+       if (kstrtoul(buf, 0, &thresh))
                return -EINVAL;

...and use return code from kstrtoul().

drivers/misc/carma/carma-fpga.c static ssize_t data_en_set(struct device *dev, struct device_attribute *attr, · line 1008

Quoted 11 lines
drivers/misc/carma/carma-fpga.c +1 -1
@@ -1002,7 +1002,7 @@ 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;

--
With Best Regards,
Andy Shevchenko