f_eem.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /*
  2. * f_eem.c -- USB CDC Ethernet (EEM) link function driver
  3. *
  4. * Copyright (C) 2003-2005,2008 David Brownell
  5. * Copyright (C) 2008 Nokia Corporation
  6. * Copyright (C) 2009 EF Johnson Technologies
  7. *
  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. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <linux/device.h>
  16. #include <linux/etherdevice.h>
  17. #include <linux/crc32.h>
  18. #include <linux/slab.h>
  19. #include "u_ether.h"
  20. #include "u_ether_configfs.h"
  21. #include "u_eem.h"
  22. #define EEM_HLEN 2
  23. /*
  24. * This function is a "CDC Ethernet Emulation Model" (CDC EEM)
  25. * Ethernet link.
  26. */
  27. struct f_eem {
  28. struct gether port;
  29. u8 ctrl_id;
  30. };
  31. static inline struct f_eem *func_to_eem(struct usb_function *f)
  32. {
  33. return container_of(f, struct f_eem, port.func);
  34. }
  35. /*-------------------------------------------------------------------------*/
  36. /* interface descriptor: */
  37. static struct usb_interface_descriptor eem_intf = {
  38. .bLength = sizeof eem_intf,
  39. .bDescriptorType = USB_DT_INTERFACE,
  40. /* .bInterfaceNumber = DYNAMIC */
  41. .bNumEndpoints = 2,
  42. .bInterfaceClass = USB_CLASS_COMM,
  43. .bInterfaceSubClass = USB_CDC_SUBCLASS_EEM,
  44. .bInterfaceProtocol = USB_CDC_PROTO_EEM,
  45. /* .iInterface = DYNAMIC */
  46. };
  47. /* full speed support: */
  48. static struct usb_endpoint_descriptor eem_fs_in_desc = {
  49. .bLength = USB_DT_ENDPOINT_SIZE,
  50. .bDescriptorType = USB_DT_ENDPOINT,
  51. .bEndpointAddress = USB_DIR_IN,
  52. .bmAttributes = USB_ENDPOINT_XFER_BULK,
  53. };
  54. static struct usb_endpoint_descriptor eem_fs_out_desc = {
  55. .bLength = USB_DT_ENDPOINT_SIZE,
  56. .bDescriptorType = USB_DT_ENDPOINT,
  57. .bEndpointAddress = USB_DIR_OUT,
  58. .bmAttributes = USB_ENDPOINT_XFER_BULK,
  59. };
  60. static struct usb_descriptor_header *eem_fs_function[] = {
  61. /* CDC EEM control descriptors */
  62. (struct usb_descriptor_header *) &eem_intf,
  63. (struct usb_descriptor_header *) &eem_fs_in_desc,
  64. (struct usb_descriptor_header *) &eem_fs_out_desc,
  65. NULL,
  66. };
  67. /* high speed support: */
  68. static struct usb_endpoint_descriptor eem_hs_in_desc = {
  69. .bLength = USB_DT_ENDPOINT_SIZE,
  70. .bDescriptorType = USB_DT_ENDPOINT,
  71. .bEndpointAddress = USB_DIR_IN,
  72. .bmAttributes = USB_ENDPOINT_XFER_BULK,
  73. .wMaxPacketSize = cpu_to_le16(512),
  74. };
  75. static struct usb_endpoint_descriptor eem_hs_out_desc = {
  76. .bLength = USB_DT_ENDPOINT_SIZE,
  77. .bDescriptorType = USB_DT_ENDPOINT,
  78. .bEndpointAddress = USB_DIR_OUT,
  79. .bmAttributes = USB_ENDPOINT_XFER_BULK,
  80. .wMaxPacketSize = cpu_to_le16(512),
  81. };
  82. static struct usb_descriptor_header *eem_hs_function[] = {
  83. /* CDC EEM control descriptors */
  84. (struct usb_descriptor_header *) &eem_intf,
  85. (struct usb_descriptor_header *) &eem_hs_in_desc,
  86. (struct usb_descriptor_header *) &eem_hs_out_desc,
  87. NULL,
  88. };
  89. /* super speed support: */
  90. static struct usb_endpoint_descriptor eem_ss_in_desc = {
  91. .bLength = USB_DT_ENDPOINT_SIZE,
  92. .bDescriptorType = USB_DT_ENDPOINT,
  93. .bEndpointAddress = USB_DIR_IN,
  94. .bmAttributes = USB_ENDPOINT_XFER_BULK,
  95. .wMaxPacketSize = cpu_to_le16(1024),
  96. };
  97. static struct usb_endpoint_descriptor eem_ss_out_desc = {
  98. .bLength = USB_DT_ENDPOINT_SIZE,
  99. .bDescriptorType = USB_DT_ENDPOINT,
  100. .bEndpointAddress = USB_DIR_OUT,
  101. .bmAttributes = USB_ENDPOINT_XFER_BULK,
  102. .wMaxPacketSize = cpu_to_le16(1024),
  103. };
  104. static struct usb_ss_ep_comp_descriptor eem_ss_bulk_comp_desc = {
  105. .bLength = sizeof eem_ss_bulk_comp_desc,
  106. .bDescriptorType = USB_DT_SS_ENDPOINT_COMP,
  107. /* the following 2 values can be tweaked if necessary */
  108. /* .bMaxBurst = 0, */
  109. /* .bmAttributes = 0, */
  110. };
  111. static struct usb_descriptor_header *eem_ss_function[] = {
  112. /* CDC EEM control descriptors */
  113. (struct usb_descriptor_header *) &eem_intf,
  114. (struct usb_descriptor_header *) &eem_ss_in_desc,
  115. (struct usb_descriptor_header *) &eem_ss_bulk_comp_desc,
  116. (struct usb_descriptor_header *) &eem_ss_out_desc,
  117. (struct usb_descriptor_header *) &eem_ss_bulk_comp_desc,
  118. NULL,
  119. };
  120. /* string descriptors: */
  121. static struct usb_string eem_string_defs[] = {
  122. [0].s = "CDC Ethernet Emulation Model (EEM)",
  123. { } /* end of list */
  124. };
  125. static struct usb_gadget_strings eem_string_table = {
  126. .language = 0x0409, /* en-us */
  127. .strings = eem_string_defs,
  128. };
  129. static struct usb_gadget_strings *eem_strings[] = {
  130. &eem_string_table,
  131. NULL,
  132. };
  133. /*-------------------------------------------------------------------------*/
  134. static int eem_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
  135. {
  136. struct usb_composite_dev *cdev = f->config->cdev;
  137. int value = -EOPNOTSUPP;
  138. u16 w_index = le16_to_cpu(ctrl->wIndex);
  139. u16 w_value = le16_to_cpu(ctrl->wValue);
  140. u16 w_length = le16_to_cpu(ctrl->wLength);
  141. DBG(cdev, "invalid control req%02x.%02x v%04x i%04x l%d\n",
  142. ctrl->bRequestType, ctrl->bRequest,
  143. w_value, w_index, w_length);
  144. /* device either stalls (value < 0) or reports success */
  145. return value;
  146. }
  147. static int eem_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
  148. {
  149. struct f_eem *eem = func_to_eem(f);
  150. struct usb_composite_dev *cdev = f->config->cdev;
  151. struct net_device *net;
  152. /* we know alt == 0, so this is an activation or a reset */
  153. if (alt != 0)
  154. goto fail;
  155. if (intf == eem->ctrl_id) {
  156. if (eem->port.in_ep->driver_data) {
  157. DBG(cdev, "reset eem\n");
  158. gether_disconnect(&eem->port);
  159. }
  160. if (!eem->port.in_ep->desc || !eem->port.out_ep->desc) {
  161. DBG(cdev, "init eem\n");
  162. if (config_ep_by_speed(cdev->gadget, f,
  163. eem->port.in_ep) ||
  164. config_ep_by_speed(cdev->gadget, f,
  165. eem->port.out_ep)) {
  166. eem->port.in_ep->desc = NULL;
  167. eem->port.out_ep->desc = NULL;
  168. goto fail;
  169. }
  170. }
  171. /* zlps should not occur because zero-length EEM packets
  172. * will be inserted in those cases where they would occur
  173. */
  174. eem->port.is_zlp_ok = 1;
  175. eem->port.cdc_filter = DEFAULT_FILTER;
  176. DBG(cdev, "activate eem\n");
  177. net = gether_connect(&eem->port);
  178. if (IS_ERR(net))
  179. return PTR_ERR(net);
  180. } else
  181. goto fail;
  182. return 0;
  183. fail:
  184. return -EINVAL;
  185. }
  186. static void eem_disable(struct usb_function *f)
  187. {
  188. struct f_eem *eem = func_to_eem(f);
  189. struct usb_composite_dev *cdev = f->config->cdev;
  190. DBG(cdev, "eem deactivated\n");
  191. if (eem->port.in_ep->driver_data)
  192. gether_disconnect(&eem->port);
  193. }
  194. /*-------------------------------------------------------------------------*/
  195. /* EEM function driver setup/binding */
  196. static int eem_bind(struct usb_configuration *c, struct usb_function *f)
  197. {
  198. struct usb_composite_dev *cdev = c->cdev;
  199. struct f_eem *eem = func_to_eem(f);
  200. struct usb_string *us;
  201. int status;
  202. struct usb_ep *ep;
  203. struct f_eem_opts *eem_opts;
  204. eem_opts = container_of(f->fi, struct f_eem_opts, func_inst);
  205. /*
  206. * in drivers/usb/gadget/configfs.c:configfs_composite_bind()
  207. * configurations are bound in sequence with list_for_each_entry,
  208. * in each configuration its functions are bound in sequence
  209. * with list_for_each_entry, so we assume no race condition
  210. * with regard to eem_opts->bound access
  211. */
  212. if (!eem_opts->bound) {
  213. mutex_lock(&eem_opts->lock);
  214. gether_set_gadget(eem_opts->net, cdev->gadget);
  215. status = gether_register_netdev(eem_opts->net);
  216. mutex_unlock(&eem_opts->lock);
  217. if (status)
  218. return status;
  219. eem_opts->bound = true;
  220. }
  221. us = usb_gstrings_attach(cdev, eem_strings,
  222. ARRAY_SIZE(eem_string_defs));
  223. if (IS_ERR(us))
  224. return PTR_ERR(us);
  225. eem_intf.iInterface = us[0].id;
  226. /* allocate instance-specific interface IDs */
  227. status = usb_interface_id(c, f);
  228. if (status < 0)
  229. goto fail;
  230. eem->ctrl_id = status;
  231. eem_intf.bInterfaceNumber = status;
  232. status = -ENODEV;
  233. /* allocate instance-specific endpoints */
  234. ep = usb_ep_autoconfig(cdev->gadget, &eem_fs_in_desc);
  235. if (!ep)
  236. goto fail;
  237. eem->port.in_ep = ep;
  238. ep->driver_data = cdev; /* claim */
  239. ep = usb_ep_autoconfig(cdev->gadget, &eem_fs_out_desc);
  240. if (!ep)
  241. goto fail;
  242. eem->port.out_ep = ep;
  243. ep->driver_data = cdev; /* claim */
  244. status = -ENOMEM;
  245. /* support all relevant hardware speeds... we expect that when
  246. * hardware is dual speed, all bulk-capable endpoints work at
  247. * both speeds
  248. */
  249. eem_hs_in_desc.bEndpointAddress = eem_fs_in_desc.bEndpointAddress;
  250. eem_hs_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress;
  251. eem_ss_in_desc.bEndpointAddress = eem_fs_in_desc.bEndpointAddress;
  252. eem_ss_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress;
  253. status = usb_assign_descriptors(f, eem_fs_function, eem_hs_function,
  254. eem_ss_function);
  255. if (status)
  256. goto fail;
  257. DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n",
  258. gadget_is_superspeed(c->cdev->gadget) ? "super" :
  259. gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full",
  260. eem->port.in_ep->name, eem->port.out_ep->name);
  261. return 0;
  262. fail:
  263. usb_free_all_descriptors(f);
  264. if (eem->port.out_ep)
  265. eem->port.out_ep->driver_data = NULL;
  266. if (eem->port.in_ep)
  267. eem->port.in_ep->driver_data = NULL;
  268. ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
  269. return status;
  270. }
  271. static void eem_cmd_complete(struct usb_ep *ep, struct usb_request *req)
  272. {
  273. struct sk_buff *skb = (struct sk_buff *)req->context;
  274. dev_kfree_skb_any(skb);
  275. }
  276. /*
  277. * Add the EEM header and ethernet checksum.
  278. * We currently do not attempt to put multiple ethernet frames
  279. * into a single USB transfer
  280. */
  281. static struct sk_buff *eem_wrap(struct gether *port, struct sk_buff *skb)
  282. {
  283. struct sk_buff *skb2 = NULL;
  284. struct usb_ep *in = port->in_ep;
  285. int padlen = 0;
  286. u16 len = skb->len;
  287. if (!skb_cloned(skb)) {
  288. int headroom = skb_headroom(skb);
  289. int tailroom = skb_tailroom(skb);
  290. /* When (len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) is 0,
  291. * stick two bytes of zero-length EEM packet on the end.
  292. */
  293. if (((len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) == 0)
  294. padlen += 2;
  295. if ((tailroom >= (ETH_FCS_LEN + padlen)) &&
  296. (headroom >= EEM_HLEN))
  297. goto done;
  298. }
  299. skb2 = skb_copy_expand(skb, EEM_HLEN, ETH_FCS_LEN + padlen, GFP_ATOMIC);
  300. dev_kfree_skb_any(skb);
  301. skb = skb2;
  302. if (!skb)
  303. return skb;
  304. done:
  305. /* use the "no CRC" option */
  306. put_unaligned_be32(0xdeadbeef, skb_put(skb, 4));
  307. /* EEM packet header format:
  308. * b0..13: length of ethernet frame
  309. * b14: bmCRC (0 == sentinel CRC)
  310. * b15: bmType (0 == data)
  311. */
  312. len = skb->len;
  313. put_unaligned_le16(len & 0x3FFF, skb_push(skb, 2));
  314. /* add a zero-length EEM packet, if needed */
  315. if (padlen)
  316. put_unaligned_le16(0, skb_put(skb, 2));
  317. return skb;
  318. }
  319. /*
  320. * Remove the EEM header. Note that there can be many EEM packets in a single
  321. * USB transfer, so we need to break them out and handle them independently.
  322. */
  323. static int eem_unwrap(struct gether *port,
  324. struct sk_buff *skb,
  325. struct sk_buff_head *list)
  326. {
  327. struct usb_composite_dev *cdev = port->func.config->cdev;
  328. int status = 0;
  329. do {
  330. struct sk_buff *skb2;
  331. u16 header;
  332. u16 len = 0;
  333. if (skb->len < EEM_HLEN) {
  334. status = -EINVAL;
  335. DBG(cdev, "invalid EEM header\n");
  336. goto error;
  337. }
  338. /* remove the EEM header */
  339. header = get_unaligned_le16(skb->data);
  340. skb_pull(skb, EEM_HLEN);
  341. /* EEM packet header format:
  342. * b0..14: EEM type dependent (data or command)
  343. * b15: bmType (0 == data, 1 == command)
  344. */
  345. if (header & BIT(15)) {
  346. struct usb_request *req = cdev->req;
  347. u16 bmEEMCmd;
  348. /* EEM command packet format:
  349. * b0..10: bmEEMCmdParam
  350. * b11..13: bmEEMCmd
  351. * b14: reserved (must be zero)
  352. * b15: bmType (1 == command)
  353. */
  354. if (header & BIT(14))
  355. continue;
  356. bmEEMCmd = (header >> 11) & 0x7;
  357. switch (bmEEMCmd) {
  358. case 0: /* echo */
  359. len = header & 0x7FF;
  360. if (skb->len < len) {
  361. status = -EOVERFLOW;
  362. goto error;
  363. }
  364. skb2 = skb_clone(skb, GFP_ATOMIC);
  365. if (unlikely(!skb2)) {
  366. DBG(cdev, "EEM echo response error\n");
  367. goto next;
  368. }
  369. skb_trim(skb2, len);
  370. put_unaligned_le16(BIT(15) | BIT(11) | len,
  371. skb_push(skb2, 2));
  372. skb_copy_bits(skb2, 0, req->buf, skb2->len);
  373. req->length = skb2->len;
  374. req->complete = eem_cmd_complete;
  375. req->zero = 1;
  376. req->context = skb2;
  377. if (usb_ep_queue(port->in_ep, req, GFP_ATOMIC))
  378. DBG(cdev, "echo response queue fail\n");
  379. break;
  380. case 1: /* echo response */
  381. case 2: /* suspend hint */
  382. case 3: /* response hint */
  383. case 4: /* response complete hint */
  384. case 5: /* tickle */
  385. default: /* reserved */
  386. continue;
  387. }
  388. } else {
  389. u32 crc, crc2;
  390. struct sk_buff *skb3;
  391. /* check for zero-length EEM packet */
  392. if (header == 0)
  393. continue;
  394. /* EEM data packet format:
  395. * b0..13: length of ethernet frame
  396. * b14: bmCRC (0 == sentinel, 1 == calculated)
  397. * b15: bmType (0 == data)
  398. */
  399. len = header & 0x3FFF;
  400. if ((skb->len < len)
  401. || (len < (ETH_HLEN + ETH_FCS_LEN))) {
  402. status = -EINVAL;
  403. goto error;
  404. }
  405. /* validate CRC */
  406. if (header & BIT(14)) {
  407. crc = get_unaligned_le32(skb->data + len
  408. - ETH_FCS_LEN);
  409. crc2 = ~crc32_le(~0,
  410. skb->data, len - ETH_FCS_LEN);
  411. } else {
  412. crc = get_unaligned_be32(skb->data + len
  413. - ETH_FCS_LEN);
  414. crc2 = 0xdeadbeef;
  415. }
  416. if (crc != crc2) {
  417. DBG(cdev, "invalid EEM CRC\n");
  418. goto next;
  419. }
  420. skb2 = skb_clone(skb, GFP_ATOMIC);
  421. if (unlikely(!skb2)) {
  422. DBG(cdev, "unable to unframe EEM packet\n");
  423. continue;
  424. }
  425. skb_trim(skb2, len - ETH_FCS_LEN);
  426. skb3 = skb_copy_expand(skb2,
  427. NET_IP_ALIGN,
  428. 0,
  429. GFP_ATOMIC);
  430. if (unlikely(!skb3)) {
  431. DBG(cdev, "unable to realign EEM packet\n");
  432. dev_kfree_skb_any(skb2);
  433. continue;
  434. }
  435. dev_kfree_skb_any(skb2);
  436. skb_queue_tail(list, skb3);
  437. }
  438. next:
  439. skb_pull(skb, len);
  440. } while (skb->len);
  441. error:
  442. dev_kfree_skb_any(skb);
  443. return status;
  444. }
  445. static inline struct f_eem_opts *to_f_eem_opts(struct config_item *item)
  446. {
  447. return container_of(to_config_group(item), struct f_eem_opts,
  448. func_inst.group);
  449. }
  450. /* f_eem_item_ops */
  451. USB_ETHERNET_CONFIGFS_ITEM(eem);
  452. /* f_eem_opts_dev_addr */
  453. USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(eem);
  454. /* f_eem_opts_host_addr */
  455. USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(eem);
  456. /* f_eem_opts_qmult */
  457. USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(eem);
  458. /* f_eem_opts_ifname */
  459. USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem);
  460. static struct configfs_attribute *eem_attrs[] = {
  461. &f_eem_opts_dev_addr.attr,
  462. &f_eem_opts_host_addr.attr,
  463. &f_eem_opts_qmult.attr,
  464. &f_eem_opts_ifname.attr,
  465. NULL,
  466. };
  467. static struct config_item_type eem_func_type = {
  468. .ct_item_ops = &eem_item_ops,
  469. .ct_attrs = eem_attrs,
  470. .ct_owner = THIS_MODULE,
  471. };
  472. static void eem_free_inst(struct usb_function_instance *f)
  473. {
  474. struct f_eem_opts *opts;
  475. opts = container_of(f, struct f_eem_opts, func_inst);
  476. if (opts->bound)
  477. gether_cleanup(netdev_priv(opts->net));
  478. else
  479. free_netdev(opts->net);
  480. kfree(opts);
  481. }
  482. static struct usb_function_instance *eem_alloc_inst(void)
  483. {
  484. struct f_eem_opts *opts;
  485. opts = kzalloc(sizeof(*opts), GFP_KERNEL);
  486. if (!opts)
  487. return ERR_PTR(-ENOMEM);
  488. mutex_init(&opts->lock);
  489. opts->func_inst.free_func_inst = eem_free_inst;
  490. opts->net = gether_setup_default();
  491. if (IS_ERR(opts->net))
  492. return ERR_CAST(opts->net);
  493. config_group_init_type_name(&opts->func_inst.group, "", &eem_func_type);
  494. return &opts->func_inst;
  495. }
  496. static void eem_free(struct usb_function *f)
  497. {
  498. struct f_eem *eem;
  499. struct f_eem_opts *opts;
  500. eem = func_to_eem(f);
  501. opts = container_of(f->fi, struct f_eem_opts, func_inst);
  502. kfree(eem);
  503. mutex_lock(&opts->lock);
  504. opts->refcnt--;
  505. mutex_unlock(&opts->lock);
  506. }
  507. static void eem_unbind(struct usb_configuration *c, struct usb_function *f)
  508. {
  509. DBG(c->cdev, "eem unbind\n");
  510. usb_free_all_descriptors(f);
  511. }
  512. struct usb_function *eem_alloc(struct usb_function_instance *fi)
  513. {
  514. struct f_eem *eem;
  515. struct f_eem_opts *opts;
  516. /* allocate and initialize one new instance */
  517. eem = kzalloc(sizeof(*eem), GFP_KERNEL);
  518. if (!eem)
  519. return ERR_PTR(-ENOMEM);
  520. opts = container_of(fi, struct f_eem_opts, func_inst);
  521. mutex_lock(&opts->lock);
  522. opts->refcnt++;
  523. eem->port.ioport = netdev_priv(opts->net);
  524. mutex_unlock(&opts->lock);
  525. eem->port.cdc_filter = DEFAULT_FILTER;
  526. eem->port.func.name = "cdc_eem";
  527. /* descriptors are per-instance copies */
  528. eem->port.func.bind = eem_bind;
  529. eem->port.func.unbind = eem_unbind;
  530. eem->port.func.set_alt = eem_set_alt;
  531. eem->port.func.setup = eem_setup;
  532. eem->port.func.disable = eem_disable;
  533. eem->port.func.free_func = eem_free;
  534. eem->port.wrap = eem_wrap;
  535. eem->port.unwrap = eem_unwrap;
  536. eem->port.header_len = EEM_HLEN;
  537. return &eem->port.func;
  538. }
  539. DECLARE_USB_FUNCTION_INIT(eem, eem_alloc_inst, eem_alloc);
  540. MODULE_LICENSE("GPL");
  541. MODULE_AUTHOR("David Brownell");