Commit 0bd08fc8 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Greg Kroah-Hartman

usb: misc: usbsevseg: Use sysfs_match_string() helper

Use sysfs_match_string() helper instead of open coded variant.
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d3be974a
...@@ -33,7 +33,7 @@ static const struct usb_device_id id_table[] = { ...@@ -33,7 +33,7 @@ static const struct usb_device_id id_table[] = {
MODULE_DEVICE_TABLE(usb, id_table); MODULE_DEVICE_TABLE(usb, id_table);
/* the different text display modes the device is capable of */ /* the different text display modes the device is capable of */
static char *display_textmodes[] = {"raw", "hex", "ascii", NULL}; static const char *display_textmodes[] = {"raw", "hex", "ascii"};
struct usb_sevsegdev { struct usb_sevsegdev {
struct usb_device *udev; struct usb_device *udev;
...@@ -280,7 +280,7 @@ static ssize_t show_attr_textmode(struct device *dev, ...@@ -280,7 +280,7 @@ static ssize_t show_attr_textmode(struct device *dev,
buf[0] = 0; buf[0] = 0;
for (i = 0; display_textmodes[i]; i++) { for (i = 0; i < ARRAY_SIZE(display_textmodes); i++) {
if (mydev->textmode == i) { if (mydev->textmode == i) {
strcat(buf, " ["); strcat(buf, " [");
strcat(buf, display_textmodes[i]); strcat(buf, display_textmodes[i]);
...@@ -304,15 +304,13 @@ static ssize_t set_attr_textmode(struct device *dev, ...@@ -304,15 +304,13 @@ static ssize_t set_attr_textmode(struct device *dev,
struct usb_sevsegdev *mydev = usb_get_intfdata(intf); struct usb_sevsegdev *mydev = usb_get_intfdata(intf);
int i; int i;
for (i = 0; display_textmodes[i]; i++) { i = sysfs_match_string(display_textmodes, buf);
if (sysfs_streq(display_textmodes[i], buf)) { if (i < 0)
return i;
mydev->textmode = i; mydev->textmode = i;
update_display_visual(mydev, GFP_KERNEL); update_display_visual(mydev, GFP_KERNEL);
return count; return count;
}
}
return -EINVAL;
} }
static DEVICE_ATTR(textmode, S_IRUGO | S_IWUSR, show_attr_textmode, set_attr_textmode); static DEVICE_ATTR(textmode, S_IRUGO | S_IWUSR, show_attr_textmode, set_attr_textmode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment