1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24#include <linux/kernel.h>
25#include <linux/device.h>
26#include <linux/etherdevice.h>
27
28#include "u_ether.h"
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48struct ecm_ep_descs {
49 struct usb_endpoint_descriptor *in;
50 struct usb_endpoint_descriptor *out;
51 struct usb_endpoint_descriptor *notify;
52};
53
54enum ecm_notify_state {
55 ECM_NOTIFY_NONE,
56 ECM_NOTIFY_CONNECT,
57 ECM_NOTIFY_SPEED,
58};
59
60struct f_ecm {
61 struct gether port;
62 u8 ctrl_id, data_id;
63
64 char ethaddr[14];
65
66 struct ecm_ep_descs fs;
67 struct ecm_ep_descs hs;
68
69 struct usb_ep *notify;
70 struct usb_endpoint_descriptor *notify_desc;
71 struct usb_request *notify_req;
72 u8 notify_state;
73 bool is_open;
74
75
76
77
78};
79
80static inline struct f_ecm *func_to_ecm(struct usb_function *f)
81{
82 return container_of(f, struct f_ecm, port.func);
83}
84
85
86static inline unsigned ecm_bitrate(struct usb_gadget *g)
87{
88 if (gadget_is_dualspeed(g) && g->speed == USB_SPEED_HIGH)
89 return 13 * 512 * 8 * 1000 * 8;
90 else
91 return 19 * 64 * 1 * 1000 * 8;
92}
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109#define LOG2_STATUS_INTERVAL_MSEC 5
110#define ECM_STATUS_BYTECOUNT 16
111
112
113
114
115static struct usb_interface_descriptor ecm_control_intf __initdata = {
116 .bLength = sizeof ecm_control_intf,
117 .bDescriptorType = USB_DT_INTERFACE,
118
119
120
121 .bNumEndpoints = 1,
122 .bInterfaceClass = USB_CLASS_COMM,
123 .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET,
124 .bInterfaceProtocol = USB_CDC_PROTO_NONE,
125
126};
127
128static struct usb_cdc_header_desc ecm_header_desc __initdata = {
129 .bLength = sizeof ecm_header_desc,
130 .bDescriptorType = USB_DT_CS_INTERFACE,
131 .bDescriptorSubType = USB_CDC_HEADER_TYPE,
132
133 .bcdCDC = cpu_to_le16(0x0110),
134};
135
136static struct usb_cdc_union_desc ecm_union_desc __initdata = {
137 .bLength = sizeof(ecm_union_desc),
138 .bDescriptorType = USB_DT_CS_INTERFACE,
139 .bDescriptorSubType = USB_CDC_UNION_TYPE,
140
141
142};
143
144static struct usb_cdc_ether_desc ecm_desc __initdata = {
145 .bLength = sizeof ecm_desc,
146 .bDescriptorType = USB_DT_CS_INTERFACE,
147 .bDescriptorSubType = USB_CDC_ETHERNET_TYPE,
148
149
150
151 .bmEthernetStatistics = cpu_to_le32(0),
152 .wMaxSegmentSize = cpu_to_le16(ETH_FRAME_LEN),
153 .wNumberMCFilters = cpu_to_le16(0),
154 .bNumberPowerFilters = 0,
155};
156
157
158
159static struct usb_interface_descriptor ecm_data_nop_intf __initdata = {
160 .bLength = sizeof ecm_data_nop_intf,
161 .bDescriptorType = USB_DT_INTERFACE,
162
163 .bInterfaceNumber = 1,
164 .bAlternateSetting = 0,
165 .bNumEndpoints = 0,
166 .bInterfaceClass = USB_CLASS_CDC_DATA,
167 .bInterfaceSubClass = 0,
168 .bInterfaceProtocol = 0,
169
170};
171
172
173
174static struct usb_interface_descriptor ecm_data_intf __initdata = {
175 .bLength = sizeof ecm_data_intf,
176 .bDescriptorType = USB_DT_INTERFACE,
177
178 .bInterfaceNumber = 1,
179 .bAlternateSetting = 1,
180 .bNumEndpoints = 2,
181 .bInterfaceClass = USB_CLASS_CDC_DATA,
182 .bInterfaceSubClass = 0,
183 .bInterfaceProtocol = 0,
184
185};
186
187
188
189static struct usb_endpoint_descriptor fs_ecm_notify_desc __initdata = {
190 .bLength = USB_DT_ENDPOINT_SIZE,
191 .bDescriptorType = USB_DT_ENDPOINT,
192
193 .bEndpointAddress = USB_DIR_IN,
194 .bmAttributes = USB_ENDPOINT_XFER_INT,
195 .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT),
196 .bInterval = 1 << LOG2_STATUS_INTERVAL_MSEC,
197};
198
199static struct usb_endpoint_descriptor fs_ecm_in_desc __initdata = {
200 .bLength = USB_DT_ENDPOINT_SIZE,
201 .bDescriptorType = USB_DT_ENDPOINT,
202
203 .bEndpointAddress = USB_DIR_IN,
204 .bmAttributes = USB_ENDPOINT_XFER_BULK,
205};
206
207static struct usb_endpoint_descriptor fs_ecm_out_desc __initdata = {
208 .bLength = USB_DT_ENDPOINT_SIZE,
209 .bDescriptorType = USB_DT_ENDPOINT,
210
211 .bEndpointAddress = USB_DIR_OUT,
212 .bmAttributes = USB_ENDPOINT_XFER_BULK,
213};
214
215static struct usb_descriptor_header *ecm_fs_function[] __initdata = {
216
217 (struct usb_descriptor_header *) &ecm_control_intf,
218 (struct usb_descriptor_header *) &ecm_header_desc,
219 (struct usb_descriptor_header *) &ecm_union_desc,
220 (struct usb_descriptor_header *) &ecm_desc,
221
222 (struct usb_descriptor_header *) &fs_ecm_notify_desc,
223
224 (struct usb_descriptor_header *) &ecm_data_nop_intf,
225 (struct usb_descriptor_header *) &ecm_data_intf,
226 (struct usb_descriptor_header *) &fs_ecm_in_desc,
227 (struct usb_descriptor_header *) &fs_ecm_out_desc,
228 NULL,
229};
230
231
232
233static struct usb_endpoint_descriptor hs_ecm_notify_desc __initdata = {
234 .bLength = USB_DT_ENDPOINT_SIZE,
235 .bDescriptorType = USB_DT_ENDPOINT,
236
237 .bEndpointAddress = USB_DIR_IN,
238 .bmAttributes = USB_ENDPOINT_XFER_INT,
239 .wMaxPacketSize = cpu_to_le16(ECM_STATUS_BYTECOUNT),
240 .bInterval = LOG2_STATUS_INTERVAL_MSEC + 4,
241};
242static struct usb_endpoint_descriptor hs_ecm_in_desc __initdata = {
243 .bLength = USB_DT_ENDPOINT_SIZE,
244 .bDescriptorType = USB_DT_ENDPOINT,
245
246 .bEndpointAddress = USB_DIR_IN,
247 .bmAttributes = USB_ENDPOINT_XFER_BULK,
248 .wMaxPacketSize = cpu_to_le16(512),
249};
250
251static struct usb_endpoint_descriptor hs_ecm_out_desc __initdata = {
252 .bLength = USB_DT_ENDPOINT_SIZE,
253 .bDescriptorType = USB_DT_ENDPOINT,
254
255 .bEndpointAddress = USB_DIR_OUT,
256 .bmAttributes = USB_ENDPOINT_XFER_BULK,
257 .wMaxPacketSize = cpu_to_le16(512),
258};
259
260static struct usb_descriptor_header *ecm_hs_function[] __initdata = {
261
262 (struct usb_descriptor_header *) &ecm_control_intf,
263 (struct usb_descriptor_header *) &ecm_header_desc,
264 (struct usb_descriptor_header *) &ecm_union_desc,
265 (struct usb_descriptor_header *) &ecm_desc,
266
267 (struct usb_descriptor_header *) &hs_ecm_notify_desc,
268
269 (struct usb_descriptor_header *) &ecm_data_nop_intf,
270 (struct usb_descriptor_header *) &ecm_data_intf,
271 (struct usb_descriptor_header *) &hs_ecm_in_desc,
272 (struct usb_descriptor_header *) &hs_ecm_out_desc,
273 NULL,
274};
275
276
277
278static struct usb_string ecm_string_defs[] = {
279 [0].s = "CDC Ethernet Control Model (ECM)",
280 [1].s = NULL ,
281 [2].s = "CDC Ethernet Data",
282 { }
283};
284
285static struct usb_gadget_strings ecm_string_table = {
286 .language = 0x0409,
287 .strings = ecm_string_defs,
288};
289
290static struct usb_gadget_strings *ecm_strings[] = {
291 &ecm_string_table,
292 NULL,
293};
294
295
296
297static void ecm_do_notify(struct f_ecm *ecm)
298{
299 struct usb_request *req = ecm->notify_req;
300 struct usb_cdc_notification *event;
301 struct usb_composite_dev *cdev = ecm->port.func.config->cdev;
302 __le32 *data;
303 int status;
304
305
306 if (!req)
307 return;
308
309 event = req->buf;
310 switch (ecm->notify_state) {
311 case ECM_NOTIFY_NONE:
312 return;
313
314 case ECM_NOTIFY_CONNECT:
315 event->bNotificationType = USB_CDC_NOTIFY_NETWORK_CONNECTION;
316 if (ecm->is_open)
317 event->wValue = cpu_to_le16(1);
318 else
319 event->wValue = cpu_to_le16(0);
320 event->wLength = 0;
321 req->length = sizeof *event;
322
323 DBG(cdev, "notify connect %s\n",
324 ecm->is_open ? "true" : "false");
325 ecm->notify_state = ECM_NOTIFY_SPEED;
326 break;
327
328 case ECM_NOTIFY_SPEED:
329 event->bNotificationType = USB_CDC_NOTIFY_SPEED_CHANGE;
330 event->wValue = cpu_to_le16(0);
331 event->wLength = cpu_to_le16(8);
332 req->length = ECM_STATUS_BYTECOUNT;
333
334
335 data = req->buf + sizeof *event;
336 data[0] = cpu_to_le32(ecm_bitrate(cdev->gadget));
337 data[1] = data[0];
338
339 DBG(cdev, "notify speed %d\n", ecm_bitrate(cdev->gadget));
340 ecm->notify_state = ECM_NOTIFY_NONE;
341 break;
342 }
343 event->bmRequestType = 0xA1;
344 event->wIndex = cpu_to_le16(ecm->ctrl_id);
345
346 ecm->notify_req = NULL;
347 status = usb_ep_queue(ecm->notify, req, GFP_ATOMIC);
348 if (status < 0) {
349 ecm->notify_req = req;
350 DBG(cdev, "notify --> %d\n", status);
351 }
352}
353
354static void ecm_notify(struct f_ecm *ecm)
355{
356
357
358
359
360
361 ecm->notify_state = ECM_NOTIFY_CONNECT;
362 ecm_do_notify(ecm);
363}
364
365static void ecm_notify_complete(struct usb_ep *ep, struct usb_request *req)
366{
367 struct f_ecm *ecm = req->context;
368 struct usb_composite_dev *cdev = ecm->port.func.config->cdev;
369 struct usb_cdc_notification *event = req->buf;
370
371 switch (req->status) {
372 case 0:
373
374 break;
375 case -ECONNRESET:
376 case -ESHUTDOWN:
377 ecm->notify_state = ECM_NOTIFY_NONE;
378 break;
379 default:
380 DBG(cdev, "event %02x --> %d\n",
381 event->bNotificationType, req->status);
382 break;
383 }
384 ecm->notify_req = req;
385 ecm_do_notify(ecm);
386}
387
388static int ecm_setup(struct usb_function *f, const struct usb_ctrlrequest *ctrl)
389{
390 struct f_ecm *ecm = func_to_ecm(f);
391 struct usb_composite_dev *cdev = f->config->cdev;
392 struct usb_request *req = cdev->req;
393 int value = -EOPNOTSUPP;
394 u16 w_index = le16_to_cpu(ctrl->wIndex);
395 u16 w_value = le16_to_cpu(ctrl->wValue);
396 u16 w_length = le16_to_cpu(ctrl->wLength);
397
398
399
400
401 switch ((ctrl->bRequestType << 8) | ctrl->bRequest) {
402 case ((USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE) << 8)
403 | USB_CDC_SET_ETHERNET_PACKET_FILTER:
404
405
406
407 if (w_length != 0 || w_index != ecm->ctrl_id)
408 goto invalid;
409 DBG(cdev, "packet filter %02x\n", w_value);
410
411
412
413
414 ecm->port.cdc_filter = w_value;
415 value = 0;
416 break;
417
418
419
420
421
422
423
424
425
426
427 default:
428invalid:
429 DBG(cdev, "invalid control req%02x.%02x v%04x i%04x l%d\n",
430 ctrl->bRequestType, ctrl->bRequest,
431 w_value, w_index, w_length);
432 }
433
434
435 if (value >= 0) {
436 DBG(cdev, "ecm req%02x.%02x v%04x i%04x l%d\n",
437 ctrl->bRequestType, ctrl->bRequest,
438 w_value, w_index, w_length);
439 req->zero = 0;
440 req->length = value;
441 value = usb_ep_queue(cdev->gadget->ep0, req, GFP_ATOMIC);
442 if (value < 0)
443 ERROR(cdev, "ecm req %02x.%02x response err %d\n",
444 ctrl->bRequestType, ctrl->bRequest,
445 value);
446 }
447
448
449 return value;
450}
451
452
453static int ecm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
454{
455 struct f_ecm *ecm = func_to_ecm(f);
456 struct usb_composite_dev *cdev = f->config->cdev;
457
458
459 if (intf == ecm->ctrl_id) {
460 if (alt != 0)
461 goto fail;
462
463 if (ecm->notify->driver_data) {
464 VDBG(cdev, "reset ecm control %d\n", intf);
465 usb_ep_disable(ecm->notify);
466 } else {
467 VDBG(cdev, "init ecm ctrl %d\n", intf);
468 ecm->notify_desc = ep_choose(cdev->gadget,
469 ecm->hs.notify,
470 ecm->fs.notify);
471 }
472 usb_ep_enable(ecm->notify, ecm->notify_desc);
473 ecm->notify->driver_data = ecm;
474
475
476 } else if (intf == ecm->data_id) {
477 if (alt > 1)
478 goto fail;
479
480 if (ecm->port.in_ep->driver_data) {
481 DBG(cdev, "reset ecm\n");
482 gether_disconnect(&ecm->port);
483 }
484
485 if (!ecm->port.in) {
486 DBG(cdev, "init ecm\n");
487 ecm->port.in = ep_choose(cdev->gadget,
488 ecm->hs.in, ecm->fs.in);
489 ecm->port.out = ep_choose(cdev->gadget,
490 ecm->hs.out, ecm->fs.out);
491 }
492
493
494
495
496 if (alt == 1) {
497 struct net_device *net;
498
499
500
501
502
503 ecm->port.is_zlp_ok = !(
504 gadget_is_sa1100(cdev->gadget)
505 || gadget_is_musbhdrc(cdev->gadget)
506 );
507 ecm->port.cdc_filter = DEFAULT_FILTER;
508 DBG(cdev, "activate ecm\n");
509 net = gether_connect(&ecm->port);
510 if (IS_ERR(net))
511 return PTR_ERR(net);
512 }
513
514
515
516
517
518
519
520 ecm_notify(ecm);
521 } else
522 goto fail;
523
524 return 0;
525fail:
526 return -EINVAL;
527}
528
529
530
531
532static int ecm_get_alt(struct usb_function *f, unsigned intf)
533{
534 struct f_ecm *ecm = func_to_ecm(f);
535
536 if (intf == ecm->ctrl_id)
537 return 0;
538 return ecm->port.in_ep->driver_data ? 1 : 0;
539}
540
541static void ecm_disable(struct usb_function *f)
542{
543 struct f_ecm *ecm = func_to_ecm(f);
544 struct usb_composite_dev *cdev = f->config->cdev;
545
546 DBG(cdev, "ecm deactivated\n");
547
548 if (ecm->port.in_ep->driver_data)
549 gether_disconnect(&ecm->port);
550
551 if (ecm->notify->driver_data) {
552 usb_ep_disable(ecm->notify);
553 ecm->notify->driver_data = NULL;
554 ecm->notify_desc = NULL;
555 }
556}
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578static void ecm_open(struct gether *geth)
579{
580 struct f_ecm *ecm = func_to_ecm(&geth->func);
581
582 DBG(ecm->port.func.config->cdev, "%s\n", __func__);
583
584 ecm->is_open = true;
585 ecm_notify(ecm);
586}
587
588static void ecm_close(struct gether *geth)
589{
590 struct f_ecm *ecm = func_to_ecm(&geth->func);
591
592 DBG(ecm->port.func.config->cdev, "%s\n", __func__);
593
594 ecm->is_open = false;
595 ecm_notify(ecm);
596}
597
598
599
600
601
602static int __init
603ecm_bind(struct usb_configuration *c, struct usb_function *f)
604{
605 struct usb_composite_dev *cdev = c->cdev;
606 struct f_ecm *ecm = func_to_ecm(f);
607 int status;
608 struct usb_ep *ep;
609
610
611 status = usb_interface_id(c, f);
612 if (status < 0)
613 goto fail;
614 ecm->ctrl_id = status;
615
616 ecm_control_intf.bInterfaceNumber = status;
617 ecm_union_desc.bMasterInterface0 = status;
618
619 status = usb_interface_id(c, f);
620 if (status < 0)
621 goto fail;
622 ecm->data_id = status;
623
624 ecm_data_nop_intf.bInterfaceNumber = status;
625 ecm_data_intf.bInterfaceNumber = status;
626 ecm_union_desc.bSlaveInterface0 = status;
627
628 status = -ENODEV;
629
630
631 ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_in_desc);
632 if (!ep)
633 goto fail;
634 ecm->port.in_ep = ep;
635 ep->driver_data = cdev;
636
637 ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_out_desc);
638 if (!ep)
639 goto fail;
640 ecm->port.out_ep = ep;
641 ep->driver_data = cdev;
642
643
644
645
646
647 ep = usb_ep_autoconfig(cdev->gadget, &fs_ecm_notify_desc);
648 if (!ep)
649 goto fail;
650 ecm->notify = ep;
651 ep->driver_data = cdev;
652
653 status = -ENOMEM;
654
655
656 ecm->notify_req = usb_ep_alloc_request(ep, GFP_KERNEL);
657 if (!ecm->notify_req)
658 goto fail;
659 ecm->notify_req->buf = kmalloc(ECM_STATUS_BYTECOUNT, GFP_KERNEL);
660 if (!ecm->notify_req->buf)
661 goto fail;
662 ecm->notify_req->context = ecm;
663 ecm->notify_req->complete = ecm_notify_complete;
664
665
666 f->descriptors = usb_copy_descriptors(ecm_fs_function);
667 if (!f->descriptors)
668 goto fail;
669
670 ecm->fs.in = usb_find_endpoint(ecm_fs_function,
671 f->descriptors, &fs_ecm_in_desc);
672 ecm->fs.out = usb_find_endpoint(ecm_fs_function,
673 f->descriptors, &fs_ecm_out_desc);
674 ecm->fs.notify = usb_find_endpoint(ecm_fs_function,
675 f->descriptors, &fs_ecm_notify_desc);
676
677
678
679
680
681 if (gadget_is_dualspeed(c->cdev->gadget)) {
682 hs_ecm_in_desc.bEndpointAddress =
683 fs_ecm_in_desc.bEndpointAddress;
684 hs_ecm_out_desc.bEndpointAddress =
685 fs_ecm_out_desc.bEndpointAddress;
686 hs_ecm_notify_desc.bEndpointAddress =
687 fs_ecm_notify_desc.bEndpointAddress;
688
689
690 f->hs_descriptors = usb_copy_descriptors(ecm_hs_function);
691 if (!f->hs_descriptors)
692 goto fail;
693
694 ecm->hs.in = usb_find_endpoint(ecm_hs_function,
695 f->hs_descriptors, &hs_ecm_in_desc);
696 ecm->hs.out = usb_find_endpoint(ecm_hs_function,
697 f->hs_descriptors, &hs_ecm_out_desc);
698 ecm->hs.notify = usb_find_endpoint(ecm_hs_function,
699 f->hs_descriptors, &hs_ecm_notify_desc);
700 }
701
702
703
704
705
706
707 ecm->port.open = ecm_open;
708 ecm->port.close = ecm_close;
709
710 DBG(cdev, "CDC Ethernet: %s speed IN/%s OUT/%s NOTIFY/%s\n",
711 gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full",
712 ecm->port.in_ep->name, ecm->port.out_ep->name,
713 ecm->notify->name);
714 return 0;
715
716fail:
717 if (f->descriptors)
718 usb_free_descriptors(f->descriptors);
719
720 if (ecm->notify_req) {
721 kfree(ecm->notify_req->buf);
722 usb_ep_free_request(ecm->notify, ecm->notify_req);
723 }
724
725
726 if (ecm->notify)
727 ecm->notify->driver_data = NULL;
728 if (ecm->port.out)
729 ecm->port.out_ep->driver_data = NULL;
730 if (ecm->port.in)
731 ecm->port.in_ep->driver_data = NULL;
732
733 ERROR(cdev, "%s: can't bind, err %d\n", f->name, status);
734
735 return status;
736}
737
738static void
739ecm_unbind(struct usb_configuration *c, struct usb_function *f)
740{
741 struct f_ecm *ecm = func_to_ecm(f);
742
743 DBG(c->cdev, "ecm unbind\n");
744
745 if (gadget_is_dualspeed(c->cdev->gadget))
746 usb_free_descriptors(f->hs_descriptors);
747 usb_free_descriptors(f->descriptors);
748
749 kfree(ecm->notify_req->buf);
750 usb_ep_free_request(ecm->notify, ecm->notify_req);
751
752 ecm_string_defs[1].s = NULL;
753 kfree(ecm);
754}
755
756
757
758
759
760
761
762
763
764
765
766
767
768int __init ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
769{
770 struct f_ecm *ecm;
771 int status;
772
773 if (!can_support_ecm(c->cdev->gadget) || !ethaddr)
774 return -EINVAL;
775
776
777 if (ecm_string_defs[0].id == 0) {
778
779
780 status = usb_string_id(c->cdev);
781 if (status < 0)
782 return status;
783 ecm_string_defs[0].id = status;
784 ecm_control_intf.iInterface = status;
785
786
787 status = usb_string_id(c->cdev);
788 if (status < 0)
789 return status;
790 ecm_string_defs[2].id = status;
791 ecm_data_intf.iInterface = status;
792
793
794 status = usb_string_id(c->cdev);
795 if (status < 0)
796 return status;
797 ecm_string_defs[1].id = status;
798 ecm_desc.iMACAddress = status;
799 }
800
801
802 ecm = kzalloc(sizeof *ecm, GFP_KERNEL);
803 if (!ecm)
804 return -ENOMEM;
805
806
807 snprintf(ecm->ethaddr, sizeof ecm->ethaddr,
808 "%02X%02X%02X%02X%02X%02X",
809 ethaddr[0], ethaddr[1], ethaddr[2],
810 ethaddr[3], ethaddr[4], ethaddr[5]);
811 ecm_string_defs[1].s = ecm->ethaddr;
812
813 ecm->port.cdc_filter = DEFAULT_FILTER;
814
815 ecm->port.func.name = "cdc_ethernet";
816 ecm->port.func.strings = ecm_strings;
817
818 ecm->port.func.bind = ecm_bind;
819 ecm->port.func.unbind = ecm_unbind;
820 ecm->port.func.set_alt = ecm_set_alt;
821 ecm->port.func.get_alt = ecm_get_alt;
822 ecm->port.func.setup = ecm_setup;
823 ecm->port.func.disable = ecm_disable;
824
825 status = usb_add_function(c, &ecm->port.func);
826 if (status) {
827 ecm_string_defs[1].s = NULL;
828 kfree(ecm);
829 }
830 return status;
831}
832