This patch pushes the iManufacturer module argument from composite into each gadget. Once the user uses the module paramter, the string is overwritten with the final value. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> --- drivers/usb/gadget/acm_ms.c | 4 +++- drivers/usb/gadget/audio.c | 3 ++- drivers/usb/gadget/cdc2.c | 3 ++- drivers/usb/gadget/composite.c | 11 +++-------- drivers/usb/gadget/ether.c | 3 ++- drivers/usb/gadget/g_ffs.c | 6 ++++++ drivers/usb/gadget/gmidi.c | 3 ++- drivers/usb/gadget/hid.c | 3 ++- drivers/usb/gadget/mass_storage.c | 7 +++++++ drivers/usb/gadget/multi.c | 7 +++++++ drivers/usb/gadget/ncm.c | 2 ++ drivers/usb/gadget/nokia.c | 2 ++ drivers/usb/gadget/printer.c | 2 ++ drivers/usb/gadget/serial.c | 3 +++ drivers/usb/gadget/tcm_usb_gadget.c | 3 +++ drivers/usb/gadget/webcam.c | 3 +++ drivers/usb/gadget/zero.c | 2 ++ include/linux/usb/composite.h | 6 +++++- 18 files changed, 58 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/acm_ms.c b/drivers/usb/gadget/acm_ms.c index 63ef563..51fc568 100644 --- a/drivers/usb/gadget/acm_ms.c +++ b/drivers/usb/gadget/acm_ms.c @@ -65,7 +65,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) */ - /* .iManufacturer = DYNAMIC */ /* .iProduct = DYNAMIC */ /* NO SERIAL NUMBER */ /*.bNumConfigurations = DYNAMIC*/ @@ -212,6 +211,9 @@ static int __init acm_ms_bind(struct usb_composite_dev *cdev) device_desc.iSerialNumber = strings_dev[STRING_PRODUCT_SERIAL].id; } + if (iManufacturer) + strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer; + dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n", DRIVER_DESC); fsg_common_put(&fsg_common); diff --git a/drivers/usb/gadget/audio.c b/drivers/usb/gadget/audio.c index 336206d..d598e32 100644 --- a/drivers/usb/gadget/audio.c +++ b/drivers/usb/gadget/audio.c @@ -100,7 +100,6 @@ static struct usb_device_descriptor device_desc = { .idVendor = __constant_cpu_to_le16(AUDIO_VENDOR_NUM), .idProduct = __constant_cpu_to_le16(AUDIO_PRODUCT_NUM), /* .bcdDevice = f(hardware) */ - /* .iManufacturer = DYNAMIC */ /* .iProduct = DYNAMIC */ /* NO SERIAL NUMBER */ .bNumConfigurations = 1, @@ -184,6 +183,8 @@ static int __init audio_bind(struct usb_composite_dev *cdev) device_desc.iSerialNumber = strings_dev[STRING_PRODUCT_SERIAL].id; } + if (iManufacturer) + strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer; 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 692f817..390a7e4 100644 --- a/drivers/usb/gadget/cdc2.c +++ b/drivers/usb/gadget/cdc2.c @@ -67,7 +67,6 @@ static struct usb_device_descriptor device_desc = { .idVendor = cpu_to_le16(CDC_VENDOR_NUM), .idProduct = cpu_to_le16(CDC_PRODUCT_NUM), /* .bcdDevice = f(hardware) */ - /* .iManufacturer = DYNAMIC */ /* .iProduct = DYNAMIC */ /* NO SERIAL NUMBER */ .bNumConfigurations = 1, @@ -211,6 +210,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev) device_desc.iSerialNumber = strings_dev[STRING_PRODUCT_SERIAL].id; } + if (iManufacturer) + strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer; 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 506be03..a89f95d 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -32,9 +32,6 @@ * 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 *iManufacturer; -module_param(iManufacturer, charp, S_IRUGO); -MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); static char *iProduct; module_param(iProduct, charp, S_IRUGO); @@ -916,8 +913,7 @@ static int get_string(struct usb_composite_dev *cdev, * check if the string has not been overridden. */ if (cdev->manufacturer_override == id) - str = iManufacturer ?: cdriver->iManufacturer ?: - composite_manufacturer; + str = cdriver->iManufacturer ?: composite_manufacturer; else if (cdev->product_override == id) str = iProduct ?: cdriver->iProduct; else if (cdev->serial_override == id) @@ -1460,9 +1456,8 @@ static int composite_bind(struct usb_gadget *gadget, cdev->desc = *cdriver->dev; /* string overrides */ - if (iManufacturer || !cdev->desc.iManufacturer) { - if (!iManufacturer && !cdriver->iManufacturer && - !*composite_manufacturer) + if (!cdev->desc.iManufacturer) { + if (!cdriver->iManufacturer) snprintf(composite_manufacturer, sizeof composite_manufacturer, "%s %s with %s", diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index a4d2d9f..fc7ad19 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -172,7 +172,6 @@ static struct usb_device_descriptor device_desc = { .idVendor = cpu_to_le16 (CDC_VENDOR_NUM), .idProduct = cpu_to_le16 (CDC_PRODUCT_NUM), /* .bcdDevice = f(hardware) */ - /* .iManufacturer = DYNAMIC */ /* .iProduct = DYNAMIC */ /* NO SERIAL NUMBER */ .bNumConfigurations = 1, @@ -372,6 +371,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev) device_desc.iSerialNumber = strings_dev[STRING_PRODUCT_SERIAL].id; } + if (iManufacturer) + strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer; 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 948414d..b8a23fb 100644 --- a/drivers/usb/gadget/g_ffs.c +++ b/drivers/usb/gadget/g_ffs.c @@ -127,6 +127,7 @@ enum { GFFS_FFS_ECM_GEN_IDX, #endif GFFS_SERIAL_IDX, + GFFS_MFR_IDX, }; /* String IDs are assigned dynamically */ @@ -141,6 +142,7 @@ static struct usb_string gfs_strings[] = { [GFFS_FFS_ECM_IDX].s = "FunctionFS", #endif [GFFS_SERIAL_IDX].s = "", + [GFFS_MFR_IDX].s = "", { } /* end of list */ }; @@ -400,6 +402,10 @@ static int gfs_bind(struct usb_composite_dev *cdev) gfs_strings[GFFS_SERIAL_IDX].s = iSerialNumber; gfs_dev_desc.iSerialNumber = gfs_strings[GFFS_SERIAL_IDX].id; } + if (iManufacturer) { + gfs_strings[GFFS_MFR_IDX].s = iManufacturer; + gfs_dev_desc.iManufacturer = gfs_strings[GFFS_MFR_IDX].id; + } return 0; diff --git a/drivers/usb/gadget/gmidi.c b/drivers/usb/gadget/gmidi.c index 90a169f..e5e9ea3 100644 --- a/drivers/usb/gadget/gmidi.c +++ b/drivers/usb/gadget/gmidi.c @@ -96,7 +96,6 @@ static struct usb_device_descriptor device_desc = { .bDeviceClass = USB_CLASS_PER_INTERFACE, .idVendor = __constant_cpu_to_le16(DRIVER_VENDOR_NUM), .idProduct = __constant_cpu_to_le16(DRIVER_PRODUCT_NUM), - /* .iManufacturer = DYNAMIC */ /* .iProduct = DYNAMIC */ .bNumConfigurations = 1, }; @@ -172,6 +171,8 @@ static int __init midi_bind(struct usb_composite_dev *cdev) strings_dev[STRING_SERIAL_IDX].s = iSerialNumber; device_desc.iSerialNumber = strings_dev[STRING_SERIAL_IDX].id; } + if (iManufacturer) + strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer; pr_info("%s\n", longname); return 0; diff --git a/drivers/usb/gadget/hid.c b/drivers/usb/gadget/hid.c index d47ca92..5c81c3f 100644 --- a/drivers/usb/gadget/hid.c +++ b/drivers/usb/gadget/hid.c @@ -68,7 +68,6 @@ static struct usb_device_descriptor device_desc = { .idVendor = cpu_to_le16(HIDG_VENDOR_NUM), .idProduct = cpu_to_le16(HIDG_PRODUCT_NUM), /* .bcdDevice = f(hardware) */ - /* .iManufacturer = DYNAMIC */ /* .iProduct = DYNAMIC */ /* NO SERIAL NUMBER */ .bNumConfigurations = 1, @@ -197,6 +196,8 @@ static int __init hid_bind(struct usb_composite_dev *cdev) device_desc.iSerialNumber = strings_dev[STRING_PRODUCT_SERIAL].id; } + if (iManufacturer) + strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer; 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 d52a29a..6d586fe 100644 --- a/drivers/usb/gadget/mass_storage.c +++ b/drivers/usb/gadget/mass_storage.c @@ -84,8 +84,10 @@ static const struct usb_descriptor_header *otg_desc[] = { }; #define STRING_PRODUCT_SERIAL 0 +#define STRING_PRODUCT_MFR 1 static struct usb_string strings_dev[] = { [STRING_PRODUCT_SERIAL].s = "", + [STRING_PRODUCT_MFR].s = "", { } /* end of list */ }; @@ -169,6 +171,11 @@ static int __init msg_bind(struct usb_composite_dev *cdev) msg_device_desc.iSerialNumber = strings_dev[STRING_PRODUCT_SERIAL].id; } + if (iManufacturer) { + strings_dev[STRING_PRODUCT_MFR].s = iManufacturer; + msg_device_desc.iManufacturer = + strings_dev[STRING_PRODUCT_MFR].id; + } 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 5205882..d77fdc5 100644 --- a/drivers/usb/gadget/multi.c +++ b/drivers/usb/gadget/multi.c @@ -116,6 +116,7 @@ enum { MULTI_STRING_CDC_CONFIG_IDX, #endif MULTI_STRING_SERIAL_IDX, + MULTI_STRING_MFR_IDX, }; static struct usb_string strings_dev[] = { @@ -126,6 +127,7 @@ static struct usb_string strings_dev[] = { [MULTI_STRING_CDC_CONFIG_IDX].s = "Multifunction with CDC ECM", #endif [MULTI_STRING_SERIAL_IDX].s = "", + [MULTI_STRING_MFR_IDX].s = "", { } /* end of list */ }; @@ -315,6 +317,11 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) device_desc.iSerialNumber = strings_dev[MULTI_STRING_SERIAL_IDX].id; } + if (iManufacturer) { + strings_dev[MULTI_STRING_MFR_IDX].s = iManufacturer; + device_desc.iManufacturer = + strings_dev[MULTI_STRING_MFR_IDX].id; + } /* we're done */ dev_info(&gadget->dev, DRIVER_DESC "\n"); diff --git a/drivers/usb/gadget/ncm.c b/drivers/usb/gadget/ncm.c index 4438715..c1dca2c 100644 --- a/drivers/usb/gadget/ncm.c +++ b/drivers/usb/gadget/ncm.c @@ -200,6 +200,8 @@ static int __init gncm_bind(struct usb_composite_dev *cdev) device_desc.iSerialNumber = strings_dev[STRING_SERIAL_IDX].id; } + if (iManufacturer) + strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer; dev_info(&gadget->dev, "%s\n", DRIVER_DESC); diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c index c6b61dc..1c8d67b 100644 --- a/drivers/usb/gadget/nokia.c +++ b/drivers/usb/gadget/nokia.c @@ -206,6 +206,8 @@ static int __init nokia_bind(struct usb_composite_dev *cdev) device_desc.iSerialNumber = strings_dev[STRING_SERIAL_IDX].id; } + if (iManufacturer) + strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer; dev_info(&gadget->dev, "%s\n", NOKIA_LONG_NAME); diff --git a/drivers/usb/gadget/printer.c b/drivers/usb/gadget/printer.c index 169de0a..c620123 100644 --- a/drivers/usb/gadget/printer.c +++ b/drivers/usb/gadget/printer.c @@ -1267,6 +1267,8 @@ static int __init printer_bind(struct usb_composite_dev *cdev) USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(device_desc); if (iSerialNumber) strings[STRING_SERIALNUM].s = iSerialNumber; + if (iManufacturer) + strings[STRING_MANUFACTURER].s = iManufacturer; return 0; } diff --git a/drivers/usb/gadget/serial.c b/drivers/usb/gadget/serial.c index 5d02f67..31da904 100644 --- a/drivers/usb/gadget/serial.c +++ b/drivers/usb/gadget/serial.c @@ -220,6 +220,9 @@ static int __init gs_bind(struct usb_composite_dev *cdev) strings_dev[STRING_SERIAL_IDX].s = iSerialNumber; device_desc.iSerialNumber = strings_dev[STRING_SERIAL_IDX].id; } + if (iManufacturer) + strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer; + INFO(cdev, "%s\n", GS_VERSION_NAME); return 0; diff --git a/drivers/usb/gadget/tcm_usb_gadget.c b/drivers/usb/gadget/tcm_usb_gadget.c index 0d74d34..f68cac3 100644 --- a/drivers/usb/gadget/tcm_usb_gadget.c +++ b/drivers/usb/gadget/tcm_usb_gadget.c @@ -2444,6 +2444,9 @@ static int usb_target_bind(struct usb_composite_dev *cdev) USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(usbg_device_desc); if (iSerialNumber) usbg_us_strings[USB_G_STR_SERIAL].s = iSerialNumber; + if (iManufacturer) + usbg_us_strings[USB_G_STR_MANUFACTOR].s = iManufacturer; + return 0; } diff --git a/drivers/usb/gadget/webcam.c b/drivers/usb/gadget/webcam.c index 9c42c17..e9fdee1 100644 --- a/drivers/usb/gadget/webcam.c +++ b/drivers/usb/gadget/webcam.c @@ -379,6 +379,9 @@ webcam_bind(struct usb_composite_dev *cdev) webcam_device_descriptor.iSerialNumber = webcam_strings[STRING_SERIAL_IDX].id; } + if (iManufacturer) + webcam_strings[STRING_MANUFACTURER_IDX].s = iManufacturer; + INFO(cdev, "Webcam Video Gadget\n"); return 0; diff --git a/drivers/usb/gadget/zero.c b/drivers/usb/gadget/zero.c index f9c53c8..b38c141 100644 --- a/drivers/usb/gadget/zero.c +++ b/drivers/usb/gadget/zero.c @@ -309,6 +309,8 @@ static int __init zero_bind(struct usb_composite_dev *cdev) USB_GADGET_COMPOSITE_OVERWRITE_OPTIONS(device_desc); if (iSerialNumber) strings_dev[STRING_SERIAL_IDX].s = iSerialNumber; + if (iManufacturer) + strings_dev[STRING_MANUFACTURER_IDX].s = iManufacturer; INFO(cdev, "%s, version: " DRIVER_VERSION "\n", longname); diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index eb13097..b951cb3 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -401,7 +401,11 @@ extern int usb_string_ids_n(struct usb_composite_dev *c, unsigned n); \ static char *iSerialNumber; \ module_param(iSerialNumber, charp, S_IRUGO); \ - MODULE_PARM_DESC(iSerialNumber, "SerialNumber string") + MODULE_PARM_DESC(iSerialNumber, "SerialNumber string"); \ + \ + static char *iManufacturer; \ + module_param(iManufacturer, charp, S_IRUGO); \ + MODULE_PARM_DESC(iManufacturer, "USB Manufacturer 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