usb: gadget: make sure each gadget is using same index for Product, Serial,…
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Thu, 6 Sep 2012 18:11:21 +0000 (20:11 +0200)
committerFelipe Balbi <balbi@ti.com>
Mon, 10 Sep 2012 13:13:00 +0000 (16:13 +0300)
The index in usb_string array is defined by the gadget. The gadget can
choose which index entry it assigns for the serial number and which the
product name. The gadget has just to ensure that the descriptor contains
the proper string id which is assigned by composite.
If the composite layer knows the index of the "default" information
which will be overwritten by module parameters, it can be used later to
overwrite it.

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
17 files changed:
drivers/usb/gadget/acm_ms.c
drivers/usb/gadget/audio.c
drivers/usb/gadget/cdc2.c
drivers/usb/gadget/ether.c
drivers/usb/gadget/g_ffs.c
drivers/usb/gadget/gmidi.c
drivers/usb/gadget/hid.c
drivers/usb/gadget/multi.c
drivers/usb/gadget/ncm.c
drivers/usb/gadget/nokia.c
drivers/usb/gadget/printer.c
drivers/usb/gadget/serial.c
drivers/usb/gadget/tcm_usb_gadget.c
drivers/usb/gadget/tcm_usb_gadget.h
drivers/usb/gadget/webcam.c
drivers/usb/gadget/zero.c
include/linux/usb/composite.h

index 7bd6b71..35db6aa 100644 (file)
@@ -90,14 +90,12 @@ static const struct usb_descriptor_header *otg_desc[] = {
 
 /* string IDs are assigned dynamically */
 
-#define STRING_MANUFACTURER_IDX                0
-#define STRING_PRODUCT_IDX             1
-
 static char manufacturer[50];
 
 static struct usb_string strings_dev[] = {
-       [STRING_MANUFACTURER_IDX].s = manufacturer,
-       [STRING_PRODUCT_IDX].s = DRIVER_DESC,
+       [USB_GADGET_MANUFACTURER_IDX].s = manufacturer,
+       [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC,
+       [USB_GADGET_SERIAL_IDX].s = "",
        {  } /* end of list */
 };
 
@@ -196,8 +194,8 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev)
        status = usb_string_ids_tab(cdev, strings_dev);
        if (status < 0)
                goto fail1;
-       device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
-       device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id;
+       device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
+       device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
 
        /* register our configuration */
        status = usb_add_config(cdev, &acm_ms_config_driver, acm_ms_do_config);
index 55b593c..8857b6e 100644 (file)
@@ -33,14 +33,12 @@ USB_GADGET_COMPOSITE_OPTIONS();
 
 /* string IDs are assigned dynamically */
 
-#define STRING_MANUFACTURER_IDX                0
-#define STRING_PRODUCT_IDX             1
-
 static char manufacturer[50];
 
 static struct usb_string strings_dev[] = {
-       [STRING_MANUFACTURER_IDX].s = manufacturer,
-       [STRING_PRODUCT_IDX].s = DRIVER_DESC,
+       [USB_GADGET_MANUFACTURER_IDX].s = manufacturer,
+       [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC,
+       [USB_GADGET_SERIAL_IDX].s = "",
        {  } /* end of list */
 };
 
@@ -170,8 +168,8 @@ static int __init audio_bind(struct usb_composite_dev *cdev)
        status = usb_string_ids_tab(cdev, strings_dev);
        if (status < 0)
                goto fail;
-       device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
-       device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id;
+       device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
+       device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
 
        status = usb_add_config(cdev, &audio_config_driver, audio_do_config);
        if (status < 0)
index 93a7580..8966bde 100644 (file)
@@ -90,15 +90,12 @@ static const struct usb_descriptor_header *otg_desc[] = {
 
 
 /* string IDs are assigned dynamically */
-
-#define STRING_MANUFACTURER_IDX                0
-#define STRING_PRODUCT_IDX             1
-
 static char manufacturer[50];
 
 static struct usb_string strings_dev[] = {
-       [STRING_MANUFACTURER_IDX].s = manufacturer,
-       [STRING_PRODUCT_IDX].s = DRIVER_DESC,
+       [USB_GADGET_MANUFACTURER_IDX].s = manufacturer,
+       [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC,
+       [USB_GADGET_SERIAL_IDX].s = "",
        {  } /* end of list */
 };
 
@@ -197,8 +194,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
        status = usb_string_ids_tab(cdev, strings_dev);
        if (status < 0)
                goto fail1;
-       device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
-       device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id;
+       device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
+       device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
 
        /* register our configuration */
        status = usb_add_config(cdev, &cdc_config_driver, cdc_do_config);
index 709ef22..dd5e00d 100644 (file)
@@ -193,17 +193,13 @@ static const struct usb_descriptor_header *otg_desc[] = {
        NULL,
 };
 
-
 /* string IDs are assigned dynamically */
-
-#define STRING_MANUFACTURER_IDX                0
-#define STRING_PRODUCT_IDX             1
-
 static char manufacturer[50];
 
 static struct usb_string strings_dev[] = {
-       [STRING_MANUFACTURER_IDX].s = manufacturer,
-       [STRING_PRODUCT_IDX].s = PREFIX DRIVER_DESC,
+       [USB_GADGET_MANUFACTURER_IDX].s = manufacturer,
+       [USB_GADGET_PRODUCT_IDX].s = PREFIX DRIVER_DESC,
+       [USB_GADGET_SERIAL_IDX].s = "",
        {  } /* end of list */
 };
 
@@ -349,8 +345,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
        status = usb_string_ids_tab(cdev, strings_dev);
        if (status < 0)
                goto fail;
-       device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
-       device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id;
+       device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
+       device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
 
        /* register our configuration(s); RNDIS first, if it's used */
        if (has_rndis()) {
index a44ed66..16d1887 100644 (file)
@@ -116,6 +116,9 @@ static const struct usb_descriptor_header *gfs_otg_desc[] = {
 
 /* String IDs are assigned dynamically */
 static struct usb_string gfs_strings[] = {
+       [USB_GADGET_MANUFACTURER_IDX].s = "",
+       [USB_GADGET_PRODUCT_IDX].s = "",
+       [USB_GADGET_SERIAL_IDX].s = "",
 #ifdef CONFIG_USB_FUNCTIONFS_RNDIS
        { .s = "FunctionFS + RNDIS" },
 #endif
@@ -369,9 +372,10 @@ static int gfs_bind(struct usb_composite_dev *cdev)
 
        for (i = 0; i < ARRAY_SIZE(gfs_configurations); ++i) {
                struct gfs_configuration *c = gfs_configurations + i;
+               int sid = USB_GADGET_FIRST_AVAIL_IDX + i;
 
-               c->c.label                      = gfs_strings[i].s;
-               c->c.iConfiguration             = gfs_strings[i].id;
+               c->c.label                      = gfs_strings[sid].s;
+               c->c.iConfiguration             = gfs_strings[sid].id;
                c->c.bConfigurationValue        = 1 + i;
                c->c.bmAttributes               = USB_CONFIG_ATT_SELFPOWER;
 
index 01b31e2..2ee3a74 100644 (file)
@@ -84,9 +84,7 @@ MODULE_PARM_DESC(out_ports, "Number of MIDI output ports");
 
 /* string IDs are assigned dynamically */
 
-#define STRING_MANUFACTURER_IDX                0
-#define STRING_PRODUCT_IDX             1
-#define STRING_DESCRIPTION_IDX         2
+#define STRING_DESCRIPTION_IDX         USB_GADGET_FIRST_AVAIL_IDX
 
 static struct usb_device_descriptor device_desc = {
        .bLength =              USB_DT_DEVICE_SIZE,
@@ -101,8 +99,9 @@ static struct usb_device_descriptor device_desc = {
 };
 
 static struct usb_string strings_dev[] = {
-       [STRING_MANUFACTURER_IDX].s     = "Grey Innovation",
-       [STRING_PRODUCT_IDX].s          = "MIDI Gadget",
+       [USB_GADGET_MANUFACTURER_IDX].s = "Grey Innovation",
+       [USB_GADGET_PRODUCT_IDX].s      = "MIDI Gadget",
+       [USB_GADGET_SERIAL_IDX].s       = "",
        [STRING_DESCRIPTION_IDX].s      = "MIDI",
        {  } /* end of list */
 };
@@ -145,8 +144,8 @@ static int __init midi_bind(struct usb_composite_dev *cdev)
        status = usb_string_ids_tab(cdev, strings_dev);
        if (status < 0)
                return status;
-       device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
-       device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id;
+       device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
+       device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
        midi_config.iConfiguration = strings_dev[STRING_DESCRIPTION_IDX].id;
 
        gcnum = usb_gadget_controller_number(gadget);
index 59fe7ee..16caf50 100644 (file)
@@ -91,15 +91,12 @@ static const struct usb_descriptor_header *otg_desc[] = {
 
 
 /* string IDs are assigned dynamically */
-
-#define STRING_MANUFACTURER_IDX                0
-#define STRING_PRODUCT_IDX             1
-
 static char manufacturer[50];
 
 static struct usb_string strings_dev[] = {
-       [STRING_MANUFACTURER_IDX].s = manufacturer,
-       [STRING_PRODUCT_IDX].s = DRIVER_DESC,
+       [USB_GADGET_MANUFACTURER_IDX].s = manufacturer,
+       [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC,
+       [USB_GADGET_SERIAL_IDX].s = "",
        {  } /* end of list */
 };
 
@@ -181,8 +178,8 @@ static int __init hid_bind(struct usb_composite_dev *cdev)
        status = usb_string_ids_tab(cdev, strings_dev);
        if (status < 0)
                return status;
-       device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
-       device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id;
+       device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
+       device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
 
        /* register our configuration */
        status = usb_add_config(cdev, &config_driver, do_config);
index 6016887..94b35e5 100644 (file)
@@ -109,21 +109,16 @@ static const struct usb_descriptor_header *otg_desc[] = {
 
 
 enum {
-#ifdef CONFIG_USB_G_MULTI_RNDIS
-       MULTI_STRING_RNDIS_CONFIG_IDX,
-#endif
-#ifdef CONFIG_USB_G_MULTI_CDC
+       MULTI_STRING_RNDIS_CONFIG_IDX = USB_GADGET_FIRST_AVAIL_IDX,
        MULTI_STRING_CDC_CONFIG_IDX,
-#endif
 };
 
 static struct usb_string strings_dev[] = {
-#ifdef CONFIG_USB_G_MULTI_RNDIS
+       [USB_GADGET_MANUFACTURER_IDX].s = "",
+       [USB_GADGET_PRODUCT_IDX].s = "",
+       [USB_GADGET_SERIAL_IDX].s = "",
        [MULTI_STRING_RNDIS_CONFIG_IDX].s = "Multifunction with RNDIS",
-#endif
-#ifdef CONFIG_USB_G_MULTI_CDC
        [MULTI_STRING_CDC_CONFIG_IDX].s   = "Multifunction with CDC ECM",
-#endif
        {  } /* end of list */
 };
 
index 8537cd9..1a26452 100644 (file)
@@ -97,15 +97,12 @@ static const struct usb_descriptor_header *otg_desc[] = {
 
 
 /* string IDs are assigned dynamically */
-
-#define STRING_MANUFACTURER_IDX                0
-#define STRING_PRODUCT_IDX             1
-
 static char manufacturer[50];
 
 static struct usb_string strings_dev[] = {
-       [STRING_MANUFACTURER_IDX].s = manufacturer,
-       [STRING_PRODUCT_IDX].s = DRIVER_DESC,
+       [USB_GADGET_MANUFACTURER_IDX].s = manufacturer,
+       [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC,
+       [USB_GADGET_SERIAL_IDX].s = "",
        {  } /* end of list */
 };
 
@@ -184,8 +181,8 @@ static int __init gncm_bind(struct usb_composite_dev *cdev)
        status = usb_string_ids_tab(cdev, strings_dev);
        if (status < 0)
                goto fail;
-       device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
-       device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id;
+       device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
+       device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
 
        status = usb_add_config(cdev, &ncm_config_driver,
                                ncm_do_config);
index 5ed927b..34b97f1 100644 (file)
@@ -56,17 +56,16 @@ USB_GADGET_COMPOSITE_OPTIONS();
 
 /* string IDs are assigned dynamically */
 
-#define STRING_MANUFACTURER_IDX                0
-#define STRING_PRODUCT_IDX             1
-#define STRING_DESCRIPTION_IDX         2
+#define STRING_DESCRIPTION_IDX         USB_GADGET_FIRST_AVAIL_IDX
 
 static char manufacturer_nokia[] = "Nokia";
 static const char product_nokia[] = NOKIA_LONG_NAME;
 static const char description_nokia[] = "PC-Suite Configuration";
 
 static struct usb_string strings_dev[] = {
-       [STRING_MANUFACTURER_IDX].s = manufacturer_nokia,
-       [STRING_PRODUCT_IDX].s = NOKIA_LONG_NAME,
+       [USB_GADGET_MANUFACTURER_IDX].s = manufacturer_nokia,
+       [USB_GADGET_PRODUCT_IDX].s = NOKIA_LONG_NAME,
+       [USB_GADGET_SERIAL_IDX].s = "",
        [STRING_DESCRIPTION_IDX].s = description_nokia,
        {  } /* end of list */
 };
@@ -168,8 +167,8 @@ static int __init nokia_bind(struct usb_composite_dev *cdev)
        status = usb_string_ids_tab(cdev, strings_dev);
        if (status < 0)
                goto err_usb;
-       device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
-       device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id;
+       device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
+       device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
        status = strings_dev[STRING_DESCRIPTION_IDX].id;
        nokia_config_500ma_driver.iConfiguration = status;
        nokia_config_100ma_driver.iConfiguration = status;
index 3fa4d80..f02434a 100644 (file)
@@ -139,10 +139,6 @@ module_param(qlen, uint, S_IRUGO|S_IWUSR);
  * descriptors are built on demand.
  */
 
-#define STRING_MANUFACTURER            0
-#define STRING_PRODUCT                 1
-#define STRING_SERIALNUM               2
-
 /* holds our biggest descriptor */
 #define USB_DESC_BUFSIZE               256
 #define USB_BUFSIZE                    8192
@@ -250,9 +246,9 @@ static char                         pnp_string [1024] =
 
 /* static strings, in UTF-8 */
 static struct usb_string               strings [] = {
-       [STRING_MANUFACTURER].s = manufacturer,
-       [STRING_PRODUCT].s = product_desc,
-       [STRING_SERIALNUM].s =  serial_num,
+       [USB_GADGET_MANUFACTURER_IDX].s = manufacturer,
+       [USB_GADGET_PRODUCT_IDX].s = product_desc,
+       [USB_GADGET_SERIAL_IDX].s =     serial_num,
        {  }            /* end of list */
 };
 
@@ -1261,9 +1257,9 @@ static int __init printer_bind(struct usb_composite_dev *cdev)
        ret = usb_string_ids_tab(cdev, strings);
        if (ret < 0)
                return ret;
-       device_desc.iManufacturer = strings[STRING_MANUFACTURER].id;
-       device_desc.iProduct = strings[STRING_PRODUCT].id;
-       device_desc.iSerialNumber = strings[STRING_SERIALNUM].id;
+       device_desc.iManufacturer = strings[USB_GADGET_MANUFACTURER_IDX].id;
+       device_desc.iProduct = strings[USB_GADGET_PRODUCT_IDX].id;
+       device_desc.iSerialNumber = strings[USB_GADGET_SERIAL_IDX].id;
 
        ret = usb_add_config(cdev, &printer_cfg_driver, printer_bind_config);
        if (ret)
index 27b5ce9..768a38e 100644 (file)
@@ -59,15 +59,14 @@ USB_GADGET_COMPOSITE_OPTIONS();
 
 /* string IDs are assigned dynamically */
 
-#define STRING_MANUFACTURER_IDX                0
-#define STRING_PRODUCT_IDX             1
-#define STRING_DESCRIPTION_IDX         2
+#define STRING_DESCRIPTION_IDX         USB_GADGET_FIRST_AVAIL_IDX
 
 static char manufacturer[50];
 
 static struct usb_string strings_dev[] = {
-       [STRING_MANUFACTURER_IDX].s = manufacturer,
-       [STRING_PRODUCT_IDX].s = GS_VERSION_NAME,
+       [USB_GADGET_MANUFACTURER_IDX].s = manufacturer,
+       [USB_GADGET_PRODUCT_IDX].s = GS_VERSION_NAME,
+       [USB_GADGET_SERIAL_IDX].s = "",
        [STRING_DESCRIPTION_IDX].s = NULL /* updated; f(use_acm) */,
        {  } /* end of list */
 };
@@ -179,8 +178,8 @@ static int __init gs_bind(struct usb_composite_dev *cdev)
        status = usb_string_ids_tab(cdev, strings_dev);
        if (status < 0)
                goto fail;
-       device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
-       device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id;
+       device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
+       device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
        status = strings_dev[STRING_DESCRIPTION_IDX].id;
        serial_config_driver.iConfiguration = status;
 
index fa3137e..b56d57d 100644 (file)
@@ -2210,9 +2210,9 @@ static struct usb_device_descriptor usbg_device_desc = {
 };
 
 static struct usb_string       usbg_us_strings[] = {
-       [USB_G_STR_MANUFACTOR].s        = "Target Manufactor",
-       [USB_G_STR_PRODUCT].s           = "Target Product",
-       [USB_G_STR_SERIAL].s            = "000000000001",
+       [USB_GADGET_MANUFACTURER_IDX].s = "Target Manufactor",
+       [USB_GADGET_PRODUCT_IDX].s      = "Target Product",
+       [USB_GADGET_SERIAL_IDX].s       = "000000000001",
        [USB_G_STR_CONFIG].s            = "default config",
        [USB_G_STR_INT_UAS].s           = "USB Attached SCSI",
        [USB_G_STR_INT_BBB].s           = "Bulk Only Transport",
@@ -2431,9 +2431,10 @@ static int usb_target_bind(struct usb_composite_dev *cdev)
                return ret;
 
        usbg_device_desc.iManufacturer =
-               usbg_us_strings[USB_G_STR_MANUFACTOR].id;
-       usbg_device_desc.iProduct = usbg_us_strings[USB_G_STR_PRODUCT].id;
-       usbg_device_desc.iSerialNumber = usbg_us_strings[USB_G_STR_SERIAL].id;
+               usbg_us_strings[USB_GADGET_MANUFACTURER_IDX].id;
+       usbg_device_desc.iProduct = usbg_us_strings[USB_GADGET_PRODUCT_IDX].id;
+       usbg_device_desc.iSerialNumber =
+               usbg_us_strings[USB_GADGET_SERIAL_IDX].id;
        usbg_config_driver.iConfiguration =
                usbg_us_strings[USB_G_STR_CONFIG].id;
 
index 9d32ec3..8289219 100644 (file)
 #define UASP_SS_EP_COMP_NUM_STREAMS (1 << UASP_SS_EP_COMP_LOG_STREAMS)
 
 enum {
-       USB_G_STR_MANUFACTOR,
-       USB_G_STR_PRODUCT,
-       USB_G_STR_SERIAL,
-       USB_G_STR_CONFIG,
+       USB_G_STR_CONFIG = USB_GADGET_FIRST_AVAIL_IDX,
        USB_G_STR_INT_UAS,
        USB_G_STR_INT_BBB,
 };
index 3060064..0359119 100644 (file)
@@ -45,13 +45,12 @@ static char webcam_config_label[] = "Video";
 
 /* string IDs are assigned dynamically */
 
-#define STRING_MANUFACTURER_IDX                0
-#define STRING_PRODUCT_IDX             1
-#define STRING_DESCRIPTION_IDX         2
+#define STRING_DESCRIPTION_IDX         USB_GADGET_FIRST_AVAIL_IDX
 
 static struct usb_string webcam_strings[] = {
-       [STRING_MANUFACTURER_IDX].s = webcam_vendor_label,
-       [STRING_PRODUCT_IDX].s = webcam_product_label,
+       [USB_GADGET_MANUFACTURER_IDX].s = webcam_vendor_label,
+       [USB_GADGET_PRODUCT_IDX].s = webcam_product_label,
+       [USB_GADGET_SERIAL_IDX].s = "",
        [STRING_DESCRIPTION_IDX].s = webcam_config_label,
        {  }
 };
@@ -360,9 +359,9 @@ webcam_bind(struct usb_composite_dev *cdev)
        if (ret < 0)
                goto error;
        webcam_device_descriptor.iManufacturer =
-               webcam_strings[STRING_MANUFACTURER_IDX].id;
+               webcam_strings[USB_GADGET_MANUFACTURER_IDX].id;
        webcam_device_descriptor.iProduct =
-               webcam_strings[STRING_PRODUCT_IDX].id;
+               webcam_strings[USB_GADGET_PRODUCT_IDX].id;
        webcam_config_driver.iConfiguration =
                webcam_strings[STRING_DESCRIPTION_IDX].id;
 
index 2b31a4a..ee769c4 100644 (file)
@@ -139,20 +139,15 @@ const struct usb_descriptor_header *otg_desc[] = {
 #endif
 
 /* string IDs are assigned dynamically */
-
-#define STRING_MANUFACTURER_IDX                0
-#define STRING_PRODUCT_IDX             1
-#define STRING_SERIAL_IDX              2
-
 static char manufacturer[50];
 
 /* default serial number takes at least two packets */
 static char serial[] = "0123456789.0123456789.0123456789";
 
 static struct usb_string strings_dev[] = {
-       [STRING_MANUFACTURER_IDX].s = manufacturer,
-       [STRING_PRODUCT_IDX].s = longname,
-       [STRING_SERIAL_IDX].s = serial,
+       [USB_GADGET_MANUFACTURER_IDX].s = manufacturer,
+       [USB_GADGET_PRODUCT_IDX].s = longname,
+       [USB_GADGET_SERIAL_IDX].s = serial,
        {  }                    /* end of list */
 };
 
@@ -274,9 +269,9 @@ static int __init zero_bind(struct usb_composite_dev *cdev)
        if (status < 0)
                return status;
 
-       device_desc.iManufacturer = strings_dev[STRING_MANUFACTURER_IDX].id;
-       device_desc.iProduct = strings_dev[STRING_PRODUCT_IDX].id;
-       device_desc.iSerialNumber = strings_dev[STRING_SERIAL_IDX].id;
+       device_desc.iManufacturer = strings_dev[USB_GADGET_MANUFACTURER_IDX].id;
+       device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
+       device_desc.iSerialNumber = strings_dev[USB_GADGET_SERIAL_IDX].id;
 
        setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev);
 
index 7651e5b..f821a3a 100644 (file)
@@ -248,6 +248,14 @@ int usb_add_config(struct usb_composite_dev *,
 void usb_remove_config(struct usb_composite_dev *,
                struct usb_configuration *);
 
+/* predefined index for usb_composite_driver */
+enum {
+       USB_GADGET_MANUFACTURER_IDX     = 0,
+       USB_GADGET_PRODUCT_IDX,
+       USB_GADGET_SERIAL_IDX,
+       USB_GADGET_FIRST_AVAIL_IDX,
+};
+
 /**
  * struct usb_composite_driver - groups configurations into a gadget
  * @name: For diagnostics, identifies the driver.
@@ -261,7 +269,9 @@ void usb_remove_config(struct usb_composite_dev *,
  * @dev: Template descriptor for the device, including default device
  *     identifiers.
  * @strings: tables of strings, keyed by identifiers assigned during @bind
- *     and language IDs provided in control requests
+ *     and language IDs provided in control requests. Note: The first entries
+ *     are predefined. The first entry that may be used is
+ *     USB_GADGET_FIRST_AVAIL_IDX
  * @max_speed: Highest speed the driver supports.
  * @needs_serial: set to 1 if the gadget needs userspace to provide
  *     a serial number.  If one is not provided, warning will be printed.