f_eem.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649
  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);
  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 padlen = 0;
  277. u16 len = skb->len;
  278. int headroom = skb_headroom(skb);
  279. int tailroom = skb_tailroom(skb);
  280. /* When (len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) is 0,
  281. * stick two bytes of zero-length EEM packet on the end.
  282. */
  283. if (((len + EEM_HLEN + ETH_FCS_LEN) % in->maxpacket) == 0)
  284. padlen += 2;
  285. if ((tailroom >= (ETH_FCS_LEN + padlen)) &&
  286. (headroom >= EEM_HLEN) && !skb_cloned(skb))
  287. goto done;
  288. skb2 = skb_copy_expand(skb, EEM_HLEN, ETH_FCS_LEN + padlen, GFP_ATOMIC);
  289. dev_kfree_skb_any(skb);
  290. skb = skb2;
  291. if (!skb)
  292. return skb;
  293. done:
  294. /* use the "no CRC" option */
  295. put_unaligned_be32(0xdeadbeef, skb_put(skb, 4));
  296. /* EEM packet header format:
  297. * b0..13: length of ethernet frame
  298. * b14: bmCRC (0 == sentinel CRC)
  299. * b15: bmType (0 == data)
  300. */
  301. len = skb->len;
  302. put_unaligned_le16(len & 0x3FFF, skb_push(skb, 2));
  303. /* add a zero-length EEM packet, if needed */
  304. if (padlen)
  305. put_unaligned_le16(0, skb_put(skb, 2));
  306. return skb;
  307. }
  308. /*
  309. * Remove the EEM header. Note that there can be many EEM packets in a single
  310. * USB transfer, so we need to break them out and handle them independently.
  311. */
  312. static int eem_unwrap(struct gether *port,
  313. struct sk_buff *skb,
  314. struct sk_buff_head *list)
  315. {
  316. struct usb_composite_dev *cdev = port->func.config->cdev;
  317. int status = 0;
  318. do {
  319. struct sk_buff *skb2;
  320. u16 header;
  321. u16 len = 0;
  322. if (skb->len < EEM_HLEN) {
  323. status = -EINVAL;
  324. DBG(cdev, "invalid EEM header\n");
  325. goto error;
  326. }
  327. /* remove the EEM header */
  328. header = get_unaligned_le16(skb->data);
  329. skb_pull(skb, EEM_HLEN);
  330. /* EEM packet header format:
  331. * b0..14: EEM type dependent (data or command)
  332. * b15: bmType (0 == data, 1 == command)
  333. */
  334. if (header & BIT(15)) {
  335. struct usb_request *req = cdev->req;
  336. u16 bmEEMCmd;
  337. /* EEM command packet format:
  338. * b0..10: bmEEMCmdParam
  339. * b11..13: bmEEMCmd
  340. * b14: reserved (must be zero)
  341. * b15: bmType (1 == command)
  342. */
  343. if (header & BIT(14))
  344. continue;
  345. bmEEMCmd = (header >> 11) & 0x7;
  346. switch (bmEEMCmd) {
  347. case 0: /* echo */
  348. len = header & 0x7FF;
  349. if (skb->len < len) {
  350. status = -EOVERFLOW;
  351. goto error;
  352. }
  353. skb2 = skb_clone(skb, GFP_ATOMIC);
  354. if (unlikely(!skb2)) {
  355. DBG(cdev, "EEM echo response error\n");
  356. goto next;
  357. }
  358. skb_trim(skb2, len);
  359. put_unaligned_le16(BIT(15) | BIT(11) | len,
  360. skb_push(skb2, 2));
  361. skb_copy_bits(skb2, 0, req->buf, skb2->len);
  362. req->length = skb2->len;
  363. req->complete = eem_cmd_complete;
  364. req->zero = 1;
  365. req->context = skb2;
  366. if (usb_ep_queue(port->in_ep, req, GFP_ATOMIC))
  367. DBG(cdev, "echo response queue fail\n");
  368. break;
  369. case 1: /* echo response */
  370. case 2: /* suspend hint */
  371. case 3: /* response hint */
  372. case 4: /* response complete hint */
  373. case 5: /* tickle */
  374. default: /* reserved */
  375. continue;
  376. }
  377. } else {
  378. u32 crc, crc2;
  379. struct sk_buff *skb3;
  380. /* check for zero-length EEM packet */
  381. if (header == 0)
  382. continue;
  383. /* EEM data packet format:
  384. * b0..13: length of ethernet frame
  385. * b14: bmCRC (0 == sentinel, 1 == calculated)
  386. * b15: bmType (0 == data)
  387. */
  388. len = header & 0x3FFF;
  389. if ((skb->len < len)
  390. || (len < (ETH_HLEN + ETH_FCS_LEN))) {
  391. status = -EINVAL;
  392. goto error;
  393. }
  394. /* validate CRC */
  395. if (header & BIT(14)) {
  396. crc = get_unaligned_le32(skb->data + len
  397. - ETH_FCS_LEN);
  398. crc2 = ~crc32_le(~0,
  399. skb->data, len - ETH_FCS_LEN);
  400. } else {
  401. crc = get_unaligned_be32(skb->data + len
  402. - ETH_FCS_LEN);
  403. crc2 = 0xdeadbeef;
  404. }
  405. if (crc != crc2) {
  406. DBG(cdev, "invalid EEM CRC\n");
  407. goto next;
  408. }
  409. skb2 = skb_clone(skb, GFP_ATOMIC);
  410. if (unlikely(!skb2)) {
  411. DBG(cdev, "unable to unframe EEM packet\n");
  412. continue;
  413. }
  414. skb_trim(skb2, len - ETH_FCS_LEN);
  415. skb3 = skb_copy_expand(skb2,
  416. NET_IP_ALIGN,
  417. 0,
  418. GFP_ATOMIC);
  419. if (unlikely(!skb3)) {
  420. DBG(cdev, "unable to realign EEM packet\n");
  421. dev_kfree_skb_any(skb2);
  422. continue;
  423. }
  424. dev_kfree_skb_any(skb2);
  425. skb_queue_tail(list, skb3);
  426. }
  427. next:
  428. skb_pull(skb, len);
  429. } while (skb->len);
  430. error:
  431. dev_kfree_skb_any(skb);
  432. return status;
  433. }
  434. static inline struct f_eem_opts *to_f_eem_opts(struct config_item *item)
  435. {
  436. return container_of(to_config_group(item), struct f_eem_opts,
  437. func_inst.group);
  438. }
  439. /* f_eem_item_ops */
  440. USB_ETHERNET_CONFIGFS_ITEM(eem);
  441. /* f_eem_opts_dev_addr */
  442. USB_ETHERNET_CONFIGFS_ITEM_ATTR_DEV_ADDR(eem);
  443. /* f_eem_opts_host_addr */
  444. USB_ETHERNET_CONFIGFS_ITEM_ATTR_HOST_ADDR(eem);
  445. /* f_eem_opts_qmult */
  446. USB_ETHERNET_CONFIGFS_ITEM_ATTR_QMULT(eem);
  447. /* f_eem_opts_ifname */
  448. USB_ETHERNET_CONFIGFS_ITEM_ATTR_IFNAME(eem);
  449. static struct configfs_attribute *eem_attrs[] = {
  450. &eem_opts_attr_dev_addr,
  451. &eem_opts_attr_host_addr,
  452. &eem_opts_attr_qmult,
  453. &eem_opts_attr_ifname,
  454. NULL,
  455. };
  456. static struct config_item_type eem_func_type = {
  457. .ct_item_ops = &eem_item_ops,
  458. .ct_attrs = eem_attrs,
  459. .ct_owner = THIS_MODULE,
  460. };
  461. static void eem_free_inst(struct usb_function_instance *f)
  462. {
  463. struct f_eem_opts *opts;
  464. opts = container_of(f, struct f_eem_opts, func_inst);
  465. if (opts->bound)
  466. gether_cleanup(netdev_priv(opts->net));
  467. else
  468. free_netdev(opts->net);
  469. kfree(opts);
  470. }
  471. static struct usb_function_instance *eem_alloc_inst(void)
  472. {
  473. struct f_eem_opts *opts;
  474. opts = kzalloc(sizeof(*opts), GFP_KERNEL);
  475. if (!opts)
  476. return ERR_PTR(-ENOMEM);
  477. mutex_init(&opts->lock);
  478. opts->func_inst.free_func_inst = eem_free_inst;
  479. opts->net = gether_setup_default();
  480. if (IS_ERR(opts->net)) {
  481. struct net_device *net = opts->net;
  482. kfree(opts);
  483. return ERR_CAST(net);
  484. }
  485. config_group_init_type_name(&opts->func_inst.group, "", &eem_func_type);
  486. return &opts->func_inst;
  487. }
  488. static void eem_free(struct usb_function *f)
  489. {
  490. struct f_eem *eem;
  491. struct f_eem_opts *opts;
  492. eem = func_to_eem(f);
  493. opts = container_of(f->fi, struct f_eem_opts, func_inst);
  494. kfree(eem);
  495. mutex_lock(&opts->lock);
  496. opts->refcnt--;
  497. mutex_unlock(&opts->lock);
  498. }
  499. static void eem_unbind(struct usb_configuration *c, struct usb_function *f)
  500. {
  501. DBG(c->cdev, "eem unbind\n");
  502. usb_free_all_descriptors(f);
  503. }
  504. static struct usb_function *eem_alloc(struct usb_function_instance *fi)
  505. {
  506. struct f_eem *eem;
  507. struct f_eem_opts *opts;
  508. /* allocate and initialize one new instance */
  509. eem = kzalloc(sizeof(*eem), GFP_KERNEL);
  510. if (!eem)
  511. return ERR_PTR(-ENOMEM);
  512. opts = container_of(fi, struct f_eem_opts, func_inst);
  513. mutex_lock(&opts->lock);
  514. opts->refcnt++;
  515. eem->port.ioport = netdev_priv(opts->net);
  516. mutex_unlock(&opts->lock);
  517. eem->port.cdc_filter = DEFAULT_FILTER;
  518. eem->port.func.name = "cdc_eem";
  519. /* descriptors are per-instance copies */
  520. eem->port.func.bind = eem_bind;
  521. eem->port.func.unbind = eem_unbind;
  522. eem->port.func.set_alt = eem_set_alt;
  523. eem->port.func.setup = eem_setup;
  524. eem->port.func.disable = eem_disable;
  525. eem->port.func.free_func = eem_free;
  526. eem->port.wrap = eem_wrap;
  527. eem->port.unwrap = eem_unwrap;
  528. eem->port.header_len = EEM_HLEN;
  529. return &eem->port.func;
  530. }
  531. DECLARE_USB_FUNCTION_INIT(eem, eem_alloc_inst, eem_alloc);
  532. MODULE_LICENSE("GPL");
  533. MODULE_AUTHOR("David Brownell");