Skip to contentSkip to conversation

Input: convert obsolete strict_strtox to kstrtox

PATCH Applied JJ Ding 3 participants 7 messages Nov 7, 2011 – Nov 8, 2011

Subsystems (6)

v2 of 3 Applied Latest is v3 →

lore
Share & tools
lore

JJ Ding

author
#0 lore raw

PATCH v2 1/1 Input: convert obsolete strict_strtox to kstrtox

From: JJ Ding <[email protected]>

With commit 67d0a0754455f89ef3946946159d8ec9e45ce33a we mark strict_strtox as obsolete. Convert all remaining such uses in drivers/input/.

Also change the data type from long to int as Dmitry sugguests, we now have kstrtouint which suits these uses better.

---
 drivers/input/input-polldev.c       |    4 ++--
 drivers/input/keyboard/atkbd.c      |   20 ++++++++++----------
 drivers/input/keyboard/lm8323.c     |    9 ++++-----
 drivers/input/misc/adxl34x.c        |   16 ++++++++--------
 drivers/input/misc/ati_remote2.c    |   12 ++++++------
 drivers/input/mouse/elantech.c      |    4 ++--
 drivers/input/mouse/hgpk.c          |    8 ++++----
 drivers/input/mouse/logips2pp.c     |    4 ++--
 drivers/input/mouse/psmouse-base.c  |   15 ++++++---------
 drivers/input/mouse/sentelic.c      |   21 ++++++++++-----------
 drivers/input/mouse/trackpoint.c    |    8 ++++----
 drivers/input/tablet/aiptek.c       |   26 +++++++++++++-------------
 drivers/input/touchscreen/ad7877.c  |   16 ++++++++--------
 drivers/input/touchscreen/ad7879.c  |    4 ++--
 drivers/input/touchscreen/ads7846.c |    4 ++--
 15 files changed, 83 insertions(+), 88 deletions(-)
