David Brownell wrote:
On Monday 12 December 2005 10:48 pm, Aras Vaichas wrote:
Hi,
I was poking around /sys and I noticed that g_ether gave an oops if I tried to
look at its parameters. g_serial seems to work OK, as do most of the other
modules that I checked.
Does anyone else have this problem?
Either the parameters should be given mode 0 so they don't show
up in the filesystem (preferable fix!) or else they shouldn't be
getting marked as __init ... please submit a patch if you have time!
I wanted to be able to see some of this information in /sys so I've chosen the
"remove __initdata" option.
This patch also includes adding the serial number parameter to the module.
The one drawback with this driver is that the dev_addr and host_addr don't show
up in /sys if they weren't specified, even though they are randomly chosen by
the driver itself.
regards,
Aras Vaichas
--- linux/drivers/usb/gadget/ether.c.orig 2005-11-29 14:15:04.000000000
+1100
+++ linux/drivers/usb/gadget/ether.c 2005-12-14 11:19:43.000000000 +1100
@@ -182,33 +182,37 @@ struct eth_dev {
* parameters are in UTF-8 (superset of ASCII's 7 bit characters).
*/
-static ushort __initdata idVendor;
+static ushort idVendor;
module_param(idVendor, ushort, S_IRUGO);
MODULE_PARM_DESC(idVendor, "USB Vendor ID");
-static ushort __initdata idProduct;
+static ushort idProduct;
module_param(idProduct, ushort, S_IRUGO);
MODULE_PARM_DESC(idProduct, "USB Product ID");
-static ushort __initdata bcdDevice;
+static ushort bcdDevice;
module_param(bcdDevice, ushort, S_IRUGO);
MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)");
-static char *__initdata iManufacturer;
+static char *iManufacturer;
module_param(iManufacturer, charp, S_IRUGO);
MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string");
-static char *__initdata iProduct;
+static char *iProduct;
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");
+
/* initial value, changed by "ifconfig usb0 hw ether xx:xx:xx:xx:xx:xx" */
-static char *__initdata dev_addr;
+static char *dev_addr;
module_param(dev_addr, charp, S_IRUGO);
MODULE_PARM_DESC(dev_addr, "Device Ethernet Address");
/* this address is invisible to ifconfig */
-static char *__initdata host_addr;
+static char *host_addr;
module_param(host_addr, charp, S_IRUGO);
MODULE_PARM_DESC(host_addr, "Host Ethernet Address");
@@ -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 */
@@ -873,6 +880,7 @@ static struct usb_string strings [] = {
{ STRING_MANUFACTURER, manufacturer, },
{ STRING_PRODUCT, product_desc, },
{ STRING_DATA, "Ethernet Data", },
+ { STRING_SERIALNUMBER, serial_number, },
#ifdef DEV_CONFIG_CDC
{ STRING_CDC, "CDC Ethernet", },
{ STRING_ETHADDR, ethaddr, },
@@ -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);