Skip to contentSkip to conversation

usb: misc: usbsevseg: replace deprecated simple_strtoul with kstrtouint

PATCH In review Jad Keskes 2 participants 2 messages Jun 22 USB

lore
Share & tools
lore

Jad Keskes

author
#0 lore raw

PATCH 1/1 usb: misc: usbsevseg: replace deprecated simple_strtoul with kstrtouint

simple_strtoul() is deprecated. kstrtouint() actually tells you when the input is garbage instead of silently accepting zero.

Fixes 3 sysfs store paths (powered, mode_msb, mode_lsb) from one macro expansion.

---
 drivers/usb/misc/usbsevseg.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/misc/usbsevseg.c +7 -1
index 89d25fcef642..2c08d8ee7d86 100644
@@ -154,7 +154,13 @@ static ssize_t name##_store(struct device *dev,			\
 	struct usb_interface *intf = to_usb_interface(dev);	\
 	struct usb_sevsegdev *mydev = usb_get_intfdata(intf);	\
 								\
-	mydev->name = simple_strtoul(buf, NULL, 10);		\
+	unsigned int val;						\
+	int ret;							\
+								\
+	ret = kstrtouint(buf, 10, &val);			\
+	if (ret < 0)						\
+		return ret;						\
+	mydev->name = val;						\
 	update_fcn(mydev); 					\
 								\
 	return count;						\
Signature · 1 line
2.54.0
#1 lore raw
Quoted 2 lines · Jad Keskes

simple_strtoul() is deprecated. kstrtouint() actually tells you when the input is garbage instead of silently accepting zero.

That changes the API visible to user space. Is this a good idea?

Regards
Oliver