blob: f37de283d0ab769e37c506c24e4e433ba2ffb583 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * ether.c -- Ethernet gadget driver, with CDC and non-CDC options
3 *
David Brownell0391c822008-06-19 18:20:11 -07004 * Copyright (C) 2003-2005,2008 David Brownell
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * Copyright (C) 2003-2004 Robert Schwebel, Benedikt Spranger
David Brownell0391c822008-06-19 18:20:11 -07006 * Copyright (C) 2008 Nokia Corporation
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 */
22
David Brownell0cf4f2d2007-08-02 00:00:38 -070023/* #define VERBOSE_DEBUG */
Linus Torvalds1da177e2005-04-16 15:20:36 -070024
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026#include <linux/utsname.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
David Brownell0391c822008-06-19 18:20:11 -070028#include "u_ether.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31/*
32 * Ethernet gadget driver -- with CDC and non-CDC options
33 * Builds on hardware support for a full duplex link.
34 *
35 * CDC Ethernet is the standard USB solution for sending Ethernet frames
36 * using USB. Real hardware tends to use the same framing protocol but look
37 * different for control features. This driver strongly prefers to use
38 * this USB-IF standard as its open-systems interoperability solution;
39 * most host side USB stacks (except from Microsoft) support it.
40 *
David Brownell0391c822008-06-19 18:20:11 -070041 * This is sometimes called "CDC ECM" (Ethernet Control Model) to support
42 * TLA-soup. "CDC ACM" (Abstract Control Model) is for modems, and a new
43 * "CDC EEM" (Ethernet Emulation Model) is starting to spread.
44 *
45 * There's some hardware that can't talk CDC ECM. We make that hardware
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 * implement a "minimalist" vendor-agnostic CDC core: same framing, but
David Brownell11d54892006-12-11 15:59:04 -080047 * link-level setup only requires activating the configuration. Only the
48 * endpoint descriptors, and product/vendor IDs, are relevant; no control
49 * operations are available. Linux supports it, but other host operating
50 * systems may not. (This is a subset of CDC Ethernet.)
51 *
52 * It turns out that if you add a few descriptors to that "CDC Subset",
53 * (Windows) host side drivers from MCCI can treat it as one submode of
54 * a proprietary scheme called "SAFE" ... without needing to know about
55 * specific product/vendor IDs. So we do that, making it easier to use
56 * those MS-Windows drivers. Those added descriptors make it resemble a
57 * CDC MDLM device, but they don't change device behavior at all. (See
58 * MCCI Engineering report 950198 "SAFE Networking Functions".)
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 *
60 * A third option is also in use. Rather than CDC Ethernet, or something
61 * simpler, Microsoft pushes their own approach: RNDIS. The published
62 * RNDIS specs are ambiguous and appear to be incomplete, and are also
David Brownell0391c822008-06-19 18:20:11 -070063 * needlessly complex. They borrow more from CDC ACM than CDC ECM.
Brian Niebuhr9b39e9d2009-08-14 10:04:22 -050064 *
65 * While CDC ECM, CDC Subset, and RNDIS are designed to extend the ethernet
66 * interface to the target, CDC EEM was designed to use ethernet over the USB
67 * link between the host and target. CDC EEM is implemented as an alternative
68 * to those other protocols when that communication model is more appropriate
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 */
70
71#define DRIVER_DESC "Ethernet Gadget"
David Brownell0391c822008-06-19 18:20:11 -070072#define DRIVER_VERSION "Memorial Day 2008"
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
David Brownell0391c822008-06-19 18:20:11 -070074#ifdef CONFIG_USB_ETH_RNDIS
75#define PREFIX "RNDIS/"
76#else
77#define PREFIX ""
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#endif
79
David Brownell0391c822008-06-19 18:20:11 -070080/*
81 * This driver aims for interoperability by using CDC ECM unless
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 *
David Brownell0391c822008-06-19 18:20:11 -070083 * can_support_ecm()
84 *
85 * returns false, in which case it supports the CDC Subset. By default,
86 * that returns true; most hardware has no problems with CDC ECM, that's
87 * a good default. Previous versions of this driver had no default; this
88 * version changes that, removing overhead for new controller support.
89 *
90 * IF YOUR HARDWARE CAN'T SUPPORT CDC ECM, UPDATE THAT ROUTINE!
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
David Brownell0391c822008-06-19 18:20:11 -070093static inline bool has_rndis(void)
94{
95#ifdef CONFIG_USB_ETH_RNDIS
96 return true;
97#else
98 return false;
99#endif
100}
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102/*-------------------------------------------------------------------------*/
103
David Brownell33376c12008-08-18 17:45:07 -0700104/*
105 * Kbuild is not very cooperative with respect to linking separately
106 * compiled library objects into one module. So for now we won't use
107 * separate compilation ... ensuring init/exit sections work to shrink
108 * the runtime footprint, and giving us at least some parts of what
109 * a "gcc --combine ... part1.c part2.c part3.c ... " build would.
110 */
111#include "composite.c"
112#include "usbstring.c"
113#include "config.c"
114#include "epautoconf.c"
115
116#include "f_ecm.c"
117#include "f_subset.c"
118#ifdef CONFIG_USB_ETH_RNDIS
119#include "f_rndis.c"
120#include "rndis.c"
121#endif
Brian Niebuhr9b39e9d2009-08-14 10:04:22 -0500122#include "f_eem.c"
David Brownell33376c12008-08-18 17:45:07 -0700123#include "u_ether.c"
124
125/*-------------------------------------------------------------------------*/
126
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127/* DO NOT REUSE THESE IDs with a protocol-incompatible driver!! Ever!!
128 * Instead: allocate your own, using normal USB-IF procedures.
129 */
130
131/* Thanks to NetChip Technologies for donating this product ID.
132 * It's for devices with only CDC Ethernet configurations.
133 */
David Brownell0391c822008-06-19 18:20:11 -0700134#define CDC_VENDOR_NUM 0x0525 /* NetChip */
135#define CDC_PRODUCT_NUM 0xa4a1 /* Linux-USB Ethernet Gadget */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137/* For hardware that can't talk CDC, we use the same vendor ID that
138 * ARM Linux has used for ethernet-over-usb, both with sa1100 and
139 * with pxa250. We're protocol-compatible, if the host-side drivers
140 * use the endpoint descriptors. bcdDevice (version) is nonzero, so
141 * drivers that need to hard-wire endpoint numbers have a hook.
142 *
143 * The protocol is a minimal subset of CDC Ether, which works on any bulk
144 * hardware that's not deeply broken ... even on hardware that can't talk
145 * RNDIS (like SA-1100, with no interrupt endpoint, or anything that
146 * doesn't handle control-OUT).
147 */
148#define SIMPLE_VENDOR_NUM 0x049f
149#define SIMPLE_PRODUCT_NUM 0x505a
150
151/* For hardware that can talk RNDIS and either of the above protocols,
152 * use this ID ... the windows INF files will know it. Unless it's
153 * used with CDC Ethernet, Linux 2.4 hosts will need updates to choose
154 * the non-RNDIS configuration.
155 */
156#define RNDIS_VENDOR_NUM 0x0525 /* NetChip */
157#define RNDIS_PRODUCT_NUM 0xa4a2 /* Ethernet/RNDIS Gadget */
158
Brian Niebuhr9b39e9d2009-08-14 10:04:22 -0500159/* For EEM gadgets */
160#define EEM_VENDOR_NUM 0x0525 /* INVALID - NEEDS TO BE ALLOCATED */
161#define EEM_PRODUCT_NUM 0xa4a1 /* INVALID - NEEDS TO BE ALLOCATED */
162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163/*-------------------------------------------------------------------------*/
164
David Brownell0391c822008-06-19 18:20:11 -0700165static struct usb_device_descriptor device_desc = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 .bLength = sizeof device_desc,
167 .bDescriptorType = USB_DT_DEVICE,
168
Harvey Harrison551509d2009-02-11 14:11:36 -0800169 .bcdUSB = cpu_to_le16 (0x0200),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
171 .bDeviceClass = USB_CLASS_COMM,
172 .bDeviceSubClass = 0,
173 .bDeviceProtocol = 0,
David Brownell0391c822008-06-19 18:20:11 -0700174 /* .bMaxPacketSize0 = f(hardware) */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
David Brownell0391c822008-06-19 18:20:11 -0700176 /* Vendor and product id defaults change according to what configs
177 * we support. (As does bNumConfigurations.) These values can
178 * also be overridden by module parameters.
179 */
Harvey Harrison551509d2009-02-11 14:11:36 -0800180 .idVendor = cpu_to_le16 (CDC_VENDOR_NUM),
181 .idProduct = cpu_to_le16 (CDC_PRODUCT_NUM),
David Brownell0391c822008-06-19 18:20:11 -0700182 /* .bcdDevice = f(hardware) */
183 /* .iManufacturer = DYNAMIC */
184 /* .iProduct = DYNAMIC */
185 /* NO SERIAL NUMBER */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 .bNumConfigurations = 1,
187};
188
David Brownell0391c822008-06-19 18:20:11 -0700189static struct usb_otg_descriptor otg_descriptor = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 .bLength = sizeof otg_descriptor,
191 .bDescriptorType = USB_DT_OTG,
192
David Brownell0391c822008-06-19 18:20:11 -0700193 /* REVISIT SRP-only hardware is possible, although
194 * it would not be called "OTG" ...
195 */
196 .bmAttributes = USB_OTG_SRP | USB_OTG_HNP,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197};
198
David Brownell0391c822008-06-19 18:20:11 -0700199static const struct usb_descriptor_header *otg_desc[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 (struct usb_descriptor_header *) &otg_descriptor,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201 NULL,
202};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
David Brownell0391c822008-06-19 18:20:11 -0700205/* string IDs are assigned dynamically */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
David Brownell0391c822008-06-19 18:20:11 -0700207#define STRING_MANUFACTURER_IDX 0
208#define STRING_PRODUCT_IDX 1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
David Brownell0391c822008-06-19 18:20:11 -0700210static char manufacturer[50];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211
David Brownell0391c822008-06-19 18:20:11 -0700212static struct usb_string strings_dev[] = {
213 [STRING_MANUFACTURER_IDX].s = manufacturer,
214 [STRING_PRODUCT_IDX].s = PREFIX DRIVER_DESC,
215 { } /* end of list */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216};
217
David Brownell0391c822008-06-19 18:20:11 -0700218static struct usb_gadget_strings stringtab_dev = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 .language = 0x0409, /* en-us */
David Brownell0391c822008-06-19 18:20:11 -0700220 .strings = strings_dev,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221};
222
David Brownell0391c822008-06-19 18:20:11 -0700223static struct usb_gadget_strings *dev_strings[] = {
224 &stringtab_dev,
225 NULL,
226};
227
228static u8 hostaddr[ETH_ALEN];
229
230/*-------------------------------------------------------------------------*/
231
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232/*
David Brownell0391c822008-06-19 18:20:11 -0700233 * We may not have an RNDIS configuration, but if we do it needs to be
234 * the first one present. That's to make Microsoft's drivers happy,
235 * and to follow DOCSIS 1.0 (cable modem standard).
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 */
David Brownell0391c822008-06-19 18:20:11 -0700237static int __init rndis_do_config(struct usb_configuration *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238{
David Brownell0391c822008-06-19 18:20:11 -0700239 /* FIXME alloc iConfiguration string, set it in c->strings */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240
David Brownell0391c822008-06-19 18:20:11 -0700241 if (gadget_is_otg(c->cdev->gadget)) {
242 c->descriptors = otg_desc;
243 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 }
245
David Brownell0391c822008-06-19 18:20:11 -0700246 return rndis_bind_config(c, hostaddr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247}
248
David Brownell0391c822008-06-19 18:20:11 -0700249static struct usb_configuration rndis_config_driver = {
250 .label = "RNDIS",
251 .bind = rndis_do_config,
252 .bConfigurationValue = 2,
253 /* .iConfiguration = DYNAMIC */
254 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
David Brownell0391c822008-06-19 18:20:11 -0700255};
256
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257/*-------------------------------------------------------------------------*/
258
Brian Niebuhr9b39e9d2009-08-14 10:04:22 -0500259#ifdef CONFIG_USB_ETH_EEM
260static int use_eem = 1;
261#else
262static int use_eem;
263#endif
264module_param(use_eem, bool, 0);
265MODULE_PARM_DESC(use_eem, "use CDC EEM mode");
266
David Brownell0391c822008-06-19 18:20:11 -0700267/*
Brian Niebuhr9b39e9d2009-08-14 10:04:22 -0500268 * We _always_ have an ECM, CDC Subset, or EEM configuration.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269 */
David Brownell0391c822008-06-19 18:20:11 -0700270static int __init eth_do_config(struct usb_configuration *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271{
David Brownell0391c822008-06-19 18:20:11 -0700272 /* FIXME alloc iConfiguration string, set it in c->strings */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
David Brownell0391c822008-06-19 18:20:11 -0700274 if (gadget_is_otg(c->cdev->gadget)) {
275 c->descriptors = otg_desc;
276 c->bmAttributes |= USB_CONFIG_ATT_WAKEUP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 }
278
Brian Niebuhr9b39e9d2009-08-14 10:04:22 -0500279 if (use_eem)
280 return eem_bind_config(c);
281 else if (can_support_ecm(c->cdev->gadget))
David Brownell0391c822008-06-19 18:20:11 -0700282 return ecm_bind_config(c, hostaddr);
283 else
284 return geth_bind_config(c, hostaddr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285}
286
David Brownell0391c822008-06-19 18:20:11 -0700287static struct usb_configuration eth_config_driver = {
288 /* .label = f(hardware) */
289 .bind = eth_do_config,
290 .bConfigurationValue = 1,
291 /* .iConfiguration = DYNAMIC */
292 .bmAttributes = USB_CONFIG_ATT_SELFPOWER,
David Brownell0391c822008-06-19 18:20:11 -0700293};
294
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295/*-------------------------------------------------------------------------*/
296
David Brownell0391c822008-06-19 18:20:11 -0700297static int __init eth_bind(struct usb_composite_dev *cdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298{
David Brownell0391c822008-06-19 18:20:11 -0700299 int gcnum;
300 struct usb_gadget *gadget = cdev->gadget;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 int status;
David Brownell7e27f182006-06-13 09:54:40 -0700302
David Brownell0391c822008-06-19 18:20:11 -0700303 /* set up network link layer */
304 status = gether_setup(cdev->gadget, hostaddr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305 if (status < 0)
David Brownell0391c822008-06-19 18:20:11 -0700306 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307
David Brownell0391c822008-06-19 18:20:11 -0700308 /* set up main config label and device descriptor */
Brian Niebuhr9b39e9d2009-08-14 10:04:22 -0500309 if (use_eem) {
310 /* EEM */
311 eth_config_driver.label = "CDC Ethernet (EEM)";
312 device_desc.idVendor = cpu_to_le16(EEM_VENDOR_NUM);
313 device_desc.idProduct = cpu_to_le16(EEM_PRODUCT_NUM);
314 } else if (can_support_ecm(cdev->gadget)) {
David Brownell0391c822008-06-19 18:20:11 -0700315 /* ECM */
316 eth_config_driver.label = "CDC Ethernet (ECM)";
317 } else {
318 /* CDC Subset */
319 eth_config_driver.label = "CDC Subset/SAFE";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320
David Brownell4e19f222009-06-19 03:09:04 -0700321 device_desc.idVendor = cpu_to_le16(SIMPLE_VENDOR_NUM);
322 device_desc.idProduct = cpu_to_le16(SIMPLE_PRODUCT_NUM);
323 if (!has_rndis())
324 device_desc.bDeviceClass = USB_CLASS_VENDOR_SPEC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 }
326
David Brownell0391c822008-06-19 18:20:11 -0700327 if (has_rndis()) {
328 /* RNDIS plus ECM-or-Subset */
David Brownell4e19f222009-06-19 03:09:04 -0700329 device_desc.idVendor = cpu_to_le16(RNDIS_VENDOR_NUM);
330 device_desc.idProduct = cpu_to_le16(RNDIS_PRODUCT_NUM);
David Brownell0391c822008-06-19 18:20:11 -0700331 device_desc.bNumConfigurations = 2;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 }
333
David Brownell0391c822008-06-19 18:20:11 -0700334 gcnum = usb_gadget_controller_number(gadget);
David Brownell91e79c92005-07-13 15:18:30 -0700335 if (gcnum >= 0)
David Brownell0391c822008-06-19 18:20:11 -0700336 device_desc.bcdDevice = cpu_to_le16(0x0300 | gcnum);
David Brownell91e79c92005-07-13 15:18:30 -0700337 else {
David Brownell0391c822008-06-19 18:20:11 -0700338 /* We assume that can_support_ecm() tells the truth;
339 * but if the controller isn't recognized at all then
340 * that assumption is a bit more likely to be wrong.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 */
David Brownell33376c12008-08-18 17:45:07 -0700342 dev_warn(&gadget->dev,
343 "controller '%s' not recognized; trying %s\n",
David Brownell0391c822008-06-19 18:20:11 -0700344 gadget->name,
345 eth_config_driver.label);
346 device_desc.bcdDevice =
Harvey Harrison551509d2009-02-11 14:11:36 -0800347 cpu_to_le16(0x0300 | 0x0099);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 }
David Brownell0391c822008-06-19 18:20:11 -0700349
350
351 /* Allocate string descriptor numbers ... note that string
352 * contents can be overridden by the composite_dev glue.
353 */
354
355 /* device descriptor strings: manufacturer, product */
356 snprintf(manufacturer, sizeof manufacturer, "%s %s with %s",
Serge E. Hallyn96b644b2006-10-02 02:18:13 -0700357 init_utsname()->sysname, init_utsname()->release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 gadget->name);
David Brownell0391c822008-06-19 18:20:11 -0700359 status = usb_string_id(cdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 if (status < 0)
David Brownell0391c822008-06-19 18:20:11 -0700361 goto fail;
362 strings_dev[STRING_MANUFACTURER_IDX].id = status;
363 device_desc.iManufacturer = status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364
David Brownell0391c822008-06-19 18:20:11 -0700365 status = usb_string_id(cdev);
366 if (status < 0)
367 goto fail;
368 strings_dev[STRING_PRODUCT_IDX].id = status;
369 device_desc.iProduct = status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370
David Brownell0391c822008-06-19 18:20:11 -0700371 /* register our configuration(s); RNDIS first, if it's used */
372 if (has_rndis()) {
373 status = usb_add_config(cdev, &rndis_config_driver);
374 if (status < 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 goto fail;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
David Brownell0391c822008-06-19 18:20:11 -0700378 status = usb_add_config(cdev, &eth_config_driver);
379 if (status < 0)
380 goto fail;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381
David Brownell33376c12008-08-18 17:45:07 -0700382 dev_info(&gadget->dev, "%s, version: " DRIVER_VERSION "\n",
383 DRIVER_DESC);
David Brownell0391c822008-06-19 18:20:11 -0700384
385 return 0;
386
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387fail:
David Brownell0391c822008-06-19 18:20:11 -0700388 gether_cleanup();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 return status;
390}
391
David Brownell0391c822008-06-19 18:20:11 -0700392static int __exit eth_unbind(struct usb_composite_dev *cdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393{
David Brownell0391c822008-06-19 18:20:11 -0700394 gether_cleanup();
395 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396}
397
David Brownell0391c822008-06-19 18:20:11 -0700398static struct usb_composite_driver eth_driver = {
399 .name = "g_ether",
400 .dev = &device_desc,
401 .strings = dev_strings,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 .bind = eth_bind,
David Brownell0391c822008-06-19 18:20:11 -0700403 .unbind = __exit_p(eth_unbind),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404};
405
David Brownell0391c822008-06-19 18:20:11 -0700406MODULE_DESCRIPTION(PREFIX DRIVER_DESC);
407MODULE_AUTHOR("David Brownell, Benedikt Spanger");
408MODULE_LICENSE("GPL");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409
David Brownell0391c822008-06-19 18:20:11 -0700410static int __init init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411{
David Brownell0391c822008-06-19 18:20:11 -0700412 return usb_composite_register(&eth_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413}
David Brownell0391c822008-06-19 18:20:11 -0700414module_init(init);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415
David Brownell0391c822008-06-19 18:20:11 -0700416static void __exit cleanup(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417{
David Brownell0391c822008-06-19 18:20:11 -0700418 usb_composite_unregister(&eth_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419}
David Brownell0391c822008-06-19 18:20:11 -0700420module_exit(cleanup);