cdc_ether.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. /*
  2. * CDC Ethernet based networking peripherals
  3. * Copyright (C) 2003-2005 by David Brownell
  4. * Copyright (C) 2006 by Ole Andre Vadla Ravnas (ActiveSync)
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. // #define DEBUG // error path messages, extra info
  21. // #define VERBOSE // more; success messages
  22. #include <linux/module.h>
  23. #include <linux/init.h>
  24. #include <linux/netdevice.h>
  25. #include <linux/etherdevice.h>
  26. #include <linux/ethtool.h>
  27. #include <linux/workqueue.h>
  28. #include <linux/mii.h>
  29. #include <linux/usb.h>
  30. #include <linux/usb/cdc.h>
  31. #include <linux/usb/usbnet.h>
  32. #if defined(CONFIG_USB_NET_RNDIS_HOST) || defined(CONFIG_USB_NET_RNDIS_HOST_MODULE)
  33. static int is_rndis(struct usb_interface_descriptor *desc)
  34. {
  35. return (desc->bInterfaceClass == USB_CLASS_COMM &&
  36. desc->bInterfaceSubClass == 2 &&
  37. desc->bInterfaceProtocol == 0xff);
  38. }
  39. static int is_activesync(struct usb_interface_descriptor *desc)
  40. {
  41. return (desc->bInterfaceClass == USB_CLASS_MISC &&
  42. desc->bInterfaceSubClass == 1 &&
  43. desc->bInterfaceProtocol == 1);
  44. }
  45. static int is_wireless_rndis(struct usb_interface_descriptor *desc)
  46. {
  47. return (desc->bInterfaceClass == USB_CLASS_WIRELESS_CONTROLLER &&
  48. desc->bInterfaceSubClass == 1 &&
  49. desc->bInterfaceProtocol == 3);
  50. }
  51. #else
  52. #define is_rndis(desc) 0
  53. #define is_activesync(desc) 0
  54. #define is_wireless_rndis(desc) 0
  55. #endif
  56. static const u8 mbm_guid[16] = {
  57. 0xa3, 0x17, 0xa8, 0x8b, 0x04, 0x5e, 0x4f, 0x01,
  58. 0xa6, 0x07, 0xc0, 0xff, 0xcb, 0x7e, 0x39, 0x2a,
  59. };
  60. /*
  61. * probes control interface, claims data interface, collects the bulk
  62. * endpoints, activates data interface (if needed), maybe sets MTU.
  63. * all pure cdc, except for certain firmware workarounds, and knowing
  64. * that rndis uses one different rule.
  65. */
  66. int usbnet_generic_cdc_bind(struct usbnet *dev, struct usb_interface *intf)
  67. {
  68. u8 *buf = intf->cur_altsetting->extra;
  69. int len = intf->cur_altsetting->extralen;
  70. struct usb_interface_descriptor *d;
  71. struct cdc_state *info = (void *) &dev->data;
  72. int status;
  73. int rndis;
  74. struct usb_driver *driver = driver_of(intf);
  75. struct usb_cdc_mdlm_desc *desc = NULL;
  76. struct usb_cdc_mdlm_detail_desc *detail = NULL;
  77. if (sizeof dev->data < sizeof *info)
  78. return -EDOM;
  79. /* expect strict spec conformance for the descriptors, but
  80. * cope with firmware which stores them in the wrong place
  81. */
  82. if (len == 0 && dev->udev->actconfig->extralen) {
  83. /* Motorola SB4100 (and others: Brad Hards says it's
  84. * from a Broadcom design) put CDC descriptors here
  85. */
  86. buf = dev->udev->actconfig->extra;
  87. len = dev->udev->actconfig->extralen;
  88. if (len)
  89. dev_dbg(&intf->dev,
  90. "CDC descriptors on config\n");
  91. }
  92. /* Maybe CDC descriptors are after the endpoint? This bug has
  93. * been seen on some 2Wire Inc RNDIS-ish products.
  94. */
  95. if (len == 0) {
  96. struct usb_host_endpoint *hep;
  97. hep = intf->cur_altsetting->endpoint;
  98. if (hep) {
  99. buf = hep->extra;
  100. len = hep->extralen;
  101. }
  102. if (len)
  103. dev_dbg(&intf->dev,
  104. "CDC descriptors on endpoint\n");
  105. }
  106. /* this assumes that if there's a non-RNDIS vendor variant
  107. * of cdc-acm, it'll fail RNDIS requests cleanly.
  108. */
  109. rndis = (is_rndis(&intf->cur_altsetting->desc) ||
  110. is_activesync(&intf->cur_altsetting->desc) ||
  111. is_wireless_rndis(&intf->cur_altsetting->desc));
  112. memset(info, 0, sizeof *info);
  113. info->control = intf;
  114. while (len > 3) {
  115. if (buf [1] != USB_DT_CS_INTERFACE)
  116. goto next_desc;
  117. /* use bDescriptorSubType to identify the CDC descriptors.
  118. * We expect devices with CDC header and union descriptors.
  119. * For CDC Ethernet we need the ethernet descriptor.
  120. * For RNDIS, ignore two (pointless) CDC modem descriptors
  121. * in favor of a complicated OID-based RPC scheme doing what
  122. * CDC Ethernet achieves with a simple descriptor.
  123. */
  124. switch (buf [2]) {
  125. case USB_CDC_HEADER_TYPE:
  126. if (info->header) {
  127. dev_dbg(&intf->dev, "extra CDC header\n");
  128. goto bad_desc;
  129. }
  130. info->header = (void *) buf;
  131. if (info->header->bLength != sizeof *info->header) {
  132. dev_dbg(&intf->dev, "CDC header len %u\n",
  133. info->header->bLength);
  134. goto bad_desc;
  135. }
  136. break;
  137. case USB_CDC_ACM_TYPE:
  138. /* paranoia: disambiguate a "real" vendor-specific
  139. * modem interface from an RNDIS non-modem.
  140. */
  141. if (rndis) {
  142. struct usb_cdc_acm_descriptor *acm;
  143. acm = (void *) buf;
  144. if (acm->bmCapabilities) {
  145. dev_dbg(&intf->dev,
  146. "ACM capabilities %02x, "
  147. "not really RNDIS?\n",
  148. acm->bmCapabilities);
  149. goto bad_desc;
  150. }
  151. }
  152. break;
  153. case USB_CDC_UNION_TYPE:
  154. if (info->u) {
  155. dev_dbg(&intf->dev, "extra CDC union\n");
  156. goto bad_desc;
  157. }
  158. info->u = (void *) buf;
  159. if (info->u->bLength != sizeof *info->u) {
  160. dev_dbg(&intf->dev, "CDC union len %u\n",
  161. info->u->bLength);
  162. goto bad_desc;
  163. }
  164. /* we need a master/control interface (what we're
  165. * probed with) and a slave/data interface; union
  166. * descriptors sort this all out.
  167. */
  168. info->control = usb_ifnum_to_if(dev->udev,
  169. info->u->bMasterInterface0);
  170. info->data = usb_ifnum_to_if(dev->udev,
  171. info->u->bSlaveInterface0);
  172. if (!info->control || !info->data) {
  173. dev_dbg(&intf->dev,
  174. "master #%u/%p slave #%u/%p\n",
  175. info->u->bMasterInterface0,
  176. info->control,
  177. info->u->bSlaveInterface0,
  178. info->data);
  179. goto bad_desc;
  180. }
  181. if (info->control != intf) {
  182. dev_dbg(&intf->dev, "bogus CDC Union\n");
  183. /* Ambit USB Cable Modem (and maybe others)
  184. * interchanges master and slave interface.
  185. */
  186. if (info->data == intf) {
  187. info->data = info->control;
  188. info->control = intf;
  189. } else
  190. goto bad_desc;
  191. }
  192. /* a data interface altsetting does the real i/o */
  193. d = &info->data->cur_altsetting->desc;
  194. if (d->bInterfaceClass != USB_CLASS_CDC_DATA) {
  195. dev_dbg(&intf->dev, "slave class %u\n",
  196. d->bInterfaceClass);
  197. goto bad_desc;
  198. }
  199. break;
  200. case USB_CDC_ETHERNET_TYPE:
  201. if (info->ether) {
  202. dev_dbg(&intf->dev, "extra CDC ether\n");
  203. goto bad_desc;
  204. }
  205. info->ether = (void *) buf;
  206. if (info->ether->bLength != sizeof *info->ether) {
  207. dev_dbg(&intf->dev, "CDC ether len %u\n",
  208. info->ether->bLength);
  209. goto bad_desc;
  210. }
  211. dev->hard_mtu = le16_to_cpu(
  212. info->ether->wMaxSegmentSize);
  213. /* because of Zaurus, we may be ignoring the host
  214. * side link address we were given.
  215. */
  216. break;
  217. case USB_CDC_MDLM_TYPE:
  218. if (desc) {
  219. dev_dbg(&intf->dev, "extra MDLM descriptor\n");
  220. goto bad_desc;
  221. }
  222. desc = (void *)buf;
  223. if (desc->bLength != sizeof(*desc))
  224. goto bad_desc;
  225. if (memcmp(&desc->bGUID, mbm_guid, 16))
  226. goto bad_desc;
  227. break;
  228. case USB_CDC_MDLM_DETAIL_TYPE:
  229. if (detail) {
  230. dev_dbg(&intf->dev, "extra MDLM detail descriptor\n");
  231. goto bad_desc;
  232. }
  233. detail = (void *)buf;
  234. if (detail->bGuidDescriptorType == 0) {
  235. if (detail->bLength < (sizeof(*detail) + 1))
  236. goto bad_desc;
  237. } else
  238. goto bad_desc;
  239. break;
  240. }
  241. next_desc:
  242. len -= buf [0]; /* bLength */
  243. buf += buf [0];
  244. }
  245. /* Microsoft ActiveSync based and some regular RNDIS devices lack the
  246. * CDC descriptors, so we'll hard-wire the interfaces and not check
  247. * for descriptors.
  248. */
  249. if (rndis && !info->u) {
  250. info->control = usb_ifnum_to_if(dev->udev, 0);
  251. info->data = usb_ifnum_to_if(dev->udev, 1);
  252. if (!info->control || !info->data) {
  253. dev_dbg(&intf->dev,
  254. "rndis: master #0/%p slave #1/%p\n",
  255. info->control,
  256. info->data);
  257. goto bad_desc;
  258. }
  259. } else if (!info->header || !info->u || (!rndis && !info->ether)) {
  260. dev_dbg(&intf->dev, "missing cdc %s%s%sdescriptor\n",
  261. info->header ? "" : "header ",
  262. info->u ? "" : "union ",
  263. info->ether ? "" : "ether ");
  264. goto bad_desc;
  265. }
  266. /* claim data interface and set it up ... with side effects.
  267. * network traffic can't flow until an altsetting is enabled.
  268. */
  269. status = usb_driver_claim_interface(driver, info->data, dev);
  270. if (status < 0)
  271. return status;
  272. status = usbnet_get_endpoints(dev, info->data);
  273. if (status < 0) {
  274. /* ensure immediate exit from usbnet_disconnect */
  275. usb_set_intfdata(info->data, NULL);
  276. usb_driver_release_interface(driver, info->data);
  277. return status;
  278. }
  279. /* status endpoint: optional for CDC Ethernet, not RNDIS (or ACM) */
  280. dev->status = NULL;
  281. if (info->control->cur_altsetting->desc.bNumEndpoints == 1) {
  282. struct usb_endpoint_descriptor *desc;
  283. dev->status = &info->control->cur_altsetting->endpoint [0];
  284. desc = &dev->status->desc;
  285. if (!usb_endpoint_is_int_in(desc) ||
  286. (le16_to_cpu(desc->wMaxPacketSize)
  287. < sizeof(struct usb_cdc_notification)) ||
  288. !desc->bInterval) {
  289. dev_dbg(&intf->dev, "bad notification endpoint\n");
  290. dev->status = NULL;
  291. }
  292. }
  293. if (rndis && !dev->status) {
  294. dev_dbg(&intf->dev, "missing RNDIS status endpoint\n");
  295. usb_set_intfdata(info->data, NULL);
  296. usb_driver_release_interface(driver, info->data);
  297. return -ENODEV;
  298. }
  299. return 0;
  300. bad_desc:
  301. dev_info(&dev->udev->dev, "bad CDC descriptors\n");
  302. return -ENODEV;
  303. }
  304. EXPORT_SYMBOL_GPL(usbnet_generic_cdc_bind);
  305. void usbnet_cdc_unbind(struct usbnet *dev, struct usb_interface *intf)
  306. {
  307. struct cdc_state *info = (void *) &dev->data;
  308. struct usb_driver *driver = driver_of(intf);
  309. /* disconnect master --> disconnect slave */
  310. if (intf == info->control && info->data) {
  311. /* ensure immediate exit from usbnet_disconnect */
  312. usb_set_intfdata(info->data, NULL);
  313. usb_driver_release_interface(driver, info->data);
  314. info->data = NULL;
  315. }
  316. /* and vice versa (just in case) */
  317. else if (intf == info->data && info->control) {
  318. /* ensure immediate exit from usbnet_disconnect */
  319. usb_set_intfdata(info->control, NULL);
  320. usb_driver_release_interface(driver, info->control);
  321. info->control = NULL;
  322. }
  323. }
  324. EXPORT_SYMBOL_GPL(usbnet_cdc_unbind);
  325. /*-------------------------------------------------------------------------
  326. *
  327. * Communications Device Class, Ethernet Control model
  328. *
  329. * Takes two interfaces. The DATA interface is inactive till an altsetting
  330. * is selected. Configuration data includes class descriptors. There's
  331. * an optional status endpoint on the control interface.
  332. *
  333. * This should interop with whatever the 2.4 "CDCEther.c" driver
  334. * (by Brad Hards) talked with, with more functionality.
  335. *
  336. *-------------------------------------------------------------------------*/
  337. static void dumpspeed(struct usbnet *dev, __le32 *speeds)
  338. {
  339. netif_info(dev, timer, dev->net,
  340. "link speeds: %u kbps up, %u kbps down\n",
  341. __le32_to_cpu(speeds[0]) / 1000,
  342. __le32_to_cpu(speeds[1]) / 1000);
  343. }
  344. static void cdc_status(struct usbnet *dev, struct urb *urb)
  345. {
  346. struct usb_cdc_notification *event;
  347. if (urb->actual_length < sizeof *event)
  348. return;
  349. /* SPEED_CHANGE can get split into two 8-byte packets */
  350. if (test_and_clear_bit(EVENT_STS_SPLIT, &dev->flags)) {
  351. dumpspeed(dev, (__le32 *) urb->transfer_buffer);
  352. return;
  353. }
  354. event = urb->transfer_buffer;
  355. switch (event->bNotificationType) {
  356. case USB_CDC_NOTIFY_NETWORK_CONNECTION:
  357. netif_dbg(dev, timer, dev->net, "CDC: carrier %s\n",
  358. event->wValue ? "on" : "off");
  359. if (event->wValue)
  360. netif_carrier_on(dev->net);
  361. else
  362. netif_carrier_off(dev->net);
  363. break;
  364. case USB_CDC_NOTIFY_SPEED_CHANGE: /* tx/rx rates */
  365. netif_dbg(dev, timer, dev->net, "CDC: speed change (len %d)\n",
  366. urb->actual_length);
  367. if (urb->actual_length != (sizeof *event + 8))
  368. set_bit(EVENT_STS_SPLIT, &dev->flags);
  369. else
  370. dumpspeed(dev, (__le32 *) &event[1]);
  371. break;
  372. /* USB_CDC_NOTIFY_RESPONSE_AVAILABLE can happen too (e.g. RNDIS),
  373. * but there are no standard formats for the response data.
  374. */
  375. default:
  376. netdev_err(dev->net, "CDC: unexpected notification %02x!\n",
  377. event->bNotificationType);
  378. break;
  379. }
  380. }
  381. static int cdc_bind(struct usbnet *dev, struct usb_interface *intf)
  382. {
  383. int status;
  384. struct cdc_state *info = (void *) &dev->data;
  385. status = usbnet_generic_cdc_bind(dev, intf);
  386. if (status < 0)
  387. return status;
  388. status = usbnet_get_ethernet_addr(dev, info->ether->iMACAddress);
  389. if (status < 0) {
  390. usb_set_intfdata(info->data, NULL);
  391. usb_driver_release_interface(driver_of(intf), info->data);
  392. return status;
  393. }
  394. /* FIXME cdc-ether has some multicast code too, though it complains
  395. * in routine cases. info->ether describes the multicast support.
  396. * Implement that here, manipulating the cdc filter as needed.
  397. */
  398. return 0;
  399. }
  400. static int cdc_manage_power(struct usbnet *dev, int on)
  401. {
  402. dev->intf->needs_remote_wakeup = on;
  403. return 0;
  404. }
  405. static const struct driver_info cdc_info = {
  406. .description = "CDC Ethernet Device",
  407. .flags = FLAG_ETHER,
  408. // .check_connect = cdc_check_connect,
  409. .bind = cdc_bind,
  410. .unbind = usbnet_cdc_unbind,
  411. .status = cdc_status,
  412. .manage_power = cdc_manage_power,
  413. };
  414. static const struct driver_info mbm_info = {
  415. .description = "Mobile Broadband Network Device",
  416. .flags = FLAG_WWAN,
  417. .bind = cdc_bind,
  418. .unbind = usbnet_cdc_unbind,
  419. .status = cdc_status,
  420. .manage_power = cdc_manage_power,
  421. };
  422. /*-------------------------------------------------------------------------*/
  423. static const struct usb_device_id products [] = {
  424. /*
  425. * BLACKLIST !!
  426. *
  427. * First blacklist any products that are egregiously nonconformant
  428. * with the CDC Ethernet specs. Minor braindamage we cope with; when
  429. * they're not even trying, needing a separate driver is only the first
  430. * of the differences to show up.
  431. */
  432. #define ZAURUS_MASTER_INTERFACE \
  433. .bInterfaceClass = USB_CLASS_COMM, \
  434. .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \
  435. .bInterfaceProtocol = USB_CDC_PROTO_NONE
  436. /* SA-1100 based Sharp Zaurus ("collie"), or compatible;
  437. * wire-incompatible with true CDC Ethernet implementations.
  438. * (And, it seems, needlessly so...)
  439. */
  440. {
  441. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  442. | USB_DEVICE_ID_MATCH_DEVICE,
  443. .idVendor = 0x04DD,
  444. .idProduct = 0x8004,
  445. ZAURUS_MASTER_INTERFACE,
  446. .driver_info = 0,
  447. },
  448. /* PXA-25x based Sharp Zaurii. Note that it seems some of these
  449. * (later models especially) may have shipped only with firmware
  450. * advertising false "CDC MDLM" compatibility ... but we're not
  451. * clear which models did that, so for now let's assume the worst.
  452. */
  453. {
  454. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  455. | USB_DEVICE_ID_MATCH_DEVICE,
  456. .idVendor = 0x04DD,
  457. .idProduct = 0x8005, /* A-300 */
  458. ZAURUS_MASTER_INTERFACE,
  459. .driver_info = 0,
  460. }, {
  461. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  462. | USB_DEVICE_ID_MATCH_DEVICE,
  463. .idVendor = 0x04DD,
  464. .idProduct = 0x8006, /* B-500/SL-5600 */
  465. ZAURUS_MASTER_INTERFACE,
  466. .driver_info = 0,
  467. }, {
  468. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  469. | USB_DEVICE_ID_MATCH_DEVICE,
  470. .idVendor = 0x04DD,
  471. .idProduct = 0x8007, /* C-700 */
  472. ZAURUS_MASTER_INTERFACE,
  473. .driver_info = 0,
  474. }, {
  475. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  476. | USB_DEVICE_ID_MATCH_DEVICE,
  477. .idVendor = 0x04DD,
  478. .idProduct = 0x9031, /* C-750 C-760 */
  479. ZAURUS_MASTER_INTERFACE,
  480. .driver_info = 0,
  481. }, {
  482. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  483. | USB_DEVICE_ID_MATCH_DEVICE,
  484. .idVendor = 0x04DD,
  485. .idProduct = 0x9032, /* SL-6000 */
  486. ZAURUS_MASTER_INTERFACE,
  487. .driver_info = 0,
  488. }, {
  489. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  490. | USB_DEVICE_ID_MATCH_DEVICE,
  491. .idVendor = 0x04DD,
  492. /* reported with some C860 units */
  493. .idProduct = 0x9050, /* C-860 */
  494. ZAURUS_MASTER_INTERFACE,
  495. .driver_info = 0,
  496. },
  497. /* Olympus has some models with a Zaurus-compatible option.
  498. * R-1000 uses a FreeScale i.MXL cpu (ARMv4T)
  499. */
  500. {
  501. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO
  502. | USB_DEVICE_ID_MATCH_DEVICE,
  503. .idVendor = 0x07B4,
  504. .idProduct = 0x0F02, /* R-1000 */
  505. ZAURUS_MASTER_INTERFACE,
  506. .driver_info = 0,
  507. },
  508. /*
  509. * WHITELIST!!!
  510. *
  511. * CDC Ether uses two interfaces, not necessarily consecutive.
  512. * We match the main interface, ignoring the optional device
  513. * class so we could handle devices that aren't exclusively
  514. * CDC ether.
  515. *
  516. * NOTE: this match must come AFTER entries blacklisting devices
  517. * because of bugs/quirks in a given product (like Zaurus, above).
  518. */
  519. {
  520. USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ETHERNET,
  521. USB_CDC_PROTO_NONE),
  522. .driver_info = (unsigned long) &cdc_info,
  523. }, {
  524. USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_MDLM,
  525. USB_CDC_PROTO_NONE),
  526. .driver_info = (unsigned long)&mbm_info,
  527. },
  528. { }, // END
  529. };
  530. MODULE_DEVICE_TABLE(usb, products);
  531. static struct usb_driver cdc_driver = {
  532. .name = "cdc_ether",
  533. .id_table = products,
  534. .probe = usbnet_probe,
  535. .disconnect = usbnet_disconnect,
  536. .suspend = usbnet_suspend,
  537. .resume = usbnet_resume,
  538. .reset_resume = usbnet_resume,
  539. .supports_autosuspend = 1,
  540. };
  541. static int __init cdc_init(void)
  542. {
  543. BUILD_BUG_ON((sizeof(((struct usbnet *)0)->data)
  544. < sizeof(struct cdc_state)));
  545. return usb_register(&cdc_driver);
  546. }
  547. module_init(cdc_init);
  548. static void __exit cdc_exit(void)
  549. {
  550. usb_deregister(&cdc_driver);
  551. }
  552. module_exit(cdc_exit);
  553. MODULE_AUTHOR("David Brownell");
  554. MODULE_DESCRIPTION("USB CDC Ethernet devices");
  555. MODULE_LICENSE("GPL");