diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2017-06-11 10:15:16 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-06-13 04:54:40 -0400 |
commit | 0bd08fc8db593eb79bd40729279016fd5d7edc09 (patch) | |
tree | a6851c32200fdb748a506c206ca1442bbc8917f7 /drivers/usb/misc/usbsevseg.c | |
parent | d3be974a9c4eac83c1af15c966857d123a8436ba (diff) |
usb: misc: usbsevseg: Use sysfs_match_string() helper
Use sysfs_match_string() helper instead of open coded variant.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/misc/usbsevseg.c')
-rw-r--r-- | drivers/usb/misc/usbsevseg.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/drivers/usb/misc/usbsevseg.c b/drivers/usb/misc/usbsevseg.c index a0ba5298160c..388fae6373db 100644 --- a/drivers/usb/misc/usbsevseg.c +++ b/drivers/usb/misc/usbsevseg.c | |||
@@ -33,7 +33,7 @@ static const struct usb_device_id id_table[] = { | |||
33 | MODULE_DEVICE_TABLE(usb, id_table); | 33 | MODULE_DEVICE_TABLE(usb, id_table); |
34 | 34 | ||
35 | /* the different text display modes the device is capable of */ | 35 | /* the different text display modes the device is capable of */ |
36 | static char *display_textmodes[] = {"raw", "hex", "ascii", NULL}; | 36 | static const char *display_textmodes[] = {"raw", "hex", "ascii"}; |
37 | 37 | ||
38 | struct usb_sevsegdev { | 38 | struct usb_sevsegdev { |
39 | struct usb_device *udev; | 39 | struct usb_device *udev; |
@@ -280,7 +280,7 @@ static ssize_t show_attr_textmode(struct device *dev, | |||
280 | 280 | ||
281 | buf[0] = 0; | 281 | buf[0] = 0; |
282 | 282 | ||
283 | for (i = 0; display_textmodes[i]; i++) { | 283 | for (i = 0; i < ARRAY_SIZE(display_textmodes); i++) { |
284 | if (mydev->textmode == i) { | 284 | if (mydev->textmode == i) { |
285 | strcat(buf, " ["); | 285 | strcat(buf, " ["); |
286 | strcat(buf, display_textmodes[i]); | 286 | strcat(buf, display_textmodes[i]); |
@@ -304,15 +304,13 @@ static ssize_t set_attr_textmode(struct device *dev, | |||
304 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); | 304 | struct usb_sevsegdev *mydev = usb_get_intfdata(intf); |
305 | int i; | 305 | int i; |
306 | 306 | ||
307 | for (i = 0; display_textmodes[i]; i++) { | 307 | i = sysfs_match_string(display_textmodes, buf); |
308 | if (sysfs_streq(display_textmodes[i], buf)) { | 308 | if (i < 0) |
309 | mydev->textmode = i; | 309 | return i; |
310 | update_display_visual(mydev, GFP_KERNEL); | ||
311 | return count; | ||
312 | } | ||
313 | } | ||
314 | 310 | ||
315 | return -EINVAL; | 311 | mydev->textmode = i; |
312 | update_display_visual(mydev, GFP_KERNEL); | ||
313 | return count; | ||
316 | } | 314 | } |
317 | 315 | ||
318 | static DEVICE_ATTR(textmode, S_IRUGO | S_IWUSR, show_attr_textmode, set_attr_textmode); | 316 | static DEVICE_ATTR(textmode, S_IRUGO | S_IWUSR, show_attr_textmode, set_attr_textmode); |