f_eem.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  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. DBG(cdev, "reset eem\n");
  157. gether_disconnect(&eem->port);
  158. if (!eem->port.in_ep->desc || !eem->port.out_ep->desc) {
  159. DBG(cdev, "init eem\n");
  160. if (config_ep_by_speed(cdev->gadget, f,
  161. eem->port.in_ep) ||
  162. config_ep_by_speed(cdev->gadget, f,
  163. eem->port.out_ep)) {
  164. eem->port.in_ep->desc = NULL;
  165. eem->port.out_ep->desc = NULL;
  166. goto fail;
  167. }
  168. }
  169. /* zlps should not occur because zero-length EEM packets
  170. * will be inserted in those cases where they would occur
  171. */
  172. eem->port.is_zlp_ok = 1;
  173. eem->port.cdc_filter = DEFAULT_FILTER;
  174. DBG(cdev, "activate eem\n");
  175. net = gether_connect(&eem->port);
  176. if (IS_ERR(net))
  177. return PTR_ERR(net);
  178. } else
  179. goto fail;
  180. return 0;
  181. fail:
  182. return -EINVAL;
  183. }
  184. static void eem_disable(struct usb_function *f)
  185. {
  186. struct f_eem *eem = func_to_eem(f);
  187. struct usb_composite_dev *cdev = f->config->cdev;
  188. DBG(cdev, "eem deactivated\n");
  189. if (eem->port.in_ep->enabled)
  190. gether_disconnect(&eem->port);
  191. }
  192. /*-------------------------------------------------------------------------*/
  193. /* EEM function driver setup/binding */
  194. static int eem_bind(struct usb_configuration *c, struct usb_function *f)
  195. {
  196. struct usb_composite_dev *cdev = c->cdev;
  197. struct f_eem *eem = func_to_eem(f);
  198. struct usb_string *us;
  199. int status;
  200. struct usb_ep *ep;
  201. struct f_eem_opts *eem_opts;
  202. eem_opts = container_of(f->fi, struct f_eem_opts, func_inst);
  203. /*
  204. * in drivers/usb/gadget/configfs.c:configfs_composite_bind()
  205. * configurations are bound in sequence with list_for_each_entry,
  206. * in each configuration its functions are bound in sequence
  207. * with list_for_each_entry, so we assume no race condition
  208. * with regard to eem_opts->bound access
  209. */
  210. if (!eem_opts->bound) {
  211. mutex_lock(&eem_opts->lock);
  212. gether_set_gadget(eem_opts->net, cdev->gadget);
  213. status = gether_register_netdev(eem_opts->net);
  214. mutex_unlock(&eem_opts->lock);
  215. if (status)
  216. return status;
  217. eem_opts->bound = true;
  218. }
  219. us = usb_gstrings_attach(cdev, eem_strings,
  220. ARRAY_SIZE(eem_string_defs));
  221. if (IS_ERR(us))
  222. return PTR_ERR(us);
  223. eem_intf.iInterface = us[0].id;
  224. /* allocate instance-specific interface IDs */
  225. status = usb_interface_id(c, f);
  226. if (status < 0)
  227. goto fail;
  228. eem->ctrl_id = status;
  229. eem_intf.bInterfaceNumber = status;
  230. status = -ENODEV;
  231. /* allocate instance-specific endpoints */
  232. ep = usb_ep_autoconfig(cdev->gadget, &eem_fs_in_desc);
  233. if (!ep)
  234. goto fail;
  235. eem->port.in_ep = ep;
  236. ep = usb_ep_autoconfig(cdev->gadget, &eem_fs_out_desc);
  237. if (!ep)
  238. goto fail;
  239. eem->port.out_ep = ep;
  240. status = -ENOMEM;
  241. /* support all relevant hardware speeds... we expect that when
  242. * hardware is dual speed, all bulk-capable endpoints work at
  243. * both speeds
  244. */
  245. eem_hs_in_desc.bEndpointAddress = eem_fs_in_desc.bEndpointAddress;
  246. eem_hs_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress;
  247. eem_ss_in_desc.bEndpointAddress = eem_fs_in_desc.bEndpointAddress;
  248. eem_ss_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress;
  249. status = usb_assign_descriptors(f, eem_fs_function, eem_hs_function,
  250. eem_ss_function, NULL);
  251. if (status)
  252. goto fail;
  253. DBG(cdev, "CDC Ethernet (EEM): %s speed IN/%s OUT/%s\n",
  254. gadget_is_superspeed(c->cdev->gadget) ? "super" :
  255. gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full",
  256. eem->port.in_ep->name, eem->port.out_ep->name);
  257. return 0;
  258. fail:
  259. ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
  260. return status;
  261. }
  262. static void eem_cmd_complete(struct usb_ep *ep, struct usb_request *req)
  263. {
  264. struct sk_buff *skb = (struct sk_buff *)req->context;
  265. dev_kfree_skb_any(skb);
  266. }
  267. /*
  268. * Add the EEM header and ethernet checksum.
  269. * We currently do not attempt to put multiple ethernet frames
  270. * into a single USB transfer
  271. */
  272. static struct sk_buff *eem_wrap(struct gether *port, struct sk_buff *skb)
  273. {
  274. struct sk_buff *skb2 = NULL;
  275. struct usb_ep *in = port->in_ep;
  276. int headroom, tailroom, padlen = 0;
  277. u16 len;
  278. if (!skb)
  279. return NULL;
  280. len = skb->len;
  281. headroom = skb_headroom(skb);
  282. tailroom = skb_tailroom(skb);
  283. /* When (len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) is 0,
  284. * stick two bytes of zero-length EEM packet on the end.
  285. */
  286. if (((len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) == 0)
  287. padlen += 2;
  288. if ((tailroom >= (ETH_FCS_LEN + padlen)) &&
  289. (headroom >= EEM_HLEN) && !skb_cloned(skb))
  290. goto done;
  291. skb2 = skb_copy_expand(skb, EEM_HLEN, ETH_FCS_LEN + padlen, GFP_ATOMIC);
  292. dev_kfree_skb_any(skb);
  293. skb = skb2;
  294. if (!skb)
  295. return skb;
  296. done:
  297. /* use the "no CRC" option */
  298. put_unaligned_be32(0xdeadbeef, skb_put(skb, 4));
  299. /* EEM packet header format:
  300. * b0..13: length of ethernet frame
  301. * b14: bmCRC (0 == sentinel CRC)
  302. * b15: bmType (0 == data)
  303. */
  304. len = skb->len;
  305. put_unaligned_le16(len & 0x3FFF, skb_push(skb, 2));
  306. /* add a zero-length EEM packet, if needed */
  307. if (padlen)
  308. put_unaligned_le16(0, skb_put(skb, 2));
  309. return skb;
  310. }
  311. /*
  312. * Remove the EEM header. Note that there can be many EEM packets in a single
  313. * USB transfer, so we need to break them out and handle them independently.
  314. */
  315. static int eem_unwrap(struct gether *port,
  316. struct sk_buff *skb,
  317. struct sk_buff_head *list)
  318. {
  319. struct usb_composite_dev *cdev = port->func.config->cdev;
  320. int status = 0;
  321. do {
  322. struct sk_buff *skb2;
  323. u16 header;
  324. u16 len = 0;
  325. if (skb->len < EEM_HLEN) {
  326. status = -EINVAL;
  327. DBG(cdev, "invalid EEM header\n");
  328. goto error;
  329. }
  330. /* remove the EEM header */
  331. header = get_unaligned_le16(skb->data);
  332. skb_pull(skb, EEM_HLEN);
  333. /* EEM packet header format:
  334. * b0..14: EEM type dependent (data or command)
  335. * b15: bmType (0 == data, 1 == command)
  336. */
  337. if (header & BIT(15)) {
  338. struct usb_request *req = cdev->req;
  339. u16 bmEEMCmd;
  340. /* EEM command packet format:
  341. * b0..10: bmEEMCmdParam
  342. * b11..13: bmEEMCmd
  343. * b14: reserved (must be zero)
  344. * b15: bmType (1 == command)
  345. */
  346. if (header & BIT(14))
  347. continue;
  348. bmEEMCmd = (header >> 11) & 0x7;
  349. switch (bmEEMCmd) {
  350. case 0: /* echo */
  351. len = header & 0x7FF;
  352. if (skb->len < len) {
  353. status = -EOVERFLOW;
  354. goto error;
  355. }
  356. skb2 = skb_clone(skb, GFP_ATOMIC);
  357. if (unlikely(!skb2)) {
  358. DBG(cdev, "EEM echo response error\n");
  359. goto next;
  360. }
  361. skb_trim(skb2, len);
  362. put_unaligned_le16(BIT(15) | BIT(11) | len,
  363. skb_push(skb2, 2));
  364. skb_copy_bits(skb2, 0, req->buf, skb2->len);
  365. req->length = skb2->len;
  366. req->complete = eem_cmd_complete;
  367. req->zero = 1;
  368. req->context = skb2;
  369. if (usb_ep_queue(port->in_ep, req, GFP_ATOMIC))
  370. DBG(cdev, "echo response queue fail\n");
  371. break;
  372. case 1: /* echo response */
  373. case 2: /* suspend hint */
  374. case 3: /* response hint */
  375. case 4: /* response complete hint */
  376. case 5: /* tickle */
  377. default: /* reserved */
  378. continue;
  379. }
  380. } else {
  381. u32 crc, crc2;
  382. struct sk_buff *skb3;
  383. /* check for zero-length EEM packet */
  384. if (header == 0)
  385. continue;
  386. /* EEM data packet format:
  387. * b0..13: length of ethernet frame
  388. * b14: bmCRC (0 == sentinel, 1 == calculated)
  389. * b15: bmType (0 == data)
  390. */
  391. len = header & 0x3FFF;
  392. if ((skb->len < len)
  393. || (len < (ETH_HLEN + ETH_FCS_LEN))) {
  394. status = -EINVAL;
  395. goto error;
  396. }
  397. /* validate CRC */
  398. if (header & BIT(14)) {
  399. crc = get_unaligned_le32(skb->data + len
  400. - ETH_FCS_LEN);
  401. crc2 = ~crc32_le(~0,
  402. skb->data, len - ETH_FCS_LEN);
  403. } else {
  404. crc = get_unaligned_be32(skb->data + len
  405. - ETH_FCS_LEN);
  406. crc2 = 0xdeadbeef;
  407. }
  408. if (crc != crc2) {
  409. DBG(cdev, "invalid EEM CRC\n");
  410. goto next;
  411. }
  412. skb2 = skb_clone(skb, GFP_ATOMIC);
  413. if (unlikely(!skb2)) {
  414. DBG(cdev, "unable to unframe EEM packet\n");
  415. continue;
  416. }
  417. skb_trim(skb2, len - ETH_FCS_LEN);
  418. skb3 = skb_copy_expand(skb2,
  419. NET_IP_ALIGN,
  420. 0,
  421. GFP_ATOMIC);
  422. if (unlikely(!skb3)) {
  423. DBG(cdev, "unable to realign EEM packet\n");
  424. dev_kfree_skb_any(skb2);
  425. continue;
  426. }
  427. dev_kfree_skb_any(skb2);
  428. skb_queue_tail(list, skb3);
  429. }
  430. next:
  431. skb_pull(skb, len);
  432. } while (skb->len);
  433. error:
  434. dev_kfree_skb_any(skb);
  435. return status;
  436. }
  437. static inline struct f_eem_opts *to_f_eem_opts(struct config_item *item)
  438. {
  439. return container_of(to_config_group(item), struct f_eem_opts,
  440. func_inst.group);
  441. }
  442. /* f_eem_item_ops */
  443. USB_ETHERNET_CONFIGFS_ITEM(eem);
  444. /* f_eem_opts_dev_addr */
  445. USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(eem);
  446. /* f_eem_opts_host_addr */
  447. USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(eem);
  448. /* f_eem_opts_qmult */
  449. USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(eem);
  450. /* f_eem_opts_ifname */
  451. USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem);
  452. static struct configfs_attribute *eem_attrs[] = {
  453. &eem_opts_attr_dev_addr,
  454. &eem_opts_attr_host_addr,
  455. &eem_opts_attr_qmult,
  456. &eem_opts_attr_ifname,
  457. NULL,
  458. };
  459. static struct config_item_type eem_func_type = {
  460. .ct_item_ops = &eem_item_ops,
  461. .ct_attrs = eem_attrs,
  462. .ct_owner = THIS_MODULE,
  463. };
  464. static void eem_free_inst(struct usb_function_instance *f)
  465. {
  466. struct f_eem_opts *opts;
  467. opts = container_of(f, struct f_eem_opts, func_inst);
  468. if (opts->bound)
  469. gether_cleanup(netdev_priv(opts->net));
  470. else
  471. free_netdev(opts->net);
  472. kfree(opts);
  473. }
  474. static struct usb_function_instance *eem_alloc_inst(void)
  475. {
  476. struct f_eem_opts *opts;
  477. opts = kzalloc(sizeof(*opts), GFP_KERNEL);
  478. if (!opts)
  479. return ERR_PTR(-ENOMEM);
  480. mutex_init(&opts->lock);
  481. opts->func_inst.free_func_inst = eem_free_inst;
  482. opts->net = gether_setup_default();
  483. if (IS_ERR(opts->net)) {
  484. struct net_device *net = opts->net;
  485. kfree(opts);
  486. return ERR_CAST(net);
  487. }
  488. config_group_init_type_name(&opts->func_inst.group, "", &eem_func_type);
  489. return &opts->func_inst;
  490. }
  491. static void eem_free(struct usb_function *f)
  492. {
  493. struct f_eem *eem;
  494. struct f_eem_opts *opts;
  495. eem = func_to_eem(f);
  496. opts = container_of(f->fi, struct f_eem_opts, func_inst);
  497. kfree(eem);
  498. mutex_lock(&opts->lock);
  499. opts->refcnt--;
  500. mutex_unlock(&opts->lock);
  501. }
  502. static void eem_unbind(struct usb_configuration *c, struct usb_function *f)
  503. {
  504. DBG(c->cdev, "eem unbind\n");
  505. usb_free_all_descriptors(f);
  506. }
  507. static struct usb_function *eem_alloc(struct usb_function_instance *fi)
  508. {
  509. struct f_eem *eem;
  510. struct f_eem_opts *opts;
  511. /* allocate and initialize one new instance */
  512. eem = kzalloc(sizeof(*eem), GFP_KERNEL);
  513. if (!eem)
  514. return ERR_PTR(-ENOMEM);
  515. opts = container_of(fi, struct f_eem_opts, func_inst);
  516. mutex_lock(&opts->lock);
  517. opts->refcnt++;
  518. eem->port.ioport = netdev_priv(opts->net);
  519. mutex_unlock(&opts->lock);
  520. eem->port.cdc_filter = DEFAULT_FILTER;
  521. eem->port.func.name = "cdc_eem";
  522. /* descriptors are per-instance copies */
  523. eem->port.func.bind = eem_bind;
  524. eem->port.func.unbind = eem_unbind;
  525. eem->port.func.set_alt = eem_set_alt;
  526. eem->port.func.setup = eem_setup;
  527. eem->port.func.disable = eem_disable;
  528. eem->port.func.free_func = eem_free;
  529. eem->port.wrap = eem_wrap;
  530. eem->port.unwrap = eem_unwrap;
  531. eem->port.header_len = EEM_HLEN;
  532. return &eem->port.func;
  533. }
  534. DECLARE_USB_FUNCTION_INIT(eem, eem_alloc_inst, eem_alloc);
  535. MODULE_LICENSE("GPL");
  536. MODULE_AUTHOR("David Brownell");