aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>2013-05-23 03:22:03 -0400
committerFelipe Balbi <balbi@ti.com>2013-06-10 10:10:57 -0400
commitf1a1823ff24fa4e3412b5078f20021cf40834946 (patch)
tree7ede1143ae2a4945b5ed9f5292c84d39edea86b6
parentd68c277b501889b3a50c179d1c3d704db7947b83 (diff)
usb: gadget: u_ether: convert into module
u_ether.c has been #include'd by all gadgets which implement USB Ethernet functions. In order to add configfs support, the f_ecm.c, f_eem.c, f_ncm.c, f_subset.c, f_rndis.c need to be converted into modules and must not be #include'd. Consequently, the u_ether.c needs to be a module too, in a manner similar to u_serial.c. The resulting module should not take any parameters, so they are pushed to the current users of it, that is ether.c, g_ffs.c, multi.c, ncm.c, nokia.c. Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r--drivers/usb/gadget/Kconfig10
-rw-r--r--drivers/usb/gadget/Makefile1
-rw-r--r--drivers/usb/gadget/cdc2.c10
-rw-r--r--drivers/usb/gadget/ether.c14
-rw-r--r--drivers/usb/gadget/g_ffs.c13
-rw-r--r--drivers/usb/gadget/multi.c13
-rw-r--r--drivers/usb/gadget/ncm.c10
-rw-r--r--drivers/usb/gadget/nokia.c11
-rw-r--r--drivers/usb/gadget/u_ether.c38
-rw-r--r--drivers/usb/gadget/u_ether.h30
10 files changed, 98 insertions, 52 deletions
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index f9bf7283e538..d5ae4dff3b90 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -499,6 +499,9 @@ config USB_F_SS_LB
499config USB_U_SERIAL 499config USB_U_SERIAL
500 tristate 500 tristate
501 501
502config USB_U_ETHER
503 tristate
504
502config USB_F_SERIAL 505config USB_F_SERIAL
503 tristate 506 tristate
504 507
@@ -595,6 +598,7 @@ config USB_ETH
595 tristate "Ethernet Gadget (with CDC Ethernet support)" 598 tristate "Ethernet Gadget (with CDC Ethernet support)"
596 depends on NET 599 depends on NET
597 select USB_LIBCOMPOSITE 600 select USB_LIBCOMPOSITE
601 select USB_U_ETHER
598 select CRC32 602 select CRC32
599 help 603 help
600 This driver implements Ethernet style communication, in one of 604 This driver implements Ethernet style communication, in one of
@@ -667,6 +671,7 @@ config USB_G_NCM
667 tristate "Network Control Model (NCM) support" 671 tristate "Network Control Model (NCM) support"
668 depends on NET 672 depends on NET
669 select USB_LIBCOMPOSITE 673 select USB_LIBCOMPOSITE
674 select USB_U_ETHER
670 select CRC32 675 select CRC32
671 help 676 help
672 This driver implements USB CDC NCM subclass standard. NCM is 677 This driver implements USB CDC NCM subclass standard. NCM is
@@ -710,6 +715,7 @@ config USB_FUNCTIONFS
710config USB_FUNCTIONFS_ETH 715config USB_FUNCTIONFS_ETH
711 bool "Include configuration with CDC ECM (Ethernet)" 716 bool "Include configuration with CDC ECM (Ethernet)"
712 depends on USB_FUNCTIONFS && NET 717 depends on USB_FUNCTIONFS && NET
718 select USB_U_ETHER
713 help 719 help
714 Include a configuration with CDC ECM function (Ethernet) and the 720 Include a configuration with CDC ECM function (Ethernet) and the
715 Function Filesystem. 721 Function Filesystem.
@@ -717,6 +723,7 @@ config USB_FUNCTIONFS_ETH
717config USB_FUNCTIONFS_RNDIS 723config USB_FUNCTIONFS_RNDIS
718 bool "Include configuration with RNDIS (Ethernet)" 724 bool "Include configuration with RNDIS (Ethernet)"
719 depends on USB_FUNCTIONFS && NET 725 depends on USB_FUNCTIONFS && NET
726 select USB_U_ETHER
720 help 727 help
721 Include a configuration with RNDIS function (Ethernet) and the Filesystem. 728 Include a configuration with RNDIS function (Ethernet) and the Filesystem.
722 729
@@ -817,6 +824,7 @@ config USB_CDC_COMPOSITE
817 depends on NET 824 depends on NET
818 select USB_LIBCOMPOSITE 825 select USB_LIBCOMPOSITE
819 select USB_U_SERIAL 826 select USB_U_SERIAL
827 select USB_U_ETHER
820 select USB_F_ACM 828 select USB_F_ACM
821 help 829 help
822 This driver provides two functions in one configuration: 830 This driver provides two functions in one configuration:
@@ -834,6 +842,7 @@ config USB_G_NOKIA
834 depends on PHONET 842 depends on PHONET
835 select USB_LIBCOMPOSITE 843 select USB_LIBCOMPOSITE
836 select USB_U_SERIAL 844 select USB_U_SERIAL
845 select USB_U_ETHER
837 select USB_F_ACM 846 select USB_F_ACM
838 help 847 help
839 The Nokia composite gadget provides support for acm, obex 848 The Nokia composite gadget provides support for acm, obex
@@ -861,6 +870,7 @@ config USB_G_MULTI
861 select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS 870 select USB_G_MULTI_CDC if !USB_G_MULTI_RNDIS
862 select USB_LIBCOMPOSITE 871 select USB_LIBCOMPOSITE
863 select USB_U_SERIAL 872 select USB_U_SERIAL
873 select USB_U_ETHER
864 select USB_F_ACM 874 select USB_F_ACM
865 help 875 help
866 The Multifunction Composite Gadget provides Ethernet (RNDIS 876 The Multifunction Composite Gadget provides Ethernet (RNDIS
diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 6afd16659e78..b6c2bf7a3c2d 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -45,6 +45,7 @@ usb_f_serial-y := f_serial.o
45obj-$(CONFIG_USB_F_SERIAL) += usb_f_serial.o 45obj-$(CONFIG_USB_F_SERIAL) += usb_f_serial.o
46usb_f_obex-y := f_obex.o 46usb_f_obex-y := f_obex.o
47obj-$(CONFIG_USB_F_OBEX) += usb_f_obex.o 47obj-$(CONFIG_USB_F_OBEX) += usb_f_obex.o
48obj-$(CONFIG_USB_U_ETHER) += u_ether.o
48 49
49# 50#
50# USB gadget drivers 51# USB gadget drivers
diff --git a/drivers/usb/gadget/cdc2.c b/drivers/usb/gadget/cdc2.c
index 2c5255182769..bffa997fd040 100644
--- a/drivers/usb/gadget/cdc2.c
+++ b/drivers/usb/gadget/cdc2.c
@@ -35,6 +35,8 @@
35/*-------------------------------------------------------------------------*/ 35/*-------------------------------------------------------------------------*/
36USB_GADGET_COMPOSITE_OPTIONS(); 36USB_GADGET_COMPOSITE_OPTIONS();
37 37
38USB_ETHERNET_MODULE_PARAMETERS();
39
38/* 40/*
39 * Kbuild is not very cooperative with respect to linking separately 41 * Kbuild is not very cooperative with respect to linking separately
40 * compiled library objects into one module. So for now we won't use 42 * compiled library objects into one module. So for now we won't use
@@ -43,7 +45,6 @@ USB_GADGET_COMPOSITE_OPTIONS();
43 * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 45 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
44 */ 46 */
45#include "f_ecm.c" 47#include "f_ecm.c"
46#include "u_ether.c"
47 48
48/*-------------------------------------------------------------------------*/ 49/*-------------------------------------------------------------------------*/
49 50
@@ -102,7 +103,7 @@ static struct usb_gadget_strings *dev_strings[] = {
102 NULL, 103 NULL,
103}; 104};
104 105
105static u8 hostaddr[ETH_ALEN]; 106static u8 host_mac[ETH_ALEN];
106static struct eth_dev *the_dev; 107static struct eth_dev *the_dev;
107/*-------------------------------------------------------------------------*/ 108/*-------------------------------------------------------------------------*/
108static struct usb_function *f_acm; 109static struct usb_function *f_acm;
@@ -120,7 +121,7 @@ static int __init cdc_do_config(struct usb_configuration *c)
120 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; 121 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
121 } 122 }
122 123
123 status = ecm_bind_config(c, hostaddr, the_dev); 124 status = ecm_bind_config(c, host_mac, the_dev);
124 if (status < 0) 125 if (status < 0)
125 return status; 126 return status;
126 127
@@ -166,7 +167,8 @@ static int __init cdc_bind(struct usb_composite_dev *cdev)
166 } 167 }
167 168
168 /* set up network link layer */ 169 /* set up network link layer */
169 the_dev = gether_setup(cdev->gadget, hostaddr); 170 the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
171 qmult);
170 if (IS_ERR(the_dev)) 172 if (IS_ERR(the_dev))
171 return PTR_ERR(the_dev); 173 return PTR_ERR(the_dev);
172 174
diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 56c8ecae9bc3..75418c7050fb 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -107,11 +107,12 @@ static inline bool has_rndis(void)
107#include "rndis.c" 107#include "rndis.c"
108#endif 108#endif
109#include "f_eem.c" 109#include "f_eem.c"
110#include "u_ether.c"
111 110
112/*-------------------------------------------------------------------------*/ 111/*-------------------------------------------------------------------------*/
113USB_GADGET_COMPOSITE_OPTIONS(); 112USB_GADGET_COMPOSITE_OPTIONS();
114 113
114USB_ETHERNET_MODULE_PARAMETERS();
115
115/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!! 116/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
116 * Instead: allocate your own, using normal USB-IF procedures. 117 * Instead: allocate your own, using normal USB-IF procedures.
117 */ 118 */
@@ -206,7 +207,7 @@ static struct usb_gadget_strings *dev_strings[] = {
206 NULL, 207 NULL,
207}; 208};
208 209
209static u8 hostaddr[ETH_ALEN]; 210static u8 host_mac[ETH_ALEN];
210static struct eth_dev *the_dev; 211static struct eth_dev *the_dev;
211/*-------------------------------------------------------------------------*/ 212/*-------------------------------------------------------------------------*/
212 213
@@ -224,7 +225,7 @@ static int __init rndis_do_config(struct usb_configuration *c)
224 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; 225 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
225 } 226 }
226 227
227 return rndis_bind_config(c, hostaddr, the_dev); 228 return rndis_bind_config(c, host_mac, the_dev);
228} 229}
229 230
230static struct usb_configuration rndis_config_driver = { 231static struct usb_configuration rndis_config_driver = {
@@ -259,9 +260,9 @@ static int __init eth_do_config(struct usb_configuration *c)
259 if (use_eem) 260 if (use_eem)
260 return eem_bind_config(c, the_dev); 261 return eem_bind_config(c, the_dev);
261 else if (can_support_ecm(c->cdev->gadget)) 262 else if (can_support_ecm(c->cdev->gadget))
262 return ecm_bind_config(c, hostaddr, the_dev); 263 return ecm_bind_config(c, host_mac, the_dev);
263 else 264 else
264 return geth_bind_config(c, hostaddr, the_dev); 265 return geth_bind_config(c, host_mac, the_dev);
265} 266}
266 267
267static struct usb_configuration eth_config_driver = { 268static struct usb_configuration eth_config_driver = {
@@ -279,7 +280,8 @@ static int __init eth_bind(struct usb_composite_dev *cdev)
279 int status; 280 int status;
280 281
281 /* set up network link layer */ 282 /* set up network link layer */
282 the_dev = gether_setup(cdev->gadget, hostaddr); 283 the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
284 qmult);
283 if (IS_ERR(the_dev)) 285 if (IS_ERR(the_dev))
284 return PTR_ERR(the_dev); 286 return PTR_ERR(the_dev);
285 287
diff --git a/drivers/usb/gadget/g_ffs.c b/drivers/usb/gadget/g_ffs.c
index 787a78e92aa2..45f26be640de 100644
--- a/drivers/usb/gadget/g_ffs.c
+++ b/drivers/usb/gadget/g_ffs.c
@@ -34,9 +34,9 @@
34# include "f_rndis.c" 34# include "f_rndis.c"
35# include "rndis.c" 35# include "rndis.c"
36# endif 36# endif
37# include "u_ether.c" 37# include "u_ether.h"
38 38
39static u8 gfs_hostaddr[ETH_ALEN]; 39static u8 gfs_host_mac[ETH_ALEN];
40static struct eth_dev *the_dev; 40static struct eth_dev *the_dev;
41# ifdef CONFIG_USB_FUNCTIONFS_ETH 41# ifdef CONFIG_USB_FUNCTIONFS_ETH
42static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN], 42static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
@@ -45,7 +45,7 @@ static int eth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
45#else 45#else
46# define the_dev NULL 46# define the_dev NULL
47# define gether_cleanup(dev) do { } while (0) 47# define gether_cleanup(dev) do { } while (0)
48# define gfs_hostaddr NULL 48# define gfs_host_mac NULL
49struct eth_dev; 49struct eth_dev;
50#endif 50#endif
51 51
@@ -73,6 +73,8 @@ struct gfs_ffs_obj {
73 73
74USB_GADGET_COMPOSITE_OPTIONS(); 74USB_GADGET_COMPOSITE_OPTIONS();
75 75
76USB_ETHERNET_MODULE_PARAMETERS();
77
76static struct usb_device_descriptor gfs_dev_desc = { 78static struct usb_device_descriptor gfs_dev_desc = {
77 .bLength = sizeof gfs_dev_desc, 79 .bLength = sizeof gfs_dev_desc,
78 .bDescriptorType = USB_DT_DEVICE, 80 .bDescriptorType = USB_DT_DEVICE,
@@ -350,7 +352,8 @@ static int gfs_bind(struct usb_composite_dev *cdev)
350 if (missing_funcs) 352 if (missing_funcs)
351 return -ENODEV; 353 return -ENODEV;
352#if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS 354#if defined CONFIG_USB_FUNCTIONFS_ETH || defined CONFIG_USB_FUNCTIONFS_RNDIS
353 the_dev = gether_setup(cdev->gadget, gfs_hostaddr); 355 the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, gfs_host_mac,
356 qmult);
354#endif 357#endif
355 if (IS_ERR(the_dev)) { 358 if (IS_ERR(the_dev)) {
356 ret = PTR_ERR(the_dev); 359 ret = PTR_ERR(the_dev);
@@ -446,7 +449,7 @@ static int gfs_do_config(struct usb_configuration *c)
446 } 449 }
447 450
448 if (gc->eth) { 451 if (gc->eth) {
449 ret = gc->eth(c, gfs_hostaddr, the_dev); 452 ret = gc->eth(c, gfs_host_mac, the_dev);
450 if (unlikely(ret < 0)) 453 if (unlikely(ret < 0))
451 return ret; 454 return ret;
452 } 455 }
diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index 4a45e80c6e38..cdb8dbf34c8d 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -49,10 +49,12 @@ MODULE_LICENSE("GPL");
49# include "f_rndis.c" 49# include "f_rndis.c"
50# include "rndis.c" 50# include "rndis.c"
51#endif 51#endif
52#include "u_ether.c" 52#include "u_ether.h"
53 53
54USB_GADGET_COMPOSITE_OPTIONS(); 54USB_GADGET_COMPOSITE_OPTIONS();
55 55
56USB_ETHERNET_MODULE_PARAMETERS();
57
56/***************************** Device Descriptor ****************************/ 58/***************************** Device Descriptor ****************************/
57 59
58#define MULTI_VENDOR_NUM 0x1d6b /* Linux Foundation */ 60#define MULTI_VENDOR_NUM 0x1d6b /* Linux Foundation */
@@ -133,7 +135,7 @@ FSG_MODULE_PARAMETERS(/* no prefix */, fsg_mod_data);
133 135
134static struct fsg_common fsg_common; 136static struct fsg_common fsg_common;
135 137
136static u8 hostaddr[ETH_ALEN]; 138static u8 host_mac[ETH_ALEN];
137 139
138static struct usb_function_instance *fi_acm; 140static struct usb_function_instance *fi_acm;
139static struct eth_dev *the_dev; 141static struct eth_dev *the_dev;
@@ -152,7 +154,7 @@ static __init int rndis_do_config(struct usb_configuration *c)
152 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; 154 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
153 } 155 }
154 156
155 ret = rndis_bind_config(c, hostaddr, the_dev); 157 ret = rndis_bind_config(c, host_mac, the_dev);
156 if (ret < 0) 158 if (ret < 0)
157 return ret; 159 return ret;
158 160
@@ -216,7 +218,7 @@ static __init int cdc_do_config(struct usb_configuration *c)
216 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; 218 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
217 } 219 }
218 220
219 ret = ecm_bind_config(c, hostaddr, the_dev); 221 ret = ecm_bind_config(c, host_mac, the_dev);
220 if (ret < 0) 222 if (ret < 0)
221 return ret; 223 return ret;
222 224
@@ -280,7 +282,8 @@ static int __ref multi_bind(struct usb_composite_dev *cdev)
280 } 282 }
281 283
282 /* set up network link layer */ 284 /* set up network link layer */
283 the_dev = gether_setup(cdev->gadget, hostaddr); 285 the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
286 qmult);
284 if (IS_ERR(the_dev)) 287 if (IS_ERR(the_dev))
285 return PTR_ERR(the_dev); 288 return PTR_ERR(the_dev);
286 289
diff --git a/drivers/usb/gadget/ncm.c b/drivers/usb/gadget/ncm.c
index 3b02fd4649ce..e411135b21e5 100644
--- a/drivers/usb/gadget/ncm.c
+++ b/drivers/usb/gadget/ncm.c
@@ -37,7 +37,6 @@
37 * a "gcc --combine ... part1.c part2.c part3.c ... " build would. 37 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
38 */ 38 */
39#include "f_ncm.c" 39#include "f_ncm.c"
40#include "u_ether.c"
41 40
42/*-------------------------------------------------------------------------*/ 41/*-------------------------------------------------------------------------*/
43 42
@@ -54,6 +53,8 @@
54/*-------------------------------------------------------------------------*/ 53/*-------------------------------------------------------------------------*/
55USB_GADGET_COMPOSITE_OPTIONS(); 54USB_GADGET_COMPOSITE_OPTIONS();
56 55
56USB_ETHERNET_MODULE_PARAMETERS();
57
57static struct usb_device_descriptor device_desc = { 58static struct usb_device_descriptor device_desc = {
58 .bLength = sizeof device_desc, 59 .bLength = sizeof device_desc,
59 .bDescriptorType = USB_DT_DEVICE, 60 .bDescriptorType = USB_DT_DEVICE,
@@ -112,7 +113,7 @@ static struct usb_gadget_strings *dev_strings[] = {
112}; 113};
113 114
114struct eth_dev *the_dev; 115struct eth_dev *the_dev;
115static u8 hostaddr[ETH_ALEN]; 116static u8 host_mac[ETH_ALEN];
116 117
117/*-------------------------------------------------------------------------*/ 118/*-------------------------------------------------------------------------*/
118 119
@@ -125,7 +126,7 @@ static int __init ncm_do_config(struct usb_configuration *c)
125 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP; 126 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
126 } 127 }
127 128
128 return ncm_bind_config(c, hostaddr, the_dev); 129 return ncm_bind_config(c, host_mac, the_dev);
129} 130}
130 131
131static struct usb_configuration ncm_config_driver = { 132static struct usb_configuration ncm_config_driver = {
@@ -144,7 +145,8 @@ static int __init gncm_bind(struct usb_composite_dev *cdev)
144 int status; 145 int status;
145 146
146 /* set up network link layer */ 147 /* set up network link layer */
147 the_dev = gether_setup(cdev->gadget, hostaddr); 148 the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
149 qmult);
148 if (IS_ERR(the_dev)) 150 if (IS_ERR(the_dev))
149 return PTR_ERR(the_dev); 151 return PTR_ERR(the_dev);
150 152
diff --git a/drivers/usb/gadget/nokia.c b/drivers/usb/gadget/nokia.c
index 3b344b41a167..39f6cb5f984d 100644
--- a/drivers/usb/gadget/nokia.c
+++ b/drivers/usb/gadget/nokia.c
@@ -41,11 +41,13 @@
41#include "f_ecm.c" 41#include "f_ecm.c"
42#include "f_obex.c" 42#include "f_obex.c"
43#include "f_phonet.c" 43#include "f_phonet.c"
44#include "u_ether.c" 44#include "u_ether.h"
45 45
46/*-------------------------------------------------------------------------*/ 46/*-------------------------------------------------------------------------*/
47USB_GADGET_COMPOSITE_OPTIONS(); 47USB_GADGET_COMPOSITE_OPTIONS();
48 48
49USB_ETHERNET_MODULE_PARAMETERS();
50
49#define NOKIA_VENDOR_ID 0x0421 /* Nokia */ 51#define NOKIA_VENDOR_ID 0x0421 /* Nokia */
50#define NOKIA_PRODUCT_ID 0x01c8 /* Nokia Gadget */ 52#define NOKIA_PRODUCT_ID 0x01c8 /* Nokia Gadget */
51 53
@@ -98,7 +100,7 @@ MODULE_LICENSE("GPL");
98/*-------------------------------------------------------------------------*/ 100/*-------------------------------------------------------------------------*/
99static struct usb_function *f_acm_cfg1; 101static struct usb_function *f_acm_cfg1;
100static struct usb_function *f_acm_cfg2; 102static struct usb_function *f_acm_cfg2;
101static u8 hostaddr[ETH_ALEN]; 103static u8 host_mac[ETH_ALEN];
102static struct eth_dev *the_dev; 104static struct eth_dev *the_dev;
103 105
104enum { 106enum {
@@ -152,7 +154,7 @@ static int __init nokia_bind_config(struct usb_configuration *c)
152 if (status) 154 if (status)
153 goto err_conf; 155 goto err_conf;
154 156
155 status = ecm_bind_config(c, hostaddr, the_dev); 157 status = ecm_bind_config(c, host_mac, the_dev);
156 if (status) { 158 if (status) {
157 pr_debug("could not bind ecm config %d\n", status); 159 pr_debug("could not bind ecm config %d\n", status);
158 goto err_ecm; 160 goto err_ecm;
@@ -186,7 +188,8 @@ static int __init nokia_bind(struct usb_composite_dev *cdev)
186 goto err_ether; 188 goto err_ether;
187 } 189 }
188 190
189 the_dev = gether_setup(cdev->gadget, hostaddr); 191 the_dev = gether_setup(cdev->gadget, dev_addr, host_addr, host_mac,
192 qmult);
190 if (IS_ERR(the_dev)) { 193 if (IS_ERR(the_dev)) {
191 status = PTR_ERR(the_dev); 194 status = PTR_ERR(the_dev);
192 goto err_ether; 195 goto err_ether;
diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c
index 4b76124ce96b..5f9dacfe6be5 100644
--- a/drivers/usb/gadget/u_ether.c
+++ b/drivers/usb/gadget/u_ether.c
@@ -63,6 +63,8 @@ struct eth_dev {
63 63
64 struct sk_buff_head rx_frames; 64 struct sk_buff_head rx_frames;
65 65
66 unsigned qmult;
67
66 unsigned header_len; 68 unsigned header_len;
67 struct sk_buff *(*wrap)(struct gether *, struct sk_buff *skb); 69 struct sk_buff *(*wrap)(struct gether *, struct sk_buff *skb);
68 int (*unwrap)(struct gether *, 70 int (*unwrap)(struct gether *,
@@ -84,12 +86,8 @@ struct eth_dev {
84 86
85#define DEFAULT_QLEN 2 /* double buffering by default */ 87#define DEFAULT_QLEN 2 /* double buffering by default */
86 88
87static unsigned qmult = 5;
88module_param(qmult, uint, S_IRUGO|S_IWUSR);
89MODULE_PARM_DESC(qmult, "queue length multiplier at high/super speed");
90
91/* for dual-speed hardware, use deeper queues at high/super speed */ 89/* for dual-speed hardware, use deeper queues at high/super speed */
92static inline int qlen(struct usb_gadget *gadget) 90static inline int qlen(struct usb_gadget *gadget, unsigned qmult)
93{ 91{
94 if (gadget_is_dualspeed(gadget) && (gadget->speed == USB_SPEED_HIGH || 92 if (gadget_is_dualspeed(gadget) && (gadget->speed == USB_SPEED_HIGH ||
95 gadget->speed == USB_SPEED_SUPER)) 93 gadget->speed == USB_SPEED_SUPER))
@@ -588,7 +586,7 @@ static netdev_tx_t eth_start_xmit(struct sk_buff *skb,
588 if (gadget_is_dualspeed(dev->gadget)) 586 if (gadget_is_dualspeed(dev->gadget))
589 req->no_interrupt = (dev->gadget->speed == USB_SPEED_HIGH || 587 req->no_interrupt = (dev->gadget->speed == USB_SPEED_HIGH ||
590 dev->gadget->speed == USB_SPEED_SUPER) 588 dev->gadget->speed == USB_SPEED_SUPER)
591 ? ((atomic_read(&dev->tx_qlen) % qmult) != 0) 589 ? ((atomic_read(&dev->tx_qlen) % dev->qmult) != 0)
592 : 0; 590 : 0;
593 591
594 retval = usb_ep_queue(in, req, GFP_ATOMIC); 592 retval = usb_ep_queue(in, req, GFP_ATOMIC);
@@ -697,16 +695,6 @@ static int eth_stop(struct net_device *net)
697 695
698/*-------------------------------------------------------------------------*/ 696/*-------------------------------------------------------------------------*/
699 697
700/* initial value, changed by "ifconfig usb0 hw ether xx:xx:xx:xx:xx:xx" */
701static char *dev_addr;
702module_param(dev_addr, charp, S_IRUGO);
703MODULE_PARM_DESC(dev_addr, "Device Ethernet Address");
704
705/* this address is invisible to ifconfig */
706static char *host_addr;
707module_param(host_addr, charp, S_IRUGO);
708MODULE_PARM_DESC(host_addr, "Host Ethernet Address");
709
710static int get_ether_addr(const char *str, u8 *dev_addr) 698static int get_ether_addr(const char *str, u8 *dev_addr)
711{ 699{
712 if (str) { 700 if (str) {
@@ -755,8 +743,9 @@ static struct device_type gadget_type = {
755 * 743 *
756 * Returns negative errno, or zero on success 744 * Returns negative errno, or zero on success
757 */ 745 */
758struct eth_dev *gether_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN], 746struct eth_dev *gether_setup_name(struct usb_gadget *g,
759 const char *netname) 747 const char *dev_addr, const char *host_addr,
748 u8 ethaddr[ETH_ALEN], unsigned qmult, const char *netname)
760{ 749{
761 struct eth_dev *dev; 750 struct eth_dev *dev;
762 struct net_device *net; 751 struct net_device *net;
@@ -777,6 +766,7 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN],
777 766
778 /* network device setup */ 767 /* network device setup */
779 dev->net = net; 768 dev->net = net;
769 dev->qmult = qmult;
780 snprintf(net->name, sizeof(net->name), "%s%%d", netname); 770 snprintf(net->name, sizeof(net->name), "%s%%d", netname);
781 771
782 if (get_ether_addr(dev_addr, net->dev_addr)) 772 if (get_ether_addr(dev_addr, net->dev_addr))
@@ -815,6 +805,7 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN],
815 805
816 return dev; 806 return dev;
817} 807}
808EXPORT_SYMBOL(gether_setup_name);
818 809
819/** 810/**
820 * gether_cleanup - remove Ethernet-over-USB device 811 * gether_cleanup - remove Ethernet-over-USB device
@@ -831,6 +822,7 @@ void gether_cleanup(struct eth_dev *dev)
831 flush_work(&dev->work); 822 flush_work(&dev->work);
832 free_netdev(dev->net); 823 free_netdev(dev->net);
833} 824}
825EXPORT_SYMBOL(gether_cleanup);
834 826
835/** 827/**
836 * gether_connect - notify network layer that USB link is active 828 * gether_connect - notify network layer that USB link is active
@@ -873,11 +865,12 @@ struct net_device *gether_connect(struct gether *link)
873 } 865 }
874 866
875 if (result == 0) 867 if (result == 0)
876 result = alloc_requests(dev, link, qlen(dev->gadget)); 868 result = alloc_requests(dev, link, qlen(dev->gadget,
869 dev->qmult));
877 870
878 if (result == 0) { 871 if (result == 0) {
879 dev->zlp = link->is_zlp_ok; 872 dev->zlp = link->is_zlp_ok;
880 DBG(dev, "qlen %d\n", qlen(dev->gadget)); 873 DBG(dev, "qlen %d\n", qlen(dev->gadget, dev->qmult));
881 874
882 dev->header_len = link->header_len; 875 dev->header_len = link->header_len;
883 dev->unwrap = link->unwrap; 876 dev->unwrap = link->unwrap;
@@ -910,6 +903,7 @@ fail0:
910 return ERR_PTR(result); 903 return ERR_PTR(result);
911 return dev->net; 904 return dev->net;
912} 905}
906EXPORT_SYMBOL(gether_connect);
913 907
914/** 908/**
915 * gether_disconnect - notify network layer that USB link is inactive 909 * gether_disconnect - notify network layer that USB link is inactive
@@ -980,3 +974,7 @@ void gether_disconnect(struct gether *link)
980 dev->port_usb = NULL; 974 dev->port_usb = NULL;
981 spin_unlock(&dev->lock); 975 spin_unlock(&dev->lock);
982} 976}
977EXPORT_SYMBOL(gether_disconnect);
978
979MODULE_LICENSE("GPL");
980MODULE_AUTHOR("David Brownell");
diff --git a/drivers/usb/gadget/u_ether.h b/drivers/usb/gadget/u_ether.h
index 02522338a708..02f58acdd5e9 100644
--- a/drivers/usb/gadget/u_ether.h
+++ b/drivers/usb/gadget/u_ether.h
@@ -21,6 +21,26 @@
21 21
22#include "gadget_chips.h" 22#include "gadget_chips.h"
23 23
24#define QMULT_DEFAULT 5
25
26/*
27 * dev_addr: initial value
28 * changed by "ifconfig usb0 hw ether xx:xx:xx:xx:xx:xx"
29 * host_addr: this address is invisible to ifconfig
30 */
31#define USB_ETHERNET_MODULE_PARAMETERS() \
32 static unsigned qmult = QMULT_DEFAULT; \
33 module_param(qmult, uint, S_IRUGO|S_IWUSR); \
34 MODULE_PARM_DESC(qmult, "queue length multiplier at high/super speed");\
35 \
36 static char *dev_addr; \
37 module_param(dev_addr, charp, S_IRUGO); \
38 MODULE_PARM_DESC(dev_addr, "Device Ethernet Address"); \
39 \
40 static char *host_addr; \
41 module_param(host_addr, charp, S_IRUGO); \
42 MODULE_PARM_DESC(host_addr, "Host Ethernet Address")
43
24struct eth_dev; 44struct eth_dev;
25 45
26/* 46/*
@@ -71,8 +91,9 @@ struct gether {
71 |USB_CDC_PACKET_TYPE_DIRECTED) 91 |USB_CDC_PACKET_TYPE_DIRECTED)
72 92
73/* variant of gether_setup that allows customizing network device name */ 93/* variant of gether_setup that allows customizing network device name */
74struct eth_dev *gether_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN], 94struct eth_dev *gether_setup_name(struct usb_gadget *g,
75 const char *netname); 95 const char *dev_addr, const char *host_addr,
96 u8 ethaddr[ETH_ALEN], unsigned qmult, const char *netname);
76 97
77/* netdev setup/teardown as directed by the gadget driver */ 98/* netdev setup/teardown as directed by the gadget driver */
78/* gether_setup - initialize one ethernet-over-usb link 99/* gether_setup - initialize one ethernet-over-usb link
@@ -88,9 +109,10 @@ struct eth_dev *gether_setup_name(struct usb_gadget *g, u8 ethaddr[ETH_ALEN],
88 * Returns negative errno, or zero on success 109 * Returns negative errno, or zero on success
89 */ 110 */
90static inline struct eth_dev *gether_setup(struct usb_gadget *g, 111static inline struct eth_dev *gether_setup(struct usb_gadget *g,
91 u8 ethaddr[ETH_ALEN]) 112 const char *dev_addr, const char *host_addr,
113 u8 ethaddr[ETH_ALEN], unsigned qmult)
92{ 114{
93 return gether_setup_name(g, ethaddr, "usb"); 115 return gether_setup_name(g, dev_addr, host_addr, ethaddr, qmult, "usb");
94} 116}
95 117
96void gether_cleanup(struct eth_dev *dev); 118void gether_cleanup(struct eth_dev *dev);