module_param(iProduct, charp, S_IRUGO);
MODULE_PARM_DESC(iProduct, "USB Product string");
-static char *iSerialNumber;
-module_param(iSerialNumber, charp, S_IRUGO);
-MODULE_PARM_DESC(iSerialNumber, "SerialNumber string");
-
static char composite_manufacturer[50];
/*-------------------------------------------------------------------------*/
else if (cdev->product_override == id)
str = iProduct ?: composite->iProduct;
else if (cdev->serial_override == id)
- str = iSerialNumber ?: composite->iSerialNumber;
+ str = composite->iSerialNumber;
else
str = NULL;
if (str) {
__le16 idVendor;
__le16 idProduct;
__le16 bcdDevice;
+ u8 iSerialNumber;
/*
* these variables may have been set in
idVendor = new->idVendor;
idProduct = new->idProduct;
bcdDevice = new->bcdDevice;
+ iSerialNumber = new->iSerialNumber;
*new = *old;
if (idVendor)
new->idProduct = idProduct;
if (bcdDevice)
new->bcdDevice = bcdDevice;
+ if (iSerialNumber)
+ new->iSerialNumber = iSerialNumber;
}
static struct usb_composite_driver *to_cdriver(struct usb_gadget_driver *gdrv)
cdev->product_override =
override_id(cdev, &cdev->desc.iProduct);
- if (iSerialNumber ||
- (!cdev->desc.iSerialNumber && composite->iSerialNumber))
+ if (composite->iSerialNumber)
cdev->serial_override =
override_id(cdev, &cdev->desc.iSerialNumber);
struct usb_composite_overwrite *covr)
{
struct usb_device_descriptor *desc = &cdev->desc;
+ struct usb_gadget_strings *gstr = cdev->driver->strings[0];
+ struct usb_string *dev_str = gstr->strings;
if (covr->idVendor)
desc->idVendor = cpu_to_le16(covr->idVendor);
if (covr->bcdDevice)
desc->bcdDevice = cpu_to_le16(covr->bcdDevice);
+
+ if (covr->serial_number) {
+ desc->iSerialNumber = dev_str[USB_GADGET_SERIAL_IDX].id;
+ dev_str[USB_GADGET_SERIAL_IDX].s = covr->serial_number;
+ }
}
NULL,
};
+static struct usb_string strings_dev[] = {
+ [USB_GADGET_MANUFACTURER_IDX].s = "",
+ [USB_GADGET_PRODUCT_IDX].s = "",
+ [USB_GADGET_SERIAL_IDX].s = "",
+ { } /* end of list */
+};
+
+static struct usb_gadget_strings stringtab_dev = {
+ .language = 0x0409, /* en-us */
+ .strings = strings_dev,
+};
+
+static struct usb_gadget_strings *dev_strings[] = {
+ &stringtab_dev,
+ NULL,
+};
/****************************** Configurations ******************************/
{
int status;
+ status = usb_string_ids_tab(cdev, strings_dev);
+ if (status < 0)
+ return status;
+
status = usb_add_config(cdev, &msg_config_driver, msg_do_config);
if (status < 0)
return status;
.iProduct = DRIVER_DESC,
.max_speed = USB_SPEED_SUPER,
.needs_serial = 1,
+ .strings = dev_strings,
.bind = msg_bind,
};
* parameters are in UTF-8 (superset of ASCII's 7 bit characters).
*/
-static char *iSerialNum;
-module_param(iSerialNum, charp, S_IRUGO);
+module_param_named(iSerialNum, coverwrite.serial_number, charp, S_IRUGO);
MODULE_PARM_DESC(iSerialNum, "1");
static char *iPNPstring;
init_utsname()->sysname, init_utsname()->release,
gadget->name);
- if (iSerialNum)
- strlcpy(serial_num, iSerialNum, sizeof serial_num);
-
if (iPNPstring)
strlcpy(&pnp_string[2], iPNPstring, (sizeof pnp_string)-2);
u16 idVendor;
u16 idProduct;
u16 bcdDevice;
+ char *serial_number;
};
#define USB_GADGET_COMPOSITE_OPTIONS() \
static struct usb_composite_overwrite coverwrite; \
MODULE_PARM_DESC(idProduct, "USB Product ID"); \
\
module_param_named(bcdDevice, coverwrite.bcdDevice, ushort, S_IRUGO); \
- MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)")
+ MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); \
+ \
+ module_param_named(iSerialNumber, coverwrite.serial_number, charp, \
+ S_IRUGO); \
+ MODULE_PARM_DESC(iSerialNumber, "SerialNumber string")
void usb_composite_overwrite_options(struct usb_composite_dev *cdev,
struct usb_composite_overwrite *covr);