usb: misc: usbsevseg: replace deprecated simple_strtoul with kstrtouint
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.
Signed-off-by Jad Keskes <[email protected]>
--- drivers/usb/misc/usbsevseg.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/usb/misc/usbsevseg.c +7 -1
@@ -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
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