diff options
-rw-r--r-- | drivers/usb/gadget/composite.c | 21 | ||||
-rw-r--r-- | 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 482cf8cf301..47b9130968b 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c | |||
@@ -28,14 +28,6 @@ | |||
28 | * with the relevant device-wide data. | 28 | * with the relevant device-wide data. |
29 | */ | 29 | */ |
30 | 30 | ||
31 | /* Some systems will need runtime overrides for the product identifiers | ||
32 | * published in the device descriptor, either numbers or strings or both. | ||
33 | * String parameters are in UTF-8 (superset of ASCII's 7 bit characters). | ||
34 | */ | ||
35 | static char *iProduct; | ||
36 | module_param(iProduct, charp, S_IRUGO); | ||
37 | MODULE_PARM_DESC(iProduct, "USB Product string"); | ||
38 | |||
39 | static char composite_manufacturer[50]; | 31 | static char composite_manufacturer[50]; |
40 | 32 | ||
41 | /*-------------------------------------------------------------------------*/ | 33 | /*-------------------------------------------------------------------------*/ |
@@ -914,7 +906,7 @@ static int get_string(struct usb_composite_dev *cdev, | |||
914 | if (cdev->manufacturer_override == id) | 906 | if (cdev->manufacturer_override == id) |
915 | str = composite->iManufacturer ?: composite_manufacturer; | 907 | str = composite->iManufacturer ?: composite_manufacturer; |
916 | else if (cdev->product_override == id) | 908 | else if (cdev->product_override == id) |
917 | str = iProduct ?: composite->iProduct; | 909 | str = composite->iProduct; |
918 | else if (cdev->serial_override == id) | 910 | else if (cdev->serial_override == id) |
919 | str = composite->iSerialNumber; | 911 | str = composite->iSerialNumber; |
920 | else | 912 | else |
@@ -1404,6 +1396,7 @@ static void update_unchanged_dev_desc(struct usb_device_descriptor *new, | |||
1404 | __le16 bcdDevice; | 1396 | __le16 bcdDevice; |
1405 | u8 iSerialNumber; | 1397 | u8 iSerialNumber; |
1406 | u8 iManufacturer; | 1398 | u8 iManufacturer; |
1399 | u8 iProduct; | ||
1407 | 1400 | ||
1408 | /* | 1401 | /* |
1409 | * these variables may have been set in | 1402 | * these variables may have been set in |
@@ -1414,6 +1407,7 @@ static void update_unchanged_dev_desc(struct usb_device_descriptor *new, | |||
1414 | bcdDevice = new->bcdDevice; | 1407 | bcdDevice = new->bcdDevice; |
1415 | iSerialNumber = new->iSerialNumber; | 1408 | iSerialNumber = new->iSerialNumber; |
1416 | iManufacturer = new->iManufacturer; | 1409 | iManufacturer = new->iManufacturer; |
1410 | iProduct = new->iProduct; | ||
1417 | 1411 | ||
1418 | *new = *old; | 1412 | *new = *old; |
1419 | if (idVendor) | 1413 | if (idVendor) |
@@ -1426,6 +1420,8 @@ static void update_unchanged_dev_desc(struct usb_device_descriptor *new, | |||
1426 | new->iSerialNumber = iSerialNumber; | 1420 | new->iSerialNumber = iSerialNumber; |
1427 | if (iManufacturer) | 1421 | if (iManufacturer) |
1428 | new->iManufacturer = iManufacturer; | 1422 | new->iManufacturer = iManufacturer; |
1423 | if (iProduct) | ||
1424 | new->iProduct = iProduct; | ||
1429 | } | 1425 | } |
1430 | 1426 | ||
1431 | static struct usb_composite_driver *to_cdriver(struct usb_gadget_driver *gdrv) | 1427 | static struct usb_composite_driver *to_cdriver(struct usb_gadget_driver *gdrv) |
@@ -1499,7 +1495,7 @@ static int composite_bind(struct usb_gadget *gadget, | |||
1499 | override_id(cdev, &cdev->desc.iManufacturer); | 1495 | override_id(cdev, &cdev->desc.iManufacturer); |
1500 | } | 1496 | } |
1501 | 1497 | ||
1502 | if (iProduct || (!cdev->desc.iProduct && composite->iProduct)) | 1498 | if (!cdev->desc.iProduct && composite->iProduct) |
1503 | cdev->product_override = | 1499 | cdev->product_override = |
1504 | override_id(cdev, &cdev->desc.iProduct); | 1500 | override_id(cdev, &cdev->desc.iProduct); |
1505 | 1501 | ||
@@ -1708,4 +1704,9 @@ void usb_composite_overwrite_options(struct usb_composite_dev *cdev, | |||
1708 | desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id; | 1704 | desc->iManufacturer = dev_str[USB_GADGET_MANUFACTURER_IDX].id; |
1709 | dev_str[USB_GADGET_MANUFACTURER_IDX].s = covr->manufacturer; | 1705 | dev_str[USB_GADGET_MANUFACTURER_IDX].s = covr->manufacturer; |
1710 | } | 1706 | } |
1707 | |||
1708 | if (covr->product) { | ||
1709 | desc->iProduct = dev_str[USB_GADGET_PRODUCT_IDX].id; | ||
1710 | dev_str[USB_GADGET_PRODUCT_IDX].s = covr->product; | ||
1711 | } | ||
1711 | } | 1712 | } |
diff --git a/include/linux/usb/composite.h b/include/linux/usb/composite.h index 86553c8c3e8..5cd110ec0a2 100644 --- a/include/linux/usb/composite.h +++ b/include/linux/usb/composite.h | |||
@@ -402,6 +402,7 @@ struct usb_composite_overwrite { | |||
402 | u16 bcdDevice; | 402 | u16 bcdDevice; |
403 | char *serial_number; | 403 | char *serial_number; |
404 | char *manufacturer; | 404 | char *manufacturer; |
405 | char *product; | ||
405 | }; | 406 | }; |
406 | #define USB_GADGET_COMPOSITE_OPTIONS() \ | 407 | #define USB_GADGET_COMPOSITE_OPTIONS() \ |
407 | static struct usb_composite_overwrite coverwrite; \ | 408 | static struct usb_composite_overwrite coverwrite; \ |
@@ -421,7 +422,10 @@ struct usb_composite_overwrite { | |||
421 | \ | 422 | \ |
422 | module_param_named(iManufacturer, coverwrite.manufacturer, charp, \ | 423 | module_param_named(iManufacturer, coverwrite.manufacturer, charp, \ |
423 | S_IRUGO); \ | 424 | S_IRUGO); \ |
424 | MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string") | 425 | MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); \ |
426 | \ | ||
427 | module_param_named(iProduct, coverwrite.product, charp, S_IRUGO); \ | ||
428 | MODULE_PARM_DESC(iProduct, "USB Product string") | ||
425 | 429 | ||
426 | void usb_composite_overwrite_options(struct usb_composite_dev *cdev, | 430 | void usb_composite_overwrite_options(struct usb_composite_dev *cdev, |
427 | struct usb_composite_overwrite *covr); | 431 | struct usb_composite_overwrite *covr); |