]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
usb: gadget: move source sink's config descriptor out of f_sourcesink
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>
Sun, 23 Dec 2012 20:09:58 +0000 (21:09 +0100)
committerFelipe Balbi <balbi@ti.com>
Mon, 21 Jan 2013 18:52:38 +0000 (20:52 +0200)
f_sourcesink should only include the bare function but it also includes
the config descriptor. This patch moves the config descriptor into
zero.c, the only user of this function.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/f_sourcesink.c
drivers/usb/gadget/g_zero.h
drivers/usb/gadget/zero.c

index bac04b0c628eb40d642b9097c55e82666c97a231..f785cbd596885c0a398749d3c47c5572a7ef53d0 100644 (file)
@@ -328,6 +328,14 @@ sourcesink_bind(struct usb_configuration *c, struct usb_function *f)
        source_sink_intf_alt0.bInterfaceNumber = id;
        source_sink_intf_alt1.bInterfaceNumber = id;
 
+       /* allocate string ID(s) */
+       id = usb_string_id(cdev);
+       if (id < 0)
+               return id;
+       strings_sourcesink[0].id = id;
+       source_sink_intf_alt0.iInterface = id;
+       source_sink_intf_alt1.iInterface = id;
+
        /* allocate bulk endpoints */
        ss->in_ep = usb_ep_autoconfig(cdev->gadget, &fs_source_desc);
        if (!ss->in_ep) {
@@ -869,43 +877,3 @@ static int ss_config_setup(struct usb_configuration *c,
                return -EOPNOTSUPP;
        }
 }
-
-static struct usb_configuration sourcesink_driver = {
-       .label                  = "source/sink",
-       .strings                = sourcesink_strings,
-       .setup                  = ss_config_setup,
-       .bConfigurationValue    = 3,
-       .bmAttributes           = USB_CONFIG_ATT_SELFPOWER,
-       /* .iConfiguration      = DYNAMIC */
-};
-
-/**
- * sourcesink_add - add a source/sink testing configuration to a device
- * @cdev: the device to support the configuration
- */
-int __init sourcesink_add(struct usb_composite_dev *cdev, bool autoresume)
-{
-       int id;
-
-       /* allocate string ID(s) */
-       id = usb_string_id(cdev);
-       if (id < 0)
-               return id;
-       strings_sourcesink[0].id = id;
-
-       source_sink_intf_alt0.iInterface = id;
-       source_sink_intf_alt1.iInterface = id;
-       sourcesink_driver.iConfiguration = id;
-
-       /* support autoresume for remote wakeup testing */
-       if (autoresume)
-               sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
-
-       /* support OTG systems */
-       if (gadget_is_otg(cdev->gadget)) {
-               sourcesink_driver.descriptors = otg_desc;
-               sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
-       }
-
-       return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config);
-}
index 71ca193358b85c23a039e12bdead188425c0490c..919eaa9ae124a662b8f7d01dd1bb5b45ef315111 100644 (file)
@@ -20,7 +20,6 @@ void disable_endpoints(struct usb_composite_dev *cdev,
                struct usb_ep *iso_in, struct usb_ep *iso_out);
 
 /* configuration-specific linkup */
-int sourcesink_add(struct usb_composite_dev *cdev, bool autoresume);
 int loopback_add(struct usb_composite_dev *cdev, bool autoresume);
 
 #endif /* __G_ZERO_H */
index 6bf4c06113656905b3042c346ede6c08f8a26deb..ddf37cfdad979f53d7291b2be261c6fb2c6acdcb 100644 (file)
@@ -139,10 +139,13 @@ const struct usb_descriptor_header *otg_desc[] = {
 /* default serial number takes at least two packets */
 static char serial[] = "0123456789.0123456789.0123456789";
 
+#define USB_GZERO_SS_DESC      (USB_GADGET_FIRST_AVAIL_IDX + 0)
+
 static struct usb_string strings_dev[] = {
        [USB_GADGET_MANUFACTURER_IDX].s = "",
        [USB_GADGET_PRODUCT_IDX].s = longname,
        [USB_GADGET_SERIAL_IDX].s = serial,
+       [USB_GZERO_SS_DESC].s   = "source and sink data",
        {  }                    /* end of list */
 };
 
@@ -251,6 +254,15 @@ static void zero_resume(struct usb_composite_dev *cdev)
 
 /*-------------------------------------------------------------------------*/
 
+static struct usb_configuration sourcesink_driver = {
+       .label                  = "source/sink",
+       .strings                = sourcesink_strings,
+       .setup                  = ss_config_setup,
+       .bConfigurationValue    = 3,
+       .bmAttributes           = USB_CONFIG_ATT_SELFPOWER,
+       /* .iConfiguration      = DYNAMIC */
+};
+
 static int __init zero_bind(struct usb_composite_dev *cdev)
 {
        int                     status;
@@ -268,14 +280,29 @@ static int __init zero_bind(struct usb_composite_dev *cdev)
 
        setup_timer(&autoresume_timer, zero_autoresume, (unsigned long) cdev);
 
+       sourcesink_driver.iConfiguration = strings_dev[USB_GZERO_SS_DESC].id;
+       /* support autoresume for remote wakeup testing */
+       sourcesink_driver.bmAttributes &= ~USB_CONFIG_ATT_WAKEUP;
+       sourcesink_driver.descriptors = NULL;
+       if (autoresume)
+               sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
+
+       /* support OTG systems */
+       if (gadget_is_otg(cdev->gadget)) {
+               sourcesink_driver.descriptors = otg_desc;
+               sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
+       }
+
        /* Register primary, then secondary configuration.  Note that
         * SH3 only allows one config...
         */
        if (loopdefault) {
                loopback_add(cdev, autoresume != 0);
-               sourcesink_add(cdev, autoresume != 0);
+               usb_add_config(cdev, &sourcesink_driver,
+                               sourcesink_bind_config);
        } else {
-               sourcesink_add(cdev, autoresume != 0);
+               usb_add_config(cdev, &sourcesink_driver,
+                               sourcesink_bind_config);
                loopback_add(cdev, autoresume != 0);
        }