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