MODULE_DEVICE_TABLE(usb, id_table);
 
 /* 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_device *udev;
 
        buf[0] = 0;
 
-       for (i = 0; display_textmodes[i]; i++) {
+       for (i = 0; i < ARRAY_SIZE(display_textmodes); i++) {
                if (mydev->textmode == i) {
                        strcat(buf, " [");
                        strcat(buf, display_textmodes[i]);
        struct usb_sevsegdev *mydev = usb_get_intfdata(intf);
        int i;
 
-       for (i = 0; display_textmodes[i]; i++) {
-               if (sysfs_streq(display_textmodes[i], buf)) {
-                       mydev->textmode = i;
-                       update_display_visual(mydev, GFP_KERNEL);
-                       return count;
-               }
-       }
+       i = sysfs_match_string(display_textmodes, buf);
+       if (i < 0)
+               return i;
 
-       return -EINVAL;
+       mydev->textmode = i;
+       update_display_visual(mydev, GFP_KERNEL);
+       return count;
 }
 
 static DEVICE_ATTR(textmode, S_IRUGO | S_IWUSR, show_attr_textmode, set_attr_textmode);