aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAras Vaichas <arasv@magellan-technology.com>2006-02-18 15:31:23 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2006-03-20 17:49:58 -0500
commit1afc64a3d68174fe524f11d92e045a30eacc927e (patch)
tree04b9889b1a606b27ed9d91923f09031ef566ab73
parent329af28b141ab4ae847aff1362864c4cc332641f (diff)
[PATCH] USB: ethernet gadget driver section fixups
This patch allows you to set the iSerialNumber field in the usb_device_descriptor structure for your USB ethernet gadget. It also changes the parameters shown through sysfs so they're no longer declared as __initdata, preventing potential oopses. That's most useful for the Ethernet addresses, which may in some cases be random "locally administered" addresses. Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/gadget/ether.c38
1 files changed, 27 insertions, 11 deletions
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 0d9d9bbb73f0..c3d8e5c5bf28 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -182,33 +182,37 @@ struct eth_dev {
182 * parameters are in UTF-8 (superset of ASCII's 7 bit characters). 182 * parameters are in UTF-8 (superset of ASCII's 7 bit characters).
183 */ 183 */
184 184
185static ushort __initdata idVendor; 185static ushort idVendor;
186module_param(idVendor, ushort, S_IRUGO); 186module_param(idVendor, ushort, S_IRUGO);
187MODULE_PARM_DESC(idVendor, "USB Vendor ID"); 187MODULE_PARM_DESC(idVendor, "USB Vendor ID");
188 188
189static ushort __initdata idProduct; 189static ushort idProduct;
190module_param(idProduct, ushort, S_IRUGO); 190module_param(idProduct, ushort, S_IRUGO);
191MODULE_PARM_DESC(idProduct, "USB Product ID"); 191MODULE_PARM_DESC(idProduct, "USB Product ID");
192 192
193static ushort __initdata bcdDevice; 193static ushort bcdDevice;
194module_param(bcdDevice, ushort, S_IRUGO); 194module_param(bcdDevice, ushort, S_IRUGO);
195MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)"); 195MODULE_PARM_DESC(bcdDevice, "USB Device version (BCD)");
196 196
197static char *__initdata iManufacturer; 197static char *iManufacturer;
198module_param(iManufacturer, charp, S_IRUGO); 198module_param(iManufacturer, charp, S_IRUGO);
199MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string"); 199MODULE_PARM_DESC(iManufacturer, "USB Manufacturer string");
200 200
201static char *__initdata iProduct; 201static char *iProduct;
202module_param(iProduct, charp, S_IRUGO); 202module_param(iProduct, charp, S_IRUGO);
203MODULE_PARM_DESC(iProduct, "USB Product string"); 203MODULE_PARM_DESC(iProduct, "USB Product string");
204 204
205static char *iSerialNumber;
206module_param(iSerialNumber, charp, S_IRUGO);
207MODULE_PARM_DESC(iSerialNumber, "SerialNumber");
208
205/* initial value, changed by "ifconfig usb0 hw ether xx:xx:xx:xx:xx:xx" */ 209/* initial value, changed by "ifconfig usb0 hw ether xx:xx:xx:xx:xx:xx" */
206static char *__initdata dev_addr; 210static char *dev_addr;
207module_param(dev_addr, charp, S_IRUGO); 211module_param(dev_addr, charp, S_IRUGO);
208MODULE_PARM_DESC(dev_addr, "Device Ethernet Address"); 212MODULE_PARM_DESC(dev_addr, "Device Ethernet Address");
209 213
210/* this address is invisible to ifconfig */ 214/* this address is invisible to ifconfig */
211static char *__initdata host_addr; 215static char *host_addr;
212module_param(host_addr, charp, S_IRUGO); 216module_param(host_addr, charp, S_IRUGO);
213MODULE_PARM_DESC(host_addr, "Host Ethernet Address"); 217MODULE_PARM_DESC(host_addr, "Host Ethernet Address");
214 218
@@ -403,6 +407,7 @@ static inline int BITRATE(struct usb_gadget *g)
403#define STRING_CDC 7 407#define STRING_CDC 7
404#define STRING_SUBSET 8 408#define STRING_SUBSET 8
405#define STRING_RNDIS 9 409#define STRING_RNDIS 9
410#define STRING_SERIALNUMBER 10
406 411
407/* holds our biggest descriptor (or RNDIS response) */ 412/* holds our biggest descriptor (or RNDIS response) */
408#define USB_BUFSIZ 256 413#define USB_BUFSIZ 256
@@ -870,6 +875,7 @@ static inline void __init hs_subset_descriptors(void)
870 875
871static char manufacturer [50]; 876static char manufacturer [50];
872static char product_desc [40] = DRIVER_DESC; 877static char product_desc [40] = DRIVER_DESC;
878static char serial_number [20];
873 879
874#ifdef DEV_CONFIG_CDC 880#ifdef DEV_CONFIG_CDC
875/* address that the host will use ... usually assigned at random */ 881/* address that the host will use ... usually assigned at random */
@@ -880,6 +886,7 @@ static char ethaddr [2 * ETH_ALEN + 1];
880static struct usb_string strings [] = { 886static struct usb_string strings [] = {
881 { STRING_MANUFACTURER, manufacturer, }, 887 { STRING_MANUFACTURER, manufacturer, },
882 { STRING_PRODUCT, product_desc, }, 888 { STRING_PRODUCT, product_desc, },
889 { STRING_SERIALNUMBER, serial_number, },
883 { STRING_DATA, "Ethernet Data", }, 890 { STRING_DATA, "Ethernet Data", },
884#ifdef DEV_CONFIG_CDC 891#ifdef DEV_CONFIG_CDC
885 { STRING_CDC, "CDC Ethernet", }, 892 { STRING_CDC, "CDC Ethernet", },
@@ -2162,7 +2169,7 @@ static u8 __init nibble (unsigned char c)
2162 return 0; 2169 return 0;
2163} 2170}
2164 2171
2165static void __init get_ether_addr (const char *str, u8 *dev_addr) 2172static int __init get_ether_addr(const char *str, u8 *dev_addr)
2166{ 2173{
2167 if (str) { 2174 if (str) {
2168 unsigned i; 2175 unsigned i;
@@ -2177,9 +2184,10 @@ static void __init get_ether_addr (const char *str, u8 *dev_addr)
2177 dev_addr [i] = num; 2184 dev_addr [i] = num;
2178 } 2185 }
2179 if (is_valid_ether_addr (dev_addr)) 2186 if (is_valid_ether_addr (dev_addr))
2180 return; 2187 return 0;
2181 } 2188 }
2182 random_ether_addr(dev_addr); 2189 random_ether_addr(dev_addr);
2190 return 1;
2183} 2191}
2184 2192
2185static int __init 2193static int __init
@@ -2277,6 +2285,10 @@ eth_bind (struct usb_gadget *gadget)
2277 strlcpy (manufacturer, iManufacturer, sizeof manufacturer); 2285 strlcpy (manufacturer, iManufacturer, sizeof manufacturer);
2278 if (iProduct) 2286 if (iProduct)
2279 strlcpy (product_desc, iProduct, sizeof product_desc); 2287 strlcpy (product_desc, iProduct, sizeof product_desc);
2288 if (iSerialNumber) {
2289 device_desc.iSerialNumber = STRING_SERIALNUMBER,
2290 strlcpy(serial_number, iSerialNumber, sizeof serial_number);
2291 }
2280 2292
2281 /* all we really need is bulk IN/OUT */ 2293 /* all we really need is bulk IN/OUT */
2282 usb_ep_autoconfig_reset (gadget); 2294 usb_ep_autoconfig_reset (gadget);
@@ -2386,9 +2398,13 @@ autoconf_fail:
2386 * The host side address is used with CDC and RNDIS, and commonly 2398 * The host side address is used with CDC and RNDIS, and commonly
2387 * ends up in a persistent config database. 2399 * ends up in a persistent config database.
2388 */ 2400 */
2389 get_ether_addr(dev_addr, net->dev_addr); 2401 if (get_ether_addr(dev_addr, net->dev_addr))
2402 dev_warn(&gadget->dev,
2403 "using random %s ethernet address\n", "self");
2390 if (cdc || rndis) { 2404 if (cdc || rndis) {
2391 get_ether_addr(host_addr, dev->host_mac); 2405 if (get_ether_addr(host_addr, dev->host_mac))
2406 dev_warn(&gadget->dev,
2407 "using random %s ethernet address\n", "host");
2392#ifdef DEV_CONFIG_CDC 2408#ifdef DEV_CONFIG_CDC
2393 snprintf (ethaddr, sizeof ethaddr, "%02X%02X%02X%02X%02X%02X", 2409 snprintf (ethaddr, sizeof ethaddr, "%02X%02X%02X%02X%02X%02X",
2394 dev->host_mac [0], dev->host_mac [1], 2410 dev->host_mac [0], dev->host_mac [1],