drivers/input/input-polldev.c +2 -2
index b253973..0ccf2b6 100644
@@ -83,9 +83,9 @@ static ssize_t input_polldev_set_poll(struct device *dev,
 {
 	struct input_polled_dev *polldev = dev_get_drvdata(dev);
 	struct input_dev *input = polldev->input;
-	unsigned long interval;
+	unsigned int interval;
 
-	if (strict_strtoul(buf, 0, &interval))
+	if (kstrtouint(buf, 0, &interval))
 		return -EINVAL;
 
 	if (interval < polldev->poll_interval_min)
drivers/input/keyboard/atkbd.c +10 -10
index 19cfc0c..1e98ebf 100644
@@ -1305,7 +1305,7 @@ static ssize_t atkbd_show_extra(struct atkbd *atkbd, char *buf)
 static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t count)
 {
 	struct input_dev *old_dev, *new_dev;
-	unsigned long value;
+	unsigned int value;
 	int err;
 	bool old_extra;
 	unsigned char old_set;
@@ -1313,7 +1313,7 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun
 	if (!atkbd->write)
 		return -EIO;
 
-	if (strict_strtoul(buf, 10, &value) || value > 1)
+	if (kstrtouint(buf, 10, &value) || value > 1)
 		return -EINVAL;
 
 	if (atkbd->extra != value) {
@@ -1389,11 +1389,11 @@ static ssize_t atkbd_show_scroll(struct atkbd *atkbd, char *buf)
 static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t count)
 {
 	struct input_dev *old_dev, *new_dev;
-	unsigned long value;
+	unsigned int value;
 	int err;
 	bool old_scroll;
 
-	if (strict_strtoul(buf, 10, &value) || value > 1)
+	if (kstrtouint(buf, 10, &value) || value > 1)
 		return -EINVAL;
 
 	if (atkbd->scroll != value) {
@@ -1433,7 +1433,7 @@ static ssize_t atkbd_show_set(struct atkbd *atkbd, char *buf)
 static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
 {
 	struct input_dev *old_dev, *new_dev;
-	unsigned long value;
+	unsigned int value;
 	int err;
 	unsigned char old_set;
 	bool old_extra;
@@ -1441,7 +1441,7 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count)
 	if (!atkbd->write)
 		return -EIO;
 
-	if (strict_strtoul(buf, 10, &value) || (value != 2 && value != 3))
+	if (kstrtouint(buf, 10, &value) || (value != 2 && value != 3))
 		return -EINVAL;
 
 	if (atkbd->set != value) {
@@ -1484,14 +1484,14 @@ static ssize_t atkbd_show_softrepeat(struct atkbd *atkbd, char *buf)
 static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t count)
 {
 	struct input_dev *old_dev, *new_dev;
-	unsigned long value;
+	unsigned int value;
 	int err;
 	bool old_softrepeat, old_softraw;
 
 	if (!atkbd->write)
 		return -EIO;
 
-	if (strict_strtoul(buf, 10, &value) || value > 1)
+	if (kstrtouint(buf, 10, &value) || value > 1)
 		return -EINVAL;
 
 	if (atkbd->softrepeat != value) {
@@ -1534,11 +1534,11 @@ static ssize_t atkbd_show_softraw(struct atkbd *atkbd, char *buf)
 static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t count)
 {
 	struct input_dev *old_dev, *new_dev;
-	unsigned long value;
+	unsigned int value;
 	int err;
 	bool old_softraw;
 
-	if (strict_strtoul(buf, 10, &value) || value > 1)
+	if (kstrtouint(buf, 10, &value) || value > 1)
 		return -EINVAL;
 
 	if (atkbd->softraw != value) {
drivers/input/keyboard/lm8323.c +4 -5
index 82d1dc8..54eeab2 100644
@@ -545,10 +545,9 @@ static ssize_t lm8323_pwm_store_time(struct device *dev,
 {
 	struct led_classdev *led_cdev = dev_get_drvdata(dev);
 	struct lm8323_pwm *pwm = cdev_to_pwm(led_cdev);
-	int ret;
-	unsigned long time;
+	int ret, time;
 
-	ret = strict_strtoul(buf, 10, &time);
+	ret = kstrtoint(buf, 10, &time);
 	/* Numbers only, please. */
 	if (ret)
 		return -EINVAL;
@@ -613,9 +612,9 @@ static ssize_t lm8323_set_disable(struct device *dev,
 {
 	struct lm8323_chip *lm = dev_get_drvdata(dev);
 	int ret;
-	unsigned long i;
+	unsigned int i;
 
-	ret = strict_strtoul(buf, 10, &i);
+	ret = kstrtouint(buf, 10, &i);
 
 	mutex_lock(&lm->lock);
 	lm->kp_enabled = !i;
drivers/input/misc/adxl34x.c +8 -8
index 144ddbd..af35885 100644
@@ -451,10 +451,10 @@ static ssize_t adxl34x_disable_store(struct device *dev,
 				     const char *buf, size_t count)
 {
 	struct adxl34x *ac = dev_get_drvdata(dev);
-	unsigned long val;
+	unsigned int val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
+	error = kstrtouint(buf, 10, &val);
 	if (error)
 		return error;
 
@@ -540,10 +540,10 @@ static ssize_t adxl34x_rate_store(struct device *dev,
 				  const char *buf, size_t count)
 {
 	struct adxl34x *ac = dev_get_drvdata(dev);
-	unsigned long val;
+	unsigned int val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
+	error = kstrtouint(buf, 10, &val);
 	if (error)
 		return error;
 
@@ -575,10 +575,10 @@ static ssize_t adxl34x_autosleep_store(struct device *dev,
 				  const char *buf, size_t count)
 {
 	struct adxl34x *ac = dev_get_drvdata(dev);
-	unsigned long val;
+	unsigned int val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
+	error = kstrtouint(buf, 10, &val);
 	if (error)
 		return error;
 
@@ -622,13 +622,13 @@ static ssize_t adxl34x_write_store(struct device *dev,
 				   const char *buf, size_t count)
 {
 	struct adxl34x *ac = dev_get_drvdata(dev);
-	unsigned long val;
+	unsigned int val;
 	int error;
 
 	/*
 	 * This allows basic ADXL register write access for debug purposes.
 	 */
-	error = strict_strtoul(buf, 16, &val);
+	error = kstrtouint(buf, 16, &val);
 	if (error)
 		return error;
 
drivers/input/misc/ati_remote2.c +6 -6
index 1de58e8..efc7eba 100644
@@ -41,13 +41,13 @@ static int ati_remote2_set_mask(const char *val,
 				const struct kernel_param *kp,
 				unsigned int max)
 {
-	unsigned long mask;
+	unsigned int mask;
 	int ret;
 
 	if (!val)
 		return -EINVAL;
 
-	ret = strict_strtoul(val, 0, &mask);
+	ret = kstrtouint(val, 0, &mask);
 	if (ret)
 		return ret;
 
@@ -719,10 +719,10 @@ static ssize_t ati_remote2_store_channel_mask(struct device *dev,
 	struct usb_device *udev = to_usb_device(dev);
 	struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
 	struct ati_remote2 *ar2 = usb_get_intfdata(intf);
-	unsigned long mask;
+	unsigned int mask;
 	int r;
 
-	if (strict_strtoul(buf, 0, &mask))
+	if (kstrtouint(buf, 0, &mask))
 		return -EINVAL;
 
 	if (mask & ~ATI_REMOTE2_MAX_CHANNEL_MASK)
@@ -768,9 +768,9 @@ static ssize_t ati_remote2_store_mode_mask(struct device *dev,
 	struct usb_device *udev = to_usb_device(dev);
 	struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
 	struct ati_remote2 *ar2 = usb_get_intfdata(intf);
-	unsigned long mask;
+	unsigned int mask;
 
-	if (strict_strtoul(buf, 0, &mask))
+	if (kstrtouint(buf, 0, &mask))
 		return -EINVAL;
 
 	if (mask & ~ATI_REMOTE2_MAX_MODE_MASK)
drivers/input/mouse/elantech.c +2 -2
index 09b93b1..4bb3b7e 100644
@@ -1031,10 +1031,10 @@ static ssize_t elantech_set_int_attr(struct psmouse *psmouse,
 	struct elantech_data *etd = psmouse->private;
 	struct elantech_attr_data *attr = data;
 	unsigned char *reg = (unsigned char *) etd + attr->field_offset;
-	unsigned long value;
+	unsigned int value;
 	int err;
 
-	err = strict_strtoul(buf, 16, &value);
+	err = kstrtouint(buf, 16, &value);
 	if (err)
 		return err;
 
drivers/input/mouse/hgpk.c +4 -4
index 0470dd4..a25f11c 100644
@@ -789,10 +789,10 @@ static ssize_t hgpk_set_powered(struct psmouse *psmouse, void *data,
 				const char *buf, size_t count)
 {
 	struct hgpk_data *priv = psmouse->private;
-	unsigned long value;
+	unsigned int value;
 	int err;
 
-	err = strict_strtoul(buf, 10, &value);
+	err = kstrtouint(buf, 10, &value);
 	if (err || value > 1)
 		return -EINVAL;
 
@@ -881,10 +881,10 @@ static ssize_t hgpk_trigger_recal(struct psmouse *psmouse, void *data,
 				const char *buf, size_t count)
 {
 	struct hgpk_data *priv = psmouse->private;
-	unsigned long value;
+	unsigned int value;
 	int err;
 
-	err = strict_strtoul(buf, 10, &value);
+	err = kstrtouint(buf, 10, &value);
 	if (err || value != 1)
 		return -EINVAL;
 
drivers/input/mouse/logips2pp.c +2 -2
index faac2c3..ac04553 100644
@@ -155,9 +155,9 @@ static ssize_t ps2pp_attr_show_smartscroll(struct psmouse *psmouse,
 static ssize_t ps2pp_attr_set_smartscroll(struct psmouse *psmouse, void *data,
 					  const char *buf, size_t count)
 {
-	unsigned long value;
+	unsigned int value;
 
-	if (strict_strtoul(buf, 10, &value) || value > 1)
+	if (kstrtouint(buf, 10, &value) || value > 1)
 		return -EINVAL;
 
 	ps2pp_set_smartscroll(psmouse, value);
drivers/input/mouse/psmouse-base.c +6 -9
index 9f352fb..c7ecb06 100644
@@ -1558,12 +1558,9 @@ static ssize_t psmouse_show_int_attr(struct psmouse *psmouse, void *offset, char
 static ssize_t psmouse_set_int_attr(struct psmouse *psmouse, void *offset, const char *buf, size_t count)
 {
 	unsigned int *field = (unsigned int *)((char *)psmouse + (size_t)offset);
-	unsigned long value;
+	unsigned int value;
 
-	if (strict_strtoul(buf, 10, &value))
-		return -EINVAL;
-
-	if ((unsigned int)value != value)
+	if (kstrtouint(buf, 10, &value))
 		return -EINVAL;
 
 	*field = value;
@@ -1671,9 +1668,9 @@ static ssize_t psmouse_attr_set_protocol(struct psmouse *psmouse, void *data, co
 
 static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const char *buf, size_t count)
 {
-	unsigned long value;
+	unsigned int value;
 
-	if (strict_strtoul(buf, 10, &value))
+	if (kstrtouint(buf, 10, &value))
 		return -EINVAL;
 
 	psmouse->set_rate(psmouse, value);
@@ -1682,9 +1679,9 @@ static ssize_t psmouse_attr_set_rate(struct psmouse *psmouse, void *data, const
 
 static ssize_t psmouse_attr_set_resolution(struct psmouse *psmouse, void *data, const char *buf, size_t count)
 {
-	unsigned long value;
+	unsigned int value;
 
-	if (strict_strtoul(buf, 10, &value))
+	if (kstrtouint(buf, 10, &value))
 		return -EINVAL;
 
 	psmouse->set_resolution(psmouse, value);
drivers/input/mouse/sentelic.c +10 -11
index c5b12d2..9d4818c 100644
@@ -408,7 +408,7 @@ static int fsp_onpad_hscr(struct psmouse *psmouse, bool enable)
 static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data,
 				   const char *buf, size_t count)
 {
-	unsigned long reg, val;
+	int reg, val;
 	char *rest;
 	ssize_t retval;
 
@@ -416,7 +416,7 @@ static ssize_t fsp_attr_set_setreg(struct psmouse *psmouse, void *data,
 	if (rest == buf || *rest != ' ' || reg > 0xff)
 		return -EINVAL;
 
-	if (strict_strtoul(rest + 1, 16, &val) || val > 0xff)
+	if (kstrtoint(rest + 1, 16, &val) || val > 0xff)
 		return -EINVAL;
 
 	if (fsp_reg_write_enable(psmouse, true))
@@ -448,10 +448,9 @@ static ssize_t fsp_attr_set_getreg(struct psmouse *psmouse, void *data,
 					const char *buf, size_t count)
 {
 	struct fsp_data *pad = psmouse->private;
-	unsigned long reg;
-	int val;
+	int reg, val;
 
-	if (strict_strtoul(buf, 16, &reg) || reg > 0xff)
+	if (kstrtoint(buf, 16, &reg) || reg > 0xff)
 		return -EINVAL;
 
 	if (fsp_reg_read(psmouse, reg, &val))
@@ -480,9 +479,9 @@ static ssize_t fsp_attr_show_pagereg(struct psmouse *psmouse,
 static ssize_t fsp_attr_set_pagereg(struct psmouse *psmouse, void *data,
 					const char *buf, size_t count)
 {
-	unsigned long val;
+	int val;
 
-	if (strict_strtoul(buf, 16, &val) || val > 0xff)
+	if (kstrtoint(buf, 16, &val) || val > 0xff)
 		return -EINVAL;
 
 	if (fsp_page_reg_write(psmouse, val))
@@ -505,9 +504,9 @@ static ssize_t fsp_attr_show_vscroll(struct psmouse *psmouse,
 static ssize_t fsp_attr_set_vscroll(struct psmouse *psmouse, void *data,
 					const char *buf, size_t count)
 {
-	unsigned long val;
+	unsigned int val;
 
-	if (strict_strtoul(buf, 10, &val) || val > 1)
+	if (kstrtouint(buf, 10, &val) || val > 1)
 		return -EINVAL;
 
 	fsp_onpad_vscr(psmouse, val);
@@ -529,9 +528,9 @@ static ssize_t fsp_attr_show_hscroll(struct psmouse *psmouse,
 static ssize_t fsp_attr_set_hscroll(struct psmouse *psmouse, void *data,
 					const char *buf, size_t count)
 {
-	unsigned long val;
+	unsigned int val;
 
-	if (strict_strtoul(buf, 10, &val) || val > 1)
+	if (kstrtouint(buf, 10, &val) || val > 1)
 		return -EINVAL;
 
 	fsp_onpad_hscr(psmouse, val);
drivers/input/mouse/trackpoint.c +4 -4
index 54b2fa8..ac9e520 100644
@@ -89,9 +89,9 @@ static ssize_t trackpoint_set_int_attr(struct psmouse *psmouse, void *data,
 	struct trackpoint_data *tp = psmouse->private;
 	struct trackpoint_attr_data *attr = data;
 	unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
-	unsigned long value;
+	unsigned int value;
 
-	if (strict_strtoul(buf, 10, &value) || value > 255)
+	if (kstrtouint(buf, 10, &value) || value > 255)
 		return -EINVAL;
 
 	*field = value;
@@ -115,9 +115,9 @@ static ssize_t trackpoint_set_bit_attr(struct psmouse *psmouse, void *data,
 	struct trackpoint_data *tp = psmouse->private;
 	struct trackpoint_attr_data *attr = data;
 	unsigned char *field = (unsigned char *)((char *)tp + attr->field_offset);
-	unsigned long value;
+	unsigned int value;
 
-	if (strict_strtoul(buf, 10, &value) || value > 1)
+	if (kstrtouint(buf, 10, &value) || value > 1)
 		return -EINVAL;
 
 	if (attr->inverted)
drivers/input/tablet/aiptek.c +13 -13
index 6d89fd1..79fec1b 100644
@@ -1198,9 +1198,9 @@ static ssize_t
 store_tabletXtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct aiptek *aiptek = dev_get_drvdata(dev);
-	long x;
+	int x;
 
-	if (strict_strtol(buf, 10, &x)) {
+	if (kstrtoint(buf, 10, &x)) {
 		size_t len = buf[count - 1] == '\n' ? count - 1 : count;
 
 		if (strncmp(buf, "disable", len))
@@ -1240,9 +1240,9 @@ static ssize_t
 store_tabletYtilt(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct aiptek *aiptek = dev_get_drvdata(dev);
-	long y;
+	int y;
 
-	if (strict_strtol(buf, 10, &y)) {
+	if (kstrtoint(buf, 10, &y)) {
 		size_t len = buf[count - 1] == '\n' ? count - 1 : count;
 
 		if (strncmp(buf, "disable", len))
@@ -1277,12 +1277,12 @@ static ssize_t
 store_tabletJitterDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct aiptek *aiptek = dev_get_drvdata(dev);
-	long j;
+	int j;
 
-	if (strict_strtol(buf, 10, &j))
+	if (kstrtoint(buf, 10, &j))
 		return -EINVAL;
 
-	aiptek->newSetting.jitterDelay = (int)j;
+	aiptek->newSetting.jitterDelay = j;
 	return count;
 }
 
@@ -1306,12 +1306,12 @@ static ssize_t
 store_tabletProgrammableDelay(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct aiptek *aiptek = dev_get_drvdata(dev);
-	long d;
+	int d;
 
-	if (strict_strtol(buf, 10, &d))
+	if (kstrtoint(buf, 10, &d))
 		return -EINVAL;
 
-	aiptek->newSetting.programmableDelay = (int)d;
+	aiptek->newSetting.programmableDelay = d;
 	return count;
 }
 
@@ -1557,11 +1557,11 @@ static ssize_t
 store_tabletWheel(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)
 {
 	struct aiptek *aiptek = dev_get_drvdata(dev);
-	long w;
+	int w;
 
-	if (strict_strtol(buf, 10, &w)) return -EINVAL;
+	if (kstrtoint(buf, 10, &w)) return -EINVAL;
 
-	aiptek->newSetting.wheel = (int)w;
+	aiptek->newSetting.wheel = w;
 	return count;
 }
 
drivers/input/touchscreen/ad7877.c +8 -8
index 714d4e0..374370e 100644
@@ -487,10 +487,10 @@ static ssize_t ad7877_disable_store(struct device *dev,
 				     const char *buf, size_t count)
 {
 	struct ad7877 *ts = dev_get_drvdata(dev);
-	unsigned long val;
+	unsigned int val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
+	error = kstrtouint(buf, 10, &val);
 	if (error)
 		return error;
 
@@ -517,10 +517,10 @@ static ssize_t ad7877_dac_store(struct device *dev,
 				     const char *buf, size_t count)
 {
 	struct ad7877 *ts = dev_get_drvdata(dev);
-	unsigned long val;
+	unsigned int val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
+	error = kstrtouint(buf, 10, &val);
 	if (error)
 		return error;
 
@@ -547,10 +547,10 @@ static ssize_t ad7877_gpio3_store(struct device *dev,
 				     const char *buf, size_t count)
 {
 	struct ad7877 *ts = dev_get_drvdata(dev);
-	unsigned long val;
+	unsigned int val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
+	error = kstrtouint(buf, 10, &val);
 	if (error)
 		return error;
 
@@ -578,10 +578,10 @@ static ssize_t ad7877_gpio4_store(struct device *dev,
 				     const char *buf, size_t count)
 {
 	struct ad7877 *ts = dev_get_drvdata(dev);
-	unsigned long val;
+	unsigned int val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
+	error = kstrtouint(buf, 10, &val);
 	if (error)
 		return error;
 
drivers/input/touchscreen/ad7879.c +2 -2
index 131f9d1..76f5cb4 100644
@@ -339,10 +339,10 @@ static ssize_t ad7879_disable_store(struct device *dev,
 				     const char *buf, size_t count)
 {
 	struct ad7879 *ts = dev_get_drvdata(dev);
-	unsigned long val;
+	unsigned int val;
 	int error;
 
-	error = strict_strtoul(buf, 10, &val);
+	error = kstrtouint(buf, 10, &val);
 	if (error)
 		return error;
 
drivers/input/touchscreen/ads7846.c +2 -2
index d507b9b..b72e99c 100644
@@ -601,9 +601,9 @@ static ssize_t ads7846_disable_store(struct device *dev,
 				     const char *buf, size_t count)
 {
 	struct ads7846 *ts = dev_get_drvdata(dev);
-	unsigned long i;
+	unsigned int i;
 
-	if (strict_strtoul(buf, 10, &i))
+	if (kstrtouint(buf, 10, &i))
 		return -EINVAL;
 
 	if (i)
Signature · 1 line
1.7.8.rc0.32.g87bf9
maintainer Applied
#1 lore raw
Quoted 8 lines · JJ Ding

From: JJ Ding <[email protected]>

With commit 67d0a0754455f89ef3946946159d8ec9e45ce33a we mark strict_strtox as obsolete. Convert all remaining such uses in drivers/input/.

Also change the data type from long to int as Dmitry sugguests, we now have kstrtouint which suits these uses better.

Applied, thanks JJ.

Signature · 1 line
Dmitry
maintainer
#2 lore raw
Quoted 12 lines · Dmitry Torokhov
Quoted 8 lines · JJ Ding

From: JJ Ding <[email protected]>

With commit 67d0a0754455f89ef3946946159d8ec9e45ce33a we mark strict_strtox as obsolete. Convert all remaining such uses in drivers/input/.

Also change the data type from long to int as Dmitry sugguests, we now have kstrtouint which suits these uses better.

Applied, thanks JJ.

Sorry, I take it back...

drivers/input/keyboard/atkbd.c static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun · line 1317

Quoted 3 lines
drivers/input/keyboard/atkbd.c +1 -1
-       if (strict_strtoul(buf, 10, &value) || value > 1)
+       if (kstrtouint(buf, 10, &value) || value > 1)
                return -EINVAL;

This mangles error condition from kstrtouint and reporting conditions beside -EINVAL was the reason for introducing new API IIRC. The proper conversion should be:

	err = kstrtouint(buf, 10, &value);
	if (err)
		return err;

	if (value > 1)
		return -EINVAL;

Thanks.

Signature · 1 line
Dmitry
author
#3 lore raw
Quoted 24 lines · Dmitry Torokhov
Quoted 12 lines · Dmitry Torokhov
Quoted 8 lines · JJ Ding

From: JJ Ding <[email protected]>

With commit 67d0a0754455f89ef3946946159d8ec9e45ce33a we mark strict_strtox as obsolete. Convert all remaining such uses in drivers/input/.

Also change the data type from long to int as Dmitry sugguests, we now have kstrtouint which suits these uses better.

Applied, thanks JJ.

Sorry, I take it back...

drivers/input/keyboard/atkbd.c static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun · line 1317

Quoted 3 lines
drivers/input/keyboard/atkbd.c +1 -1
-       if (strict_strtoul(buf, 10, &value) || value > 1)
+       if (kstrtouint(buf, 10, &value) || value > 1)
                return -EINVAL;

This mangles error condition from kstrtouint and reporting conditions beside -EINVAL was the reason for introducing new API IIRC. The proper conversion should be:

Quoted 9 lines
	err = kstrtouint(buf, 10, &value);
	if (err)
		return err;

	if (value > 1)
		return -EINVAL;

Thanks.

Thanks, I get it. I'll fix and resend.

jj

Quoted 2 lines
Signature · 1 line
Dmitry
author
#4 lore raw
Quoted 23 lines · JJ Ding
Quoted 22 lines · Dmitry Torokhov
Quoted 3 lines · Dmitry Torokhov

Applied, thanks JJ.

Sorry, I take it back...

drivers/input/keyboard/atkbd.c static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun · line 1317

Quoted 3 lines
drivers/input/keyboard/atkbd.c +1 -1
-       if (strict_strtoul(buf, 10, &value) || value > 1)
+       if (kstrtouint(buf, 10, &value) || value > 1)
                return -EINVAL;

This mangles error condition from kstrtouint and reporting conditions beside -EINVAL was the reason for introducing new API IIRC. The proper conversion should be:

	err = kstrtouint(buf, 10, &value);
	if (err)
		return err;

	if (value > 1)
		return -EINVAL;
Quoted 7 lines
Quoted 2 lines

Thanks.

Thanks, I get it. I'll fix and resend.

jj

Thinking a bit more about your suggestion, and looking at the code more closely, some uses of these conversions really want a u8, and some want a bool. I think I should check the data type where these converted values are really used, and use a more appropriate kstrtox.

And for those that just need a bool, do you think using strtobool introduced in commit d0f1fed29e6e73d9d17f4c91a5896a4ce3938d45 OK? That way the user may even type [NnYy01].

What do you think about the approach above?

Thanks,
jj

Quoted 2 lines
Quoted 2 lines
Signature · 1 line
Dmitry
maintainer
#5 lore raw
Quoted 29 lines · JJ Ding
Quoted 28 lines · JJ Ding
Quoted 15 lines · Dmitry Torokhov
Quoted 3 lines · Dmitry Torokhov

Applied, thanks JJ.

Sorry, I take it back...

Quoted 3 lines

-       if (strict_strtoul(buf, 10, &value) || value > 1)
+       if (kstrtouint(buf, 10, &value) || value > 1) return -EINVAL;

This mangles error condition from kstrtouint and reporting conditions beside -EINVAL was the reason for introducing new API IIRC. The proper conversion should be:

Quoted 9 lines

    err = kstrtouint(buf, 10, &value);
    if (err)
            return err;

    if (value > 1)
            return -EINVAL;

Thanks.

Thanks, I get it. I'll fix and resend.

Quoted 7 lines
Quoted 2 lines

jj

Thinking a bit more about your suggestion, and looking at the code more closely, some uses of these conversions really want a u8, and some want a bool. I think I should check the data type where these converted values are really used, and use a more appropriate kstrtox.

If some really want full u8 range then yes, I agree, kstrtou8 is best. For ones where we have just a few valid values I think we should stick with conversing to unsigned int and then validate the range manually.

Quoted 4 lines

And for those that just need a bool, do you think using strtobool introduced in commit d0f1fed29e6e73d9d17f4c91a5896a4ce3938d45 OK? That way the user may even type [NnYy01].

I do not like strtobool because it is sloppy. It will also accept 10, yoda, nada and similar inputs as correct.

Thanks.

Signature · 5 lines
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw
Quoted 43 lines · Dmitry Torokhov
Quoted 29 lines · JJ Ding
Quoted 28 lines · JJ Ding
Quoted 15 lines · Dmitry Torokhov
Quoted 3 lines · Dmitry Torokhov

Applied, thanks JJ.

Sorry, I take it back...

drivers/input/keyboard/atkbd.c static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun · line 1317

Quoted 3 lines
drivers/input/keyboard/atkbd.c +1 -1
-       if (strict_strtoul(buf, 10, &value) || value > 1)
+       if (kstrtouint(buf, 10, &value) || value > 1)
                return -EINVAL;

This mangles error condition from kstrtouint and reporting conditions beside -EINVAL was the reason for introducing new API IIRC. The proper conversion should be:

Quoted 9 lines
    err = kstrtouint(buf, 10, &value);
    if (err)
            return err;

    if (value > 1)
            return -EINVAL;

Thanks.

Thanks, I get it. I'll fix and resend.

Quoted 7 lines
Quoted 2 lines

jj

Thinking a bit more about your suggestion, and looking at the code more closely, some uses of these conversions really want a u8, and some want a bool. I think I should check the data type where these converted values are really used, and use a more appropriate kstrtox.

If some really want full u8 range then yes, I agree, kstrtou8 is best. For ones where we have just a few valid values I think we should stick with conversing to unsigned int and then validate the range manually.

Quoted 1 line
Quoted 7 lines
Quoted 3 lines

And for those that just need a bool, do you think using strtobool introduced in commit d0f1fed29e6e73d9d17f4c91a5896a4ce3938d45 OK? That way the user may even type [NnYy01].

I do not like strtobool because it is sloppy. It will also accept 10, yoda, nada and similar inputs as correct.

plenty of room for kstrtobool if anyone wants to take it on...