]> git.openfabrics.org - ~shefty/rdma-dev.git/blobdiff - drivers/usb/gadget/tcm_usb_gadget.c
Merge branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/git/nab/target...
[~shefty/rdma-dev.git] / drivers / usb / gadget / tcm_usb_gadget.c
index 5662d6e927c010407a46bfd889f44600419c1d4c..97e68b38cfdf5ebab332f1ae0f670ed7b7edc56b 100644 (file)
 #include <target/configfs_macros.h>
 #include <asm/unaligned.h>
 
-#include "usbstring.c"
-#include "epautoconf.c"
-#include "config.c"
-#include "composite.c"
-
 #include "tcm_usb_gadget.h"
 
+USB_GADGET_COMPOSITE_OPTIONS();
+
 static struct target_fabric_configfs *usbg_fabric_configfs;
 
 static inline struct f_uas *to_f_uas(struct usb_function *f)
@@ -1964,7 +1961,6 @@ static struct usb_interface_descriptor bot_intf_desc = {
        .bInterfaceClass =      USB_CLASS_MASS_STORAGE,
        .bInterfaceSubClass =   USB_SC_SCSI,
        .bInterfaceProtocol =   USB_PR_BULK,
-       .iInterface =           USB_G_STR_INT_UAS,
 };
 
 static struct usb_interface_descriptor uasp_intf_desc = {
@@ -1975,7 +1971,6 @@ static struct usb_interface_descriptor uasp_intf_desc = {
        .bInterfaceClass =      USB_CLASS_MASS_STORAGE,
        .bInterfaceSubClass =   USB_SC_SCSI,
        .bInterfaceProtocol =   USB_PR_UAS,
-       .iInterface =           USB_G_STR_INT_BBB,
 };
 
 static struct usb_endpoint_descriptor uasp_bi_desc = {
@@ -2196,20 +2191,16 @@ static struct usb_device_descriptor usbg_device_desc = {
        .bDeviceClass =         USB_CLASS_PER_INTERFACE,
        .idVendor =             cpu_to_le16(UAS_VENDOR_ID),
        .idProduct =            cpu_to_le16(UAS_PRODUCT_ID),
-       .iManufacturer =        USB_G_STR_MANUFACTOR,
-       .iProduct =             USB_G_STR_PRODUCT,
-       .iSerialNumber =        USB_G_STR_SERIAL,
-
        .bNumConfigurations =   1,
 };
 
 static struct usb_string       usbg_us_strings[] = {
-       { USB_G_STR_MANUFACTOR, "Target Manufactor"},
-       { USB_G_STR_PRODUCT,    "Target Product"},
-       { USB_G_STR_SERIAL,     "000000000001"},
-       { USB_G_STR_CONFIG,     "default config"},
-       { USB_G_STR_INT_UAS,    "USB Attached SCSI"},
-       { USB_G_STR_INT_BBB,    "Bulk Only Transport"},
+       [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",
        { },
 };
 
@@ -2231,7 +2222,6 @@ static int guas_unbind(struct usb_composite_dev *cdev)
 static struct usb_configuration usbg_config_driver = {
        .label                  = "Linux Target",
        .bConfigurationValue    = 1,
-       .iConfiguration         = USB_G_STR_CONFIG,
        .bmAttributes           = USB_CONFIG_ATT_SELFPOWER,
 };
 
@@ -2404,6 +2394,9 @@ static int usbg_cfg_bind(struct usb_configuration *c)
        fu->function.disable = usbg_disable;
        fu->tpg = the_only_tpg_I_currently_have;
 
+       bot_intf_desc.iInterface = usbg_us_strings[USB_G_STR_INT_BBB].id;
+       uasp_intf_desc.iInterface = usbg_us_strings[USB_G_STR_INT_UAS].id;
+
        ret = usb_add_function(c, &fu->function);
        if (ret)
                goto err;
@@ -2418,22 +2411,38 @@ static int usb_target_bind(struct usb_composite_dev *cdev)
 {
        int ret;
 
+       ret = usb_string_ids_tab(cdev, usbg_us_strings);
+       if (ret)
+               return ret;
+
+       usbg_device_desc.iManufacturer =
+               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;
+
        ret = usb_add_config(cdev, &usbg_config_driver,
                        usbg_cfg_bind);
+       if (ret)
+               return ret;
+       usb_composite_overwrite_options(cdev, &coverwrite);
        return 0;
 }
 
-static struct usb_composite_driver usbg_driver = {
+static __refdata struct usb_composite_driver usbg_driver = {
        .name           = "g_target",
        .dev            = &usbg_device_desc,
        .strings        = usbg_strings,
        .max_speed      = USB_SPEED_SUPER,
+       .bind           = usb_target_bind,
        .unbind         = guas_unbind,
 };
 
 static int usbg_attach(struct usbg_tpg *tpg)
 {
-       return usb_composite_probe(&usbg_driver, usb_target_bind);
+       return usb_composite_probe(&usbg_driver);
 }
 
 static void usbg_detach(struct usbg_tpg *tpg)