usb: gadget: remove string override from struct usb_composite_driver
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Mon, 10 Sep 2012 13:01:57 +0000 (15:01 +0200)
committerFelipe Balbi <balbi@ti.com>
Mon, 10 Sep 2012 13:13:02 +0000 (16:13 +0300)
The struct usb_composite_driver members iProduct, iSerial and
iManufacturer can be entered directly via the string array. There is no
need for them to appear here.

Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/composite.c
drivers/usb/gadget/g_ffs.c
drivers/usb/gadget/mass_storage.c
drivers/usb/gadget/multi.c
include/linux/usb/composite.h

index 47b9130968bca828892391061b3d240b5748141b..f3689e1bf4b2e11dad1b349916fe7a3bf1c6fda9 100644 (file)
@@ -904,11 +904,7 @@ static int get_string(struct usb_composite_dev *cdev,
         * check if the string has not been overridden.
         */
        if (cdev->manufacturer_override == id)
-               str = composite->iManufacturer ?: composite_manufacturer;
-       else if (cdev->product_override == id)
-               str = composite->iProduct;
-       else if (cdev->serial_override == id)
-               str = composite->iSerialNumber;
+               str = composite_manufacturer;
        else
                str = NULL;
        if (str) {
@@ -1483,26 +1479,17 @@ static int composite_bind(struct usb_gadget *gadget,
 
        /* string overrides */
        if (!cdev->desc.iManufacturer) {
-               if (!composite->iManufacturer)
-                       snprintf(composite_manufacturer,
-                                sizeof composite_manufacturer,
-                                "%s %s with %s",
-                                init_utsname()->sysname,
-                                init_utsname()->release,
-                                gadget->name);
+               snprintf(composite_manufacturer,
+                               sizeof composite_manufacturer,
+                               "%s %s with %s",
+                               init_utsname()->sysname,
+                               init_utsname()->release,
+                               gadget->name);
 
                cdev->manufacturer_override =
                        override_id(cdev, &cdev->desc.iManufacturer);
        }
 
-       if (!cdev->desc.iProduct && composite->iProduct)
-               cdev->product_override =
-                       override_id(cdev, &cdev->desc.iProduct);
-
-       if (composite->iSerialNumber)
-               cdev->serial_override =
-                       override_id(cdev, &cdev->desc.iSerialNumber);
-
        /* has userspace failed to provide a serial number? */
        if (composite->needs_serial && !cdev->desc.iSerialNumber)
                WARNING(cdev, "userspace failed to provide iSerialNumber\n");
@@ -1619,8 +1606,6 @@ int usb_composite_probe(struct usb_composite_driver *driver)
 
        if (!driver->name)
                driver->name = "composite";
-       if (!driver->iProduct)
-               driver->iProduct = driver->name;
 
        driver->gadget_driver = composite_driver_template;
        gadget_driver = &driver->gadget_driver;
index 16d18873ebeb122b91daad9244b1360122db8511..eaaed199e453f191daf25362211e2f5333864038 100644 (file)
@@ -117,7 +117,7 @@ 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_PRODUCT_IDX].s = DRIVER_DESC,
        [USB_GADGET_SERIAL_IDX].s = "",
 #ifdef CONFIG_USB_FUNCTIONFS_RNDIS
        { .s = "FunctionFS + RNDIS" },
@@ -172,7 +172,6 @@ static __refdata struct usb_composite_driver gfs_driver = {
        .max_speed      = USB_SPEED_HIGH,
        .bind           = gfs_bind,
        .unbind         = gfs_unbind,
-       .iProduct       = DRIVER_DESC,
 };
 
 static DEFINE_MUTEX(gfs_lock);
@@ -360,6 +359,7 @@ static int gfs_bind(struct usb_composite_dev *cdev)
        ret = usb_string_ids_tab(cdev, gfs_strings);
        if (unlikely(ret < 0))
                goto error;
+       gfs_dev_desc.iProduct = gfs_strings[USB_GADGET_PRODUCT_IDX].id;
 
        for (i = func_num; --i; ) {
                ret = functionfs_bind(ffs_tab[i].ffs_data, cdev);
index 6f5a3b232d8160ed9e465e7a6f6239e14e4afb4b..50da3c88cb065850b6b58ea7b4eb6a85d908d1c9 100644 (file)
@@ -85,7 +85,7 @@ static const struct usb_descriptor_header *otg_desc[] = {
 
 static struct usb_string strings_dev[] = {
        [USB_GADGET_MANUFACTURER_IDX].s = "",
-       [USB_GADGET_PRODUCT_IDX].s = "",
+       [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC,
        [USB_GADGET_SERIAL_IDX].s = "",
        {  } /* end of list */
 };
@@ -160,6 +160,7 @@ static int __init msg_bind(struct usb_composite_dev *cdev)
        status = usb_string_ids_tab(cdev, strings_dev);
        if (status < 0)
                return status;
+       msg_device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
 
        status = usb_add_config(cdev, &msg_config_driver, msg_do_config);
        if (status < 0)
@@ -177,7 +178,6 @@ static int __init msg_bind(struct usb_composite_dev *cdev)
 static __refdata struct usb_composite_driver msg_driver = {
        .name           = "g_mass_storage",
        .dev            = &msg_device_desc,
-       .iProduct       = DRIVER_DESC,
        .max_speed      = USB_SPEED_SUPER,
        .needs_serial   = 1,
        .strings        = dev_strings,
index 94b35e5539d75739fe4e0bfa2c379cc42614a4c0..c158706b5ab09895e5a1ca53e2f148ff3b92c082 100644 (file)
@@ -115,7 +115,7 @@ enum {
 
 static struct usb_string strings_dev[] = {
        [USB_GADGET_MANUFACTURER_IDX].s = "",
-       [USB_GADGET_PRODUCT_IDX].s = "",
+       [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC,
        [USB_GADGET_SERIAL_IDX].s = "",
        [MULTI_STRING_RNDIS_CONFIG_IDX].s = "Multifunction with RNDIS",
        [MULTI_STRING_CDC_CONFIG_IDX].s   = "Multifunction with CDC ECM",
@@ -293,6 +293,7 @@ static int __ref multi_bind(struct usb_composite_dev *cdev)
        status = usb_string_ids_tab(cdev, strings_dev);
        if (unlikely(status < 0))
                goto fail2;
+       device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
 
        /* register configurations */
        status = rndis_config_register(cdev);
@@ -338,7 +339,6 @@ static __refdata struct usb_composite_driver multi_driver = {
        .max_speed      = USB_SPEED_HIGH,
        .bind           = multi_bind,
        .unbind         = __exit_p(multi_unbind),
-       .iProduct       = DRIVER_DESC,
        .needs_serial   = 1,
 };
 
index 5cd110ec0a2373d2f29671d936b7c599007b55a3..60f8815998bd6377a58385a6c3d8418a6a5f3629 100644 (file)
@@ -259,13 +259,6 @@ enum {
 /**
  * struct usb_composite_driver - groups configurations into a gadget
  * @name: For diagnostics, identifies the driver.
- * @iProduct: Used as iProduct override if @dev->iProduct is not set.
- *     If NULL value of @name is taken.
- * @iManufacturer: Used as iManufacturer override if @dev->iManufacturer is
- *     not set. If NULL a default "<system> <release> with <udc>" value
- *     will be used.
- * @iSerialNumber: Used as iSerialNumber override if @dev->iSerialNumber is
- *     not set.
  * @dev: Template descriptor for the device, including default device
  *     identifiers.
  * @strings: tables of strings, keyed by identifiers assigned during @bind
@@ -300,9 +293,6 @@ enum {
  */
 struct usb_composite_driver {
        const char                              *name;
-       const char                              *iProduct;
-       const char                              *iManufacturer;
-       const char                              *iSerialNumber;
        const struct usb_device_descriptor      *dev;
        struct usb_gadget_strings               **strings;
        enum usb_device_speed                   max_speed;
@@ -369,8 +359,6 @@ struct usb_composite_dev {
        struct usb_composite_driver     *driver;
        u8                              next_string_id;
        u8                              manufacturer_override;
-       u8                              product_override;
-       u8                              serial_override;
 
        /* the gadget driver won't enable the data pullup
         * while the deactivation count is nonzero.