This patch pushes the iProduct module argument from composite into each gadget. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> --- drivers/usb/gadget/acm_ms.c | 3 ++- drivers/usb/gadget/audio.c | 2 ++ drivers/usb/gadget/cdc2.c | 2 ++ drivers/usb/gadget/composite.c | 13 ++----------- drivers/usb/gadget/ether.c | 2 ++ drivers/usb/gadget/g_ffs.c | 4 ++++ drivers/usb/gadget/gmidi.c | 2 ++ drivers/usb/gadget/hid.c | 2 ++ drivers/usb/gadget/mass_storage.c | 5 +++++ drivers/usb/gadget/multi.c | 7 +++++-- drivers/usb/gadget/ncm.c | 2 ++ drivers/usb/gadget/nokia.c | 2 ++ drivers/usb/gadget/printer.c | 3 +++ drivers/usb/gadget/serial.c | 2 ++ drivers/usb/gadget/tcm_usb_gadget.c | 2 ++ drivers/usb/gadget/webcam.c | 2 ++ drivers/usb/gadget/zero.c | 2 ++ include/linux/usb/composite.h | 6 +++++- 18 files changed, 48 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c index 6986d4c..e18e7cf 100644 --- a/drivers/usb/gadget/acm_ms.c +++ b/drivers/usb/gadget/acm_ms.c @@ -64,7 +64,6 @@ static struct usb_device_descriptor device_desc = { .idVendor = cpu_to_le16(ACM_MS_VENDOR_NUM), .idProduct = cpu_to_le16(ACM_MS_PRODUCT_NUM), /* .bcdDevice = f(hardware) */ - /* .iProduct = DYNAMIC */ /* NO SERIAL NUMBER */ /*.bNumConfigurations = DYNAMIC*/ }; @@ -209,6 +208,8 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev) else strings_dev[STRING_MANUFACTURER_IDX].s = composite_default_mfr(gadget); + if (iProduct) + strings_dev[STRING_PRODUCT_IDX].s = iProduct; dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c index f9b6a82..e1dc15f 100644 --- a/drivers/usb/gadget/audio.c +++ b/drivers/usb/gadget/audio.c @@ -181,6 +181,8 @@ static int __init audio_bind(struct usb_composite_dev *cdev) else strings_dev[STRING_MANUFACTURER_IDX].s = composite_default_mfr(cdev->gadget); + if (iProduct) + strings_dev[STRING_PRODUCT_IDX].s = iProduct; INFO(cdev, "%s, version: %s\n", DRIVER_DESC, DRIVER_VERSION); return 0; diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c index 708f17c..766ca2d 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c @@ -207,6 +207,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) else strings_dev[STRING_MANUFACTURER_IDX].s = composite_default_mfr(gadget); + if (iProduct) + strings_dev[STRING_PRODUCT_IDX].s = iProduct; USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(device_desc); dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 2ce92c9..487e912 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -28,15 +28,6 @@ * with the relevant device-wide data. */ -/* Some systems will need runtime overrides for the product identifiers - * published in the device descriptor, either numbers or strings or both. - * String parameters are in UTF-8 (superset of ASCII's 7 bit characters). - */ - -static char *iProduct; -module_param(iProduct, charp, S_IRUGO); -MODULE_PARM_DESC(iProduct, "USB Product string"); - /*-------------------------------------------------------------------------*/ /** * next_ep_desc() - advance to the next EP descriptor @@ -913,7 +904,7 @@ static int get_string(struct usb_composite_dev *cdev, if (cdev->manufacturer_override == id) str = cdriver->iManufacturer; else if (cdev->product_override == id) - str = iProduct ?: cdriver->iProduct; + str = cdriver->iProduct; else if (cdev->serial_override == id) str = cdriver->iSerialNumber; else @@ -1458,7 +1449,7 @@ static int composite_bind(struct usb_gadget *gadget, cdev->manufacturer_override = override_id(cdev, &cdev->desc.iManufacturer); - if (iProduct || (!cdev->desc.iProduct && cdriver->iProduct)) + if (!cdev->desc.iProduct && cdriver->iProduct) cdev->product_override = override_id(cdev, &cdev->desc.iProduct); diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 513c309..09d4156 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -367,6 +367,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) else strings_dev[STRING_MANUFACTURER_IDX].s = composite_default_mfr(gadget); + if (iProduct) + strings_dev[STRING_PRODUCT_IDX].s = iProduct; dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c index 0960987..da9484a 100644 --- a/drivers/usb/gadget/g_ffs.c +++ b/drivers/usb/gadget/g_ffs.c @@ -127,6 +127,7 @@ enum { #endif GFFS_SERIAL_IDX, GFFS_MFR_IDX, + GFFS_PRODUCT_IDX, }; /* String IDs are assigned dynamically */ @@ -142,6 +143,7 @@ static struct usb_string gfs_strings[] = { #endif [GFFS_SERIAL_IDX].s = "", [GFFS_MFR_IDX].s = "", + [GFFS_PRODUCT_IDX].s = "", { } /* end of list */ }; @@ -407,6 +409,8 @@ static int gfs_bind(struct usb_composite_dev *cdev) else gfs_strings[GFFS_MFR_IDX].s = composite_default_mfr(cdev->gadget); + if (iProduct) + gfs_strings[GFFS_PRODUCT_IDX].s = iProduct; return 0; error_unbind: diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 1417262..51fb461 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c @@ -172,6 +172,8 @@ static int __init midi_bind(struct usb_composite_dev *cdev) } if (iManufacturer) strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer; + if (iProduct) + strings_dev[STRING_PRODUCT_IDX].s = iProduct; pr_info("%s\n", longname); return 0; diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c index 2a6f278..6839f55 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c @@ -193,6 +193,8 @@ static int __init hid_bind(struct usb_composite_dev *cdev) else strings_dev[STRING_MANUFACTURER_IDX].s = composite_default_mfr(gadget); + if (iProduct) + strings_dev[STRING_PRODUCT_IDX].s = iProduct; dev_info(&gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); diff --git a/drivers/usb/gadget/mass_storage.c b/drivers/usb/gadget/mass_storage.c index bc5bd95..769195a 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -84,9 +84,12 @@ static const struct usb_descriptor_header *otg_desc[] = { #define STRING_PRODUCT_SERIAL 0 #define STRING_PRODUCT_MFR 1 +#define STRING_PRODUCT_NAME 2 + static struct usb_string strings_dev[] = { [STRING_PRODUCT_SERIAL].s = "", [STRING_PRODUCT_MFR].s = "", + [STRING_PRODUCT_NAME].s = "", { } /* end of list */ }; @@ -176,6 +179,8 @@ static int __init msg_bind(struct usb_composite_dev *cdev) else strings_dev[STRING_PRODUCT_MFR].s = composite_default_mfr(cdev->gadget); + if (iProduct) + strings_dev[STRING_PRODUCT_NAME].s = iProduct; dev_info(&cdev->gadget->dev, DRIVER_DESC ", version: " DRIVER_VERSION "\n"); diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c index 952fc1b..847635b 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -116,6 +116,7 @@ enum { #endif MULTI_STRING_SERIAL_IDX, MULTI_STRING_MFR_IDX, + MULTI_STRING_PRODUCT_IDX, }; static struct usb_string strings_dev[] = { @@ -127,6 +128,7 @@ static struct usb_string strings_dev[] = { #endif [MULTI_STRING_SERIAL_IDX].s = "", [MULTI_STRING_MFR_IDX].s = "", + [MULTI_STRING_PRODUCT_IDX].s = DRIVER_DESC, { } /* end of list */ }; @@ -316,13 +318,15 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) device_desc.iSerialNumber = strings_dev[MULTI_STRING_SERIAL_IDX].id; } + device_desc.iProduct = strings_dev[MULTI_STRING_PRODUCT_IDX].id; device_desc.iManufacturer = strings_dev[MULTI_STRING_MFR_IDX].id; if (iManufacturer) strings_dev[MULTI_STRING_MFR_IDX].s = iManufacturer; else strings_dev[MULTI_STRING_MFR_IDX].s = composite_default_mfr(gadget); - + if (iProduct) + strings_dev[MULTI_STRING_PRODUCT_IDX].s = iProduct; /* we're done */ dev_info(&gadget->dev, DRIVER_DESC "\n"); fsg_common_put(&fsg_common); @@ -359,7 +363,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, }; diff --git a/drivers/usb/gadget/ncm.c b/drivers/usb/gadget/ncm.c index 6f8c270..82f0173 100644 --- a/drivers/usb/gadget/ncm.c +++ b/drivers/usb/gadget/ncm.c @@ -196,6 +196,8 @@ static int __init gncm_bind(struct usb_composite_dev *cdev) else strings_dev[STRING_MANUFACTURER_IDX].s = composite_default_mfr(gadget); + if (iProduct) + strings_dev[STRING_PRODUCT_IDX].s = iProduct; dev_info(&gadget->dev, "%s\n", DRIVER_DESC); diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c index e382b52..f194e70 100644 --- a/drivers/usb/gadget/nokia.c +++ b/drivers/usb/gadget/nokia.c @@ -207,6 +207,8 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) } if (iManufacturer) strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer; + if (iProduct) + strings_dev[STRING_PRODUCT_IDX].s = iProduct; dev_info(&gadget->dev, "%s\n", NOKIA_LONG_NAME); diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 0f63c08..a719af3 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c @@ -1268,6 +1268,9 @@ static int __init printer_bind(struct usb_composite_dev *cdev) else strings[STRING_MANUFACTURER].s = composite_default_mfr(cdev->gadget); + if (iProduct) + strings[STRING_PRODUCT].s = iProduct; + return 0; } diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 8bffcd6..f842eea 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c @@ -217,6 +217,8 @@ static int __init gs_bind(struct usb_composite_dev *cdev) else strings_dev[STRING_MANUFACTURER_IDX].s = composite_default_mfr(gadget); + if (iProduct) + strings_dev[STRING_PRODUCT_IDX].s = iProduct; INFO(cdev, "%s\n", GS_VERSION_NAME); diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index f68cac3..7de60d8 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c @@ -2446,6 +2446,8 @@ static int usb_target_bind(struct usb_composite_dev *cdev) usbg_us_strings[USB_G_STR_SERIAL].s = iSerialNumber; if (iManufacturer) usbg_us_strings[USB_G_STR_MANUFACTOR].s = iManufacturer; + if (iProduct) + usbg_us_strings[USB_G_STR_PRODUCT].s = iProduct; return 0; } diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c index e9fdee1..40eb91e 100644 --- a/drivers/usb/gadget/webcam.c +++ b/drivers/usb/gadget/webcam.c @@ -381,6 +381,8 @@ webcam_bind(struct usb_composite_dev *cdev) } if (iManufacturer) webcam_strings[STRING_MANUFACTURER_IDX].s = iManufacturer; + if (iProduct) + webcam_strings[STRING_PRODUCT_IDX].s = iProduct; INFO(cdev, "Webcam Video Gadget\n"); return 0; diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index 9679d53..b791c28 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c @@ -311,6 +311,8 @@ static int __init zero_bind(struct usb_composite_dev *cdev) else strings_dev[STRING_MANUFACTURER_IDX].s = composite_default_mfr(gadget); + if (iProduct) + strings_dev[STRING_PRODUCT_IDX].s = iProduct; INFO(cdev, "%s, version: " DRIVER_VERSION "\n", longname); return 0; diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index b951cb3..59cf2dd 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -405,7 +405,11 @@ extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); \ static char *iManufacturer; \ module_param(iManufacturer, charp, S_IRUGO); \ - MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string") + MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); \ + \ + static char *iProduct; \ + module_param(iProduct, charp, S_IRUGO); \ + MODULE_PARM_DESC(iProduct, "USB Product string") #define USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(__usb_desc) \ do { \ -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html