usb: gadget: Provide a default implementation of default manufacturer string
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / usb / gadget / hid.c
index 3493adf064f512bccc28358a202015188ff932e9..0e2e357cc59e4db57db1fb51b99d0952423acd56 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 #include <linux/list.h>
 
+#include "gadget_chips.h"
 #define DRIVER_DESC            "HID Gadget"
 #define DRIVER_VERSION         "2010/03/16"
 
@@ -35,9 +36,6 @@
  */
 
 #include "composite.c"
-#include "usbstring.c"
-#include "config.c"
-#include "epautoconf.c"
 
 #include "f_hid.c"
 
@@ -50,6 +48,7 @@ struct hidg_func_node {
 static LIST_HEAD(hidg_func_list);
 
 /*-------------------------------------------------------------------------*/
+USB_GADGET_COMPOSITE_OPTIONS();
 
 static struct usb_device_descriptor device_desc = {
        .bLength =              sizeof device_desc,
@@ -92,15 +91,10 @@ 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 = "",
+       [USB_GADGET_PRODUCT_IDX].s = DRIVER_DESC,
+       [USB_GADGET_SERIAL_IDX].s = "",
        {  } /* end of list */
 };
 
@@ -169,32 +163,22 @@ static int __init hid_bind(struct usb_composite_dev *cdev)
        else
                device_desc.bcdDevice = cpu_to_le16(0x0300 | 0x0099);
 
-
        /* Allocate string descriptor numbers ... note that string
         * contents can be overridden by the composite_dev glue.
         */
 
-       /* device descriptor strings: manufacturer, product */
-       snprintf(manufacturer, sizeof manufacturer, "%s %s with %s",
-               init_utsname()->sysname, init_utsname()->release,
-               gadget->name);
-       status = usb_string_id(cdev);
-       if (status < 0)
-               return status;
-       strings_dev[STRING_MANUFACTURER_IDX].id = status;
-       device_desc.iManufacturer = status;
-
-       status = usb_string_id(cdev);
+       status = usb_string_ids_tab(cdev, strings_dev);
        if (status < 0)
                return status;
-       strings_dev[STRING_PRODUCT_IDX].id = status;
-       device_desc.iProduct = status;
+       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);
        if (status < 0)
                return status;
 
+       usb_composite_overwrite_options(cdev, &coverwrite);
        dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n");
 
        return 0;
@@ -242,11 +226,12 @@ static int __devexit hidg_plat_driver_remove(struct platform_device *pdev)
 /****************************** Some noise ******************************/
 
 
-static struct usb_composite_driver hidg_driver = {
+static __refdata struct usb_composite_driver hidg_driver = {
        .name           = "g_hid",
        .dev            = &device_desc,
        .strings        = dev_strings,
        .max_speed      = USB_SPEED_HIGH,
+       .bind           = hid_bind,
        .unbind         = __exit_p(hid_unbind),
 };
 
@@ -272,7 +257,7 @@ static int __init hidg_init(void)
        if (status < 0)
                return status;
 
-       status = usb_composite_probe(&hidg_driver, hid_bind);
+       status = usb_composite_probe(&hidg_driver);
        if (status < 0)
                platform_driver_unregister(&hidg_plat_driver);