aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/ether.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/gadget/ether.c')
-rw-r--r--drivers/usb/gadget/ether.c53
1 files changed, 39 insertions, 14 deletions
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index afc84cfb61f9..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
@@ -253,6 +257,14 @@ MODULE_PARM_DESC(host_addr, "Host Ethernet Address");
253#define DEV_CONFIG_CDC 257#define DEV_CONFIG_CDC
254#endif 258#endif
255 259
260#ifdef CONFIG_USB_GADGET_MUSBHSFC
261#define DEV_CONFIG_CDC
262#endif
263
264#ifdef CONFIG_USB_GADGET_MUSBHDRC
265#define DEV_CONFIG_CDC
266#endif
267
256 268
257/* For CDC-incapable hardware, choose the simple cdc subset. 269/* For CDC-incapable hardware, choose the simple cdc subset.
258 * Anything that talks bulk (without notable bugs) can do this. 270 * Anything that talks bulk (without notable bugs) can do this.
@@ -395,6 +407,7 @@ static inline int BITRATE(struct usb_gadget *g)
395#define STRING_CDC 7 407#define STRING_CDC 7
396#define STRING_SUBSET 8 408#define STRING_SUBSET 8
397#define STRING_RNDIS 9 409#define STRING_RNDIS 9
410#define STRING_SERIALNUMBER 10
398 411
399/* holds our biggest descriptor (or RNDIS response) */ 412/* holds our biggest descriptor (or RNDIS response) */
400#define USB_BUFSIZ 256 413#define USB_BUFSIZ 256
@@ -862,6 +875,7 @@ static inline void __init hs_subset_descriptors(void)
862 875
863static char manufacturer [50]; 876static char manufacturer [50];
864static char product_desc [40] = DRIVER_DESC; 877static char product_desc [40] = DRIVER_DESC;
878static char serial_number [20];
865 879
866#ifdef DEV_CONFIG_CDC 880#ifdef DEV_CONFIG_CDC
867/* address that the host will use ... usually assigned at random */ 881/* address that the host will use ... usually assigned at random */
@@ -872,6 +886,7 @@ static char ethaddr [2 * ETH_ALEN + 1];
872static struct usb_string strings [] = { 886static struct usb_string strings [] = {
873 { STRING_MANUFACTURER, manufacturer, }, 887 { STRING_MANUFACTURER, manufacturer, },
874 { STRING_PRODUCT, product_desc, }, 888 { STRING_PRODUCT, product_desc, },
889 { STRING_SERIALNUMBER, serial_number, },
875 { STRING_DATA, "Ethernet Data", }, 890 { STRING_DATA, "Ethernet Data", },
876#ifdef DEV_CONFIG_CDC 891#ifdef DEV_CONFIG_CDC
877 { STRING_CDC, "CDC Ethernet", }, 892 { STRING_CDC, "CDC Ethernet", },
@@ -1549,7 +1564,8 @@ static int eth_change_mtu (struct net_device *net, int new_mtu)
1549{ 1564{
1550 struct eth_dev *dev = netdev_priv(net); 1565 struct eth_dev *dev = netdev_priv(net);
1551 1566
1552 // FIXME if rndis, don't change while link's live 1567 if (dev->rndis)
1568 return -EBUSY;
1553 1569
1554 if (new_mtu <= ETH_HLEN || new_mtu > ETH_FRAME_LEN) 1570 if (new_mtu <= ETH_HLEN || new_mtu > ETH_FRAME_LEN)
1555 return -ERANGE; 1571 return -ERANGE;
@@ -2116,7 +2132,7 @@ eth_req_free (struct usb_ep *ep, struct usb_request *req)
2116} 2132}
2117 2133
2118 2134
2119static void 2135static void __exit
2120eth_unbind (struct usb_gadget *gadget) 2136eth_unbind (struct usb_gadget *gadget)
2121{ 2137{
2122 struct eth_dev *dev = get_gadget_data (gadget); 2138 struct eth_dev *dev = get_gadget_data (gadget);
@@ -2153,7 +2169,7 @@ static u8 __init nibble (unsigned char c)
2153 return 0; 2169 return 0;
2154} 2170}
2155 2171
2156static void __init get_ether_addr (const char *str, u8 *dev_addr) 2172static int __init get_ether_addr(const char *str, u8 *dev_addr)
2157{ 2173{
2158 if (str) { 2174 if (str) {
2159 unsigned i; 2175 unsigned i;
@@ -2168,9 +2184,10 @@ static void __init get_ether_addr (const char *str, u8 *dev_addr)
2168 dev_addr [i] = num; 2184 dev_addr [i] = num;
2169 } 2185 }
2170 if (is_valid_ether_addr (dev_addr)) 2186 if (is_valid_ether_addr (dev_addr))
2171 return; 2187 return 0;
2172 } 2188 }
2173 random_ether_addr(dev_addr); 2189 random_ether_addr(dev_addr);
2190 return 1;
2174} 2191}
2175 2192
2176static int __init 2193static int __init
@@ -2268,6 +2285,10 @@ eth_bind (struct usb_gadget *gadget)
2268 strlcpy (manufacturer, iManufacturer, sizeof manufacturer); 2285 strlcpy (manufacturer, iManufacturer, sizeof manufacturer);
2269 if (iProduct) 2286 if (iProduct)
2270 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 }
2271 2292
2272 /* all we really need is bulk IN/OUT */ 2293 /* all we really need is bulk IN/OUT */
2273 usb_ep_autoconfig_reset (gadget); 2294 usb_ep_autoconfig_reset (gadget);
@@ -2377,9 +2398,13 @@ autoconf_fail:
2377 * 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
2378 * ends up in a persistent config database. 2399 * ends up in a persistent config database.
2379 */ 2400 */
2380 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");
2381 if (cdc || rndis) { 2404 if (cdc || rndis) {
2382 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");
2383#ifdef DEV_CONFIG_CDC 2408#ifdef DEV_CONFIG_CDC
2384 snprintf (ethaddr, sizeof ethaddr, "%02X%02X%02X%02X%02X%02X", 2409 snprintf (ethaddr, sizeof ethaddr, "%02X%02X%02X%02X%02X%02X",
2385 dev->host_mac [0], dev->host_mac [1], 2410 dev->host_mac [0], dev->host_mac [1],
@@ -2523,7 +2548,7 @@ static struct usb_gadget_driver eth_driver = {
2523 2548
2524 .function = (char *) driver_desc, 2549 .function = (char *) driver_desc,
2525 .bind = eth_bind, 2550 .bind = eth_bind,
2526 .unbind = eth_unbind, 2551 .unbind = __exit_p(eth_unbind),
2527 2552
2528 .setup = eth_setup, 2553 .setup = eth_setup,
2529 .disconnect = eth_disconnect, 2554 .disconnect = eth_disconnect,