usb: gadget: g_ffs: Allow to set configuration string 35/88035/3
authorKrzysztof Opasiak <k.opasiak@samsung.com>
Mon, 12 Sep 2016 20:23:26 +0000 (22:23 +0200)
committerKrzysztof Opasiak <k.opasiak@samsung.com>
Tue, 20 Sep 2016 09:13:24 +0000 (11:13 +0200)
usb host tests expect configuration string to have
a predefined value. As on 3.10 kernel we cannot use
ConfigFS to achieve this let's add a module parameter
which allows us to set it.

Change-Id: I7556ef87fb4da7ae1f86fa4f110f78ffd5d2b854
Signed-off-by: Krzysztof Opasiak <k.opasiak@samsung.com>
drivers/usb/gadget/g_ffs.c

index 787a78e..6576186 100644 (file)
@@ -124,11 +124,19 @@ static struct usb_string gfs_strings[] = {
        { .s = "FunctionFS + ECM" },
 #endif
 #ifdef CONFIG_USB_FUNCTIONFS_GENERIC
-       { .s = "FunctionFS" },
+       { }, /* set dynamically based on module param */
 #endif
        {  } /* end of list */
 };
 
+#ifdef CONFIG_USB_FUNCTIONFS_GENERIC
+static char *generic_ffs_config_str = "FunctionFS";
+module_param_named(generic_ffs_config_str,
+                  generic_ffs_config_str,
+                  charp, S_IRUGO);
+MODULE_PARM_DESC(generic_ffs_config_str,
+                "Configuration string of generic FFS config");
+#endif
 static struct usb_gadget_strings *gfs_dev_strings[] = {
        &(struct usb_gadget_strings) {
                .language       = 0x0409,       /* en-us */
@@ -186,6 +194,14 @@ static int __init gfs_init(void)
 
        ENTER();
 
+#ifdef CONFIG_USB_FUNCTIONFS_GENERIC
+       /* Find first (but not last) config with a NULL str */
+       for (i = 0; i < ARRAY_SIZE(gfs_strings) - 1 ; ++i)
+               if (!gfs_strings[i].s) {
+                       gfs_strings[i].s = generic_ffs_config_str;
+                       break;
+               }
+#endif
        if (!func_num) {
                gfs_single_func = true;
                func_num = 1;