This patch allows you to set the iSerialNumber field in the
usb_device_descriptor structure for your USB ethernet gadget.
e.g.
modprobe g_ether iSerialNumber="1234abcde"
# lsusb -v
...
iProduct 2 RNDIS/Ethernet Gadget
iSerial 10 1234abcde
bNumConfigurations 2
...
--- linux/drivers/usb/gadget/ether.c.orig 2005-11-29 14:15:04.000000000
+1100
+++ linux/drivers/usb/gadget/ether.c 2005-11-29 14:59:23.000000000 +1100
@@ -202,6 +202,10 @@ static char *__initdata iProduct;
module_param(iProduct, charp, S_IRUGO);
MODULE_PARM_DESC(iProduct, "USB Product string");
+static char *__initdata iSerialNumber;
+module_param(iSerialNumber, charp, S_IRUGO);
+MODULE_PARM_DESC(iSerialNumber, "SerialNumber");
+
/* initial value, changed by "ifconfig usb0 hw ether xx:xx:xx:xx:xx:xx" */
static char *__initdata dev_addr;
module_param(dev_addr, charp, S_IRUGO);
@@ -395,6 +399,7 @@ static inline int BITRATE(struct usb_gad
#define STRING_CDC 7
#define STRING_SUBSET 8
#define STRING_RNDIS 9
+#define STRING_SERIALNUMBER 10
/* holds our biggest descriptor (or RNDIS response) */
#define USB_BUFSIZ 256
@@ -428,6 +433,7 @@ device_desc = {
.idProduct = __constant_cpu_to_le16 (CDC_PRODUCT_NUM),
.iManufacturer = STRING_MANUFACTURER,
.iProduct = STRING_PRODUCT,
+ .iSerialNumber = STRING_SERIALNUMBER,
.bNumConfigurations = 1,
};
@@ -862,6 +868,7 @@ static inline void __init hs_subset_desc
static char manufacturer [50];
static char product_desc [40] = DRIVER_DESC;
+static char serial_number [13];
#ifdef DEV_CONFIG_CDC
/* address that the host will use ... usually assigned at random */
@@ -884,6 +891,7 @@ static struct usb_string strings [] = {
#ifdef CONFIG_USB_ETH_RNDIS
{ STRING_RNDIS, "RNDIS", },
{ STRING_RNDIS_CONTROL, "RNDIS Communications Control", },
+ { STRING_SERIALNUMBER, serial_number, },
#endif
{ } /* end of list */
};
@@ -2268,6 +2276,8 @@ eth_bind (struct usb_gadget *gadget)
strlcpy (manufacturer, iManufacturer, sizeof manufacturer);
if (iProduct)
strlcpy (product_desc, iProduct, sizeof product_desc);
+ if (iSerialNumber)
+ strlcpy (serial_number, iSerialNumber, sizeof serial_number);
/* all we really need is bulk IN/OUT */
usb_ep_autoconfig_reset (gadget);