Skip to content

Commit 7be04b2

Browse files
Sebastian Andrzej Siewiorgregkh
Sebastian Andrzej Siewior
authored andcommitted
usb: gadget: initialize the strings in tcm_usb_gadget properly
commit 18786da upstream. I have no idea what I've been thinking while I was doing this in the first place. Now the strings are initialized properly and reported by lsusb. Acked-by: Michal Nazarewicz <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Felipe Balbi <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 458cf14 commit 7be04b2

File tree

2 files changed

+28
-19
lines changed

2 files changed

+28
-19
lines changed

drivers/usb/gadget/tcm_usb_gadget.c

+20-13
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,6 @@ static struct usb_interface_descriptor bot_intf_desc = {
19831983
.bInterfaceClass = USB_CLASS_MASS_STORAGE,
19841984
.bInterfaceSubClass = USB_SC_SCSI,
19851985
.bInterfaceProtocol = USB_PR_BULK,
1986-
.iInterface = USB_G_STR_INT_UAS,
19871986
};
19881987

19891988
static struct usb_interface_descriptor uasp_intf_desc = {
@@ -1994,7 +1993,6 @@ static struct usb_interface_descriptor uasp_intf_desc = {
19941993
.bInterfaceClass = USB_CLASS_MASS_STORAGE,
19951994
.bInterfaceSubClass = USB_SC_SCSI,
19961995
.bInterfaceProtocol = USB_PR_UAS,
1997-
.iInterface = USB_G_STR_INT_BBB,
19981996
};
19991997

20001998
static struct usb_endpoint_descriptor uasp_bi_desc = {
@@ -2215,20 +2213,16 @@ static struct usb_device_descriptor usbg_device_desc = {
22152213
.bDeviceClass = USB_CLASS_PER_INTERFACE,
22162214
.idVendor = cpu_to_le16(UAS_VENDOR_ID),
22172215
.idProduct = cpu_to_le16(UAS_PRODUCT_ID),
2218-
.iManufacturer = USB_G_STR_MANUFACTOR,
2219-
.iProduct = USB_G_STR_PRODUCT,
2220-
.iSerialNumber = USB_G_STR_SERIAL,
2221-
22222216
.bNumConfigurations = 1,
22232217
};
22242218

22252219
static struct usb_string usbg_us_strings[] = {
2226-
{ USB_G_STR_MANUFACTOR, "Target Manufactor"},
2227-
{ USB_G_STR_PRODUCT, "Target Product"},
2228-
{ USB_G_STR_SERIAL, "000000000001"},
2229-
{ USB_G_STR_CONFIG, "default config"},
2230-
{ USB_G_STR_INT_UAS, "USB Attached SCSI"},
2231-
{ USB_G_STR_INT_BBB, "Bulk Only Transport"},
2220+
[USB_G_STR_MANUFACTOR].s = "Target Manufactor",
2221+
[USB_G_STR_PRODUCT].s = "Target Product",
2222+
[USB_G_STR_SERIAL].s = "000000000001",
2223+
[USB_G_STR_CONFIG].s = "default config",
2224+
[USB_G_STR_INT_UAS].s = "USB Attached SCSI",
2225+
[USB_G_STR_INT_BBB].s = "Bulk Only Transport",
22322226
{ },
22332227
};
22342228

@@ -2250,7 +2244,6 @@ static int guas_unbind(struct usb_composite_dev *cdev)
22502244
static struct usb_configuration usbg_config_driver = {
22512245
.label = "Linux Target",
22522246
.bConfigurationValue = 1,
2253-
.iConfiguration = USB_G_STR_CONFIG,
22542247
.bmAttributes = USB_CONFIG_ATT_SELFPOWER,
22552248
};
22562249

@@ -2423,6 +2416,9 @@ static int usbg_cfg_bind(struct usb_configuration *c)
24232416
fu->function.disable = usbg_disable;
24242417
fu->tpg = the_only_tpg_I_currently_have;
24252418

2419+
bot_intf_desc.iInterface = usbg_us_strings[USB_G_STR_INT_BBB].id;
2420+
uasp_intf_desc.iInterface = usbg_us_strings[USB_G_STR_INT_UAS].id;
2421+
24262422
ret = usb_add_function(c, &fu->function);
24272423
if (ret)
24282424
goto err;
@@ -2437,6 +2433,17 @@ static int usb_target_bind(struct usb_composite_dev *cdev)
24372433
{
24382434
int ret;
24392435

2436+
ret = usb_string_ids_tab(cdev, usbg_us_strings);
2437+
if (ret)
2438+
return ret;
2439+
2440+
usbg_device_desc.iManufacturer =
2441+
usbg_us_strings[USB_G_STR_MANUFACTOR].id;
2442+
usbg_device_desc.iProduct = usbg_us_strings[USB_G_STR_PRODUCT].id;
2443+
usbg_device_desc.iSerialNumber = usbg_us_strings[USB_G_STR_SERIAL].id;
2444+
usbg_config_driver.iConfiguration =
2445+
usbg_us_strings[USB_G_STR_CONFIG].id;
2446+
24402447
ret = usb_add_config(cdev, &usbg_config_driver,
24412448
usbg_cfg_bind);
24422449
return 0;

drivers/usb/gadget/tcm_usb_gadget.h

+8-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
#define UASP_SS_EP_COMP_LOG_STREAMS 4
1717
#define UASP_SS_EP_COMP_NUM_STREAMS (1 << UASP_SS_EP_COMP_LOG_STREAMS)
1818

19-
#define USB_G_STR_MANUFACTOR 1
20-
#define USB_G_STR_PRODUCT 2
21-
#define USB_G_STR_SERIAL 3
22-
#define USB_G_STR_CONFIG 4
23-
#define USB_G_STR_INT_UAS 5
24-
#define USB_G_STR_INT_BBB 6
19+
enum {
20+
USB_G_STR_MANUFACTOR,
21+
USB_G_STR_PRODUCT,
22+
USB_G_STR_SERIAL,
23+
USB_G_STR_CONFIG,
24+
USB_G_STR_INT_UAS,
25+
USB_G_STR_INT_BBB,
26+
};
2527

2628
#define USB_G_ALT_INT_BBB 0
2729
#define USB_G_ALT_INT_UAS 1

0 commit comments

Comments
 (0)