This patch pushes the iProduct module argument from composite into each gadget. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx> --- drivers/usb/gadget/composite.c | 21 +++++++++++---------- include/linux/usb/composite.h | 6 +++++- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 699de9c..f3e46a6 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -28,14 +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"); - static char composite_manufacturer[50]; /*-------------------------------------------------------------------------*/ @@ -914,7 +906,7 @@ static int get_string(struct usb_composite_dev *cdev, if (cdev->manufacturer_override == id) str = cdriver->iManufacturer ?: composite_manufacturer; else if (cdev->product_override == id) - str = iProduct ?: cdriver->iProduct; + str = cdriver->iProduct; else if (cdev->serial_override == id) str = cdriver->iSerialNumber; else @@ -1404,6 +1396,7 @@ static void update_unchanged_dev_desc(struct usb_device_descriptor *new, __le16 bcdDevice; u8 iSerialNumber; u8 iManufacturer; + u8 iProduct; /* * these variables may have been set in @@ -1414,6 +1407,7 @@ static void update_unchanged_dev_desc(struct usb_device_descriptor *new, bcdDevice = new->bcdDevice; iSerialNumber = new->iSerialNumber; iManufacturer = new->iManufacturer; + iProduct = new->iProduct; *new = *old; if (idVendor) @@ -1426,6 +1420,8 @@ static void update_unchanged_dev_desc(struct usb_device_descriptor *new, new->iSerialNumber = iSerialNumber; if (iManufacturer) new->iManufacturer = iManufacturer; + if (iProduct) + new->iProduct = iProduct; } static struct usb_composite_driver *to_cdriver(struct usb_gadget_driver *gdrv) @@ -1499,7 +1495,7 @@ static int composite_bind(struct usb_gadget *gadget, 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); @@ -1715,4 +1711,9 @@ void usb_composite_overwrite_options(struct usb_composite_dev *cdev, desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id; dev_str[USB_GADGET_MANUFACTURER_IDX].s = covr->manufacturer; } + + if (covr->product) { + desc->iProduct = dev_str[USB_GADGET_PRODUCT_IDX].id; + dev_str[USB_GADGET_PRODUCT_IDX].s = covr->product; + } } diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 86553c8..5cd110e 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h @@ -402,6 +402,7 @@ struct usb_composite_overwrite { u16 bcdDevice; char *serial_number; char *manufacturer; + char *product; }; #define USB_GADGET_COMPOSITE_OPTIONS() \ static struct usb_composite_overwrite coverwrite; \ @@ -421,7 +422,10 @@ struct usb_composite_overwrite { \ module_param_named(iManufacturer, coverwrite.manufacturer, charp, \ S_IRUGO); \ - MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string") + MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); \ + \ + module_param_named(iProduct, coverwrite.product, charp, S_IRUGO); \ + MODULE_PARM_DESC(iProduct, "USB Product string") void usb_composite_overwrite_options(struct usb_composite_dev *cdev, struct usb_composite_overwrite *covr); -- 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