1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54#include <linux/init.h>
55#include <linux/module.h>
56#include <linux/slab.h>
57#include <linux/usb.h>
58#include <linux/usb/wusb.h>
59#include <linux/usb/wusb-wa.h>
60#include <linux/uwb.h>
61
62#include "uwb-internal.h"
63
64
65
66#define WUSB_QUIRK_WHCI_CMD_EVT 0x01
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81struct hwarc {
82 struct usb_device *usb_dev;
83 struct usb_interface *usb_iface;
84 struct uwb_rc *uwb_rc;
85 struct urb *neep_urb;
86 struct edc neep_edc;
87 void *rd_buffer;
88};
89
90
91
92struct uwb_rc_evt_beacon_WUSB_0100 {
93 struct uwb_rceb rceb;
94 u8 bChannelNumber;
95 __le16 wBPSTOffset;
96 u8 bLQI;
97 u8 bRSSI;
98 __le16 wBeaconInfoLength;
99 u8 BeaconInfo[];
100} __attribute__((packed));
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116static
117int hwarc_filter_evt_beacon_WUSB_0100(struct uwb_rc *rc,
118 struct uwb_rceb **header,
119 const size_t buf_size,
120 size_t *new_size)
121{
122 struct uwb_rc_evt_beacon_WUSB_0100 *be;
123 struct uwb_rc_evt_beacon *newbe;
124 size_t bytes_left, ielength;
125 struct device *dev = &rc->uwb_dev.dev;
126
127 be = container_of(*header, struct uwb_rc_evt_beacon_WUSB_0100, rceb);
128 bytes_left = buf_size;
129 if (bytes_left < sizeof(*be)) {
130 dev_err(dev, "Beacon Received Notification: Not enough data "
131 "to decode for filtering (%zu vs %zu bytes needed)\n",
132 bytes_left, sizeof(*be));
133 return -EINVAL;
134 }
135 bytes_left -= sizeof(*be);
136 ielength = le16_to_cpu(be->wBeaconInfoLength);
137 if (bytes_left < ielength) {
138 dev_err(dev, "Beacon Received Notification: Not enough data "
139 "to decode IEs (%zu vs %zu bytes needed)\n",
140 bytes_left, ielength);
141 return -EINVAL;
142 }
143 newbe = kzalloc(sizeof(*newbe) + ielength, GFP_ATOMIC);
144 if (newbe == NULL)
145 return -ENOMEM;
146 newbe->rceb = be->rceb;
147 newbe->bChannelNumber = be->bChannelNumber;
148 newbe->bBeaconType = UWB_RC_BEACON_TYPE_NEIGHBOR;
149 newbe->wBPSTOffset = be->wBPSTOffset;
150 newbe->bLQI = be->bLQI;
151 newbe->bRSSI = be->bRSSI;
152 newbe->wBeaconInfoLength = be->wBeaconInfoLength;
153 memcpy(newbe->BeaconInfo, be->BeaconInfo, ielength);
154 *header = &newbe->rceb;
155 *new_size = sizeof(*newbe) + ielength;
156 return 1;
157}
158
159
160
161struct uwb_rc_evt_drp_avail_WUSB_0100 {
162 struct uwb_rceb rceb;
163 __le16 wIELength;
164 u8 IEData[];
165} __attribute__((packed));
166
167
168
169
170
171
172
173
174static
175int hwarc_filter_evt_drp_avail_WUSB_0100(struct uwb_rc *rc,
176 struct uwb_rceb **header,
177 const size_t buf_size,
178 size_t *new_size)
179{
180 struct uwb_rc_evt_drp_avail_WUSB_0100 *da;
181 struct uwb_rc_evt_drp_avail *newda;
182 struct uwb_ie_hdr *ie_hdr;
183 size_t bytes_left, ielength;
184 struct device *dev = &rc->uwb_dev.dev;
185
186
187 da = container_of(*header, struct uwb_rc_evt_drp_avail_WUSB_0100, rceb);
188 bytes_left = buf_size;
189 if (bytes_left < sizeof(*da)) {
190 dev_err(dev, "Not enough data to decode DRP Avail "
191 "Notification for filtering. Expected %zu, "
192 "received %zu.\n", (size_t)sizeof(*da), bytes_left);
193 return -EINVAL;
194 }
195 bytes_left -= sizeof(*da);
196 ielength = le16_to_cpu(da->wIELength);
197 if (bytes_left < ielength) {
198 dev_err(dev, "DRP Avail Notification filter: IE length "
199 "[%zu bytes] does not match actual length "
200 "[%zu bytes].\n", ielength, bytes_left);
201 return -EINVAL;
202 }
203 if (ielength < sizeof(*ie_hdr)) {
204 dev_err(dev, "DRP Avail Notification filter: Not enough "
205 "data to decode IE [%zu bytes, %zu needed]\n",
206 ielength, sizeof(*ie_hdr));
207 return -EINVAL;
208 }
209 ie_hdr = (void *) da->IEData;
210 if (ie_hdr->length > 32) {
211 dev_err(dev, "DRP Availability Change event has unexpected "
212 "length for filtering. Expected < 32 bytes, "
213 "got %zu bytes.\n", (size_t)ie_hdr->length);
214 return -EINVAL;
215 }
216 newda = kzalloc(sizeof(*newda), GFP_ATOMIC);
217 if (newda == NULL)
218 return -ENOMEM;
219 newda->rceb = da->rceb;
220 memcpy(newda->bmp, (u8 *) ie_hdr + sizeof(*ie_hdr), ie_hdr->length);
221 *header = &newda->rceb;
222 *new_size = sizeof(*newda);
223 return 1;
224}
225
226
227
228struct uwb_rc_evt_drp_WUSB_0100 {
229 struct uwb_rceb rceb;
230 struct uwb_dev_addr wSrcAddr;
231 u8 bExplicit;
232 __le16 wIELength;
233 u8 IEData[];
234} __attribute__((packed));
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249static
250int hwarc_filter_evt_drp_WUSB_0100(struct uwb_rc *rc,
251 struct uwb_rceb **header,
252 const size_t buf_size,
253 size_t *new_size)
254{
255 struct uwb_rc_evt_drp_WUSB_0100 *drpev;
256 struct uwb_rc_evt_drp *newdrpev;
257 size_t bytes_left, ielength;
258 struct device *dev = &rc->uwb_dev.dev;
259
260 drpev = container_of(*header, struct uwb_rc_evt_drp_WUSB_0100, rceb);
261 bytes_left = buf_size;
262 if (bytes_left < sizeof(*drpev)) {
263 dev_err(dev, "Not enough data to decode DRP Notification "
264 "for filtering. Expected %zu, received %zu.\n",
265 (size_t)sizeof(*drpev), bytes_left);
266 return -EINVAL;
267 }
268 ielength = le16_to_cpu(drpev->wIELength);
269 bytes_left -= sizeof(*drpev);
270 if (bytes_left < ielength) {
271 dev_err(dev, "DRP Notification filter: header length [%zu "
272 "bytes] does not match actual length [%zu "
273 "bytes].\n", ielength, bytes_left);
274 return -EINVAL;
275 }
276 newdrpev = kzalloc(sizeof(*newdrpev) + ielength, GFP_ATOMIC);
277 if (newdrpev == NULL)
278 return -ENOMEM;
279 newdrpev->rceb = drpev->rceb;
280 newdrpev->src_addr = drpev->wSrcAddr;
281 newdrpev->reason = UWB_DRP_NOTIF_DRP_IE_RCVD;
282 newdrpev->beacon_slot_number = 0;
283 newdrpev->ie_length = drpev->wIELength;
284 memcpy(newdrpev->ie_data, drpev->IEData, ielength);
285 *header = &newdrpev->rceb;
286 *new_size = sizeof(*newdrpev) + ielength;
287 return 1;
288}
289
290
291
292struct uwb_rc_cmd_scan_WUSB_0100 {
293 struct uwb_rccb rccb;
294 u8 bChannelNumber;
295 u8 bScanState;
296} __attribute__((packed));
297
298
299
300
301
302
303
304
305
306
307
308static
309int hwarc_filter_cmd_scan_WUSB_0100(struct uwb_rc *rc,
310 struct uwb_rccb **header,
311 size_t *size)
312{
313 struct uwb_rc_cmd_scan *sc;
314
315 sc = container_of(*header, struct uwb_rc_cmd_scan, rccb);
316
317 if (sc->bScanState == UWB_SCAN_ONLY_STARTTIME)
318 sc->bScanState = UWB_SCAN_ONLY;
319
320 *size -= 2;
321 return 0;
322}
323
324
325
326struct uwb_rc_cmd_set_drp_ie_WUSB_0100 {
327 struct uwb_rccb rccb;
328 u8 bExplicit;
329 __le16 wIELength;
330 struct uwb_ie_drp IEData[];
331} __attribute__((packed));
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346static
347int hwarc_filter_cmd_set_drp_ie_WUSB_0100(struct uwb_rc *rc,
348 struct uwb_rccb **header,
349 size_t *size)
350{
351 struct uwb_rc_cmd_set_drp_ie *orgcmd;
352 struct uwb_rc_cmd_set_drp_ie_WUSB_0100 *cmd;
353 size_t ielength;
354
355 orgcmd = container_of(*header, struct uwb_rc_cmd_set_drp_ie, rccb);
356 ielength = le16_to_cpu(orgcmd->wIELength);
357 cmd = kzalloc(sizeof(*cmd) + ielength, GFP_KERNEL);
358 if (cmd == NULL)
359 return -ENOMEM;
360 cmd->rccb = orgcmd->rccb;
361 cmd->bExplicit = 0;
362 cmd->wIELength = orgcmd->wIELength;
363 memcpy(cmd->IEData, orgcmd->IEData, ielength);
364 *header = &cmd->rccb;
365 *size = sizeof(*cmd) + ielength;
366 return 1;
367}
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391static
392int hwarc_filter_cmd_WUSB_0100(struct uwb_rc *rc, struct uwb_rccb **header,
393 size_t *size)
394{
395 int result;
396 struct uwb_rccb *rccb = *header;
397 int cmd = le16_to_cpu(rccb->wCommand);
398 switch (cmd) {
399 case UWB_RC_CMD_SCAN:
400 result = hwarc_filter_cmd_scan_WUSB_0100(rc, header, size);
401 break;
402 case UWB_RC_CMD_SET_DRP_IE:
403 result = hwarc_filter_cmd_set_drp_ie_WUSB_0100(rc, header, size);
404 break;
405 default:
406 result = -ENOANO;
407 break;
408 }
409 return result;
410}
411
412
413
414
415
416
417
418
419
420
421
422
423static
424int hwarc_filter_cmd(struct uwb_rc *rc, struct uwb_rccb **header,
425 size_t *size)
426{
427 int result = -ENOANO;
428 if (rc->version == 0x0100)
429 result = hwarc_filter_cmd_WUSB_0100(rc, header, size);
430 return result;
431}
432
433
434
435
436
437
438
439
440
441
442
443
444static
445ssize_t hwarc_get_event_size(struct uwb_rc *rc, const struct uwb_rceb *rceb,
446 size_t core_size, size_t offset,
447 const size_t buf_size)
448{
449 ssize_t size = -ENOSPC;
450 const void *ptr = rceb;
451 size_t type_size = sizeof(__le16);
452 struct device *dev = &rc->uwb_dev.dev;
453
454 if (offset + type_size >= buf_size) {
455 dev_err(dev, "Not enough data to read extra size of event "
456 "0x%02x/%04x/%02x, only got %zu bytes.\n",
457 rceb->bEventType, le16_to_cpu(rceb->wEvent),
458 rceb->bEventContext, buf_size);
459 goto out;
460 }
461 ptr += offset;
462 size = core_size + le16_to_cpu(*(__le16 *)ptr);
463out:
464 return size;
465}
466
467
468
469struct uwb_rc_evt_bp_slot_change_WUSB_0100 {
470 struct uwb_rceb rceb;
471 u8 bSlotNumber;
472} __attribute__((packed));
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497static
498int hwarc_filter_event_WUSB_0100(struct uwb_rc *rc, struct uwb_rceb **header,
499 const size_t buf_size, size_t *_real_size,
500 size_t *_new_size)
501{
502 int result = -ENOANO;
503 struct uwb_rceb *rceb = *header;
504 int event = le16_to_cpu(rceb->wEvent);
505 ssize_t event_size;
506 size_t core_size, offset;
507
508 if (rceb->bEventType != UWB_RC_CET_GENERAL)
509 goto out;
510 switch (event) {
511 case UWB_RC_EVT_BEACON:
512 core_size = sizeof(struct uwb_rc_evt_beacon_WUSB_0100);
513 offset = offsetof(struct uwb_rc_evt_beacon_WUSB_0100,
514 wBeaconInfoLength);
515 event_size = hwarc_get_event_size(rc, rceb, core_size,
516 offset, buf_size);
517 if (event_size < 0)
518 goto out;
519 *_real_size = event_size;
520 result = hwarc_filter_evt_beacon_WUSB_0100(rc, header,
521 buf_size, _new_size);
522 break;
523 case UWB_RC_EVT_BP_SLOT_CHANGE:
524 *_new_size = *_real_size =
525 sizeof(struct uwb_rc_evt_bp_slot_change_WUSB_0100);
526 result = 0;
527 break;
528
529 case UWB_RC_EVT_DRP_AVAIL:
530 core_size = sizeof(struct uwb_rc_evt_drp_avail_WUSB_0100);
531 offset = offsetof(struct uwb_rc_evt_drp_avail_WUSB_0100,
532 wIELength);
533 event_size = hwarc_get_event_size(rc, rceb, core_size,
534 offset, buf_size);
535 if (event_size < 0)
536 goto out;
537 *_real_size = event_size;
538 result = hwarc_filter_evt_drp_avail_WUSB_0100(
539 rc, header, buf_size, _new_size);
540 break;
541
542 case UWB_RC_EVT_DRP:
543 core_size = sizeof(struct uwb_rc_evt_drp_WUSB_0100);
544 offset = offsetof(struct uwb_rc_evt_drp_WUSB_0100, wIELength);
545 event_size = hwarc_get_event_size(rc, rceb, core_size,
546 offset, buf_size);
547 if (event_size < 0)
548 goto out;
549 *_real_size = event_size;
550 result = hwarc_filter_evt_drp_WUSB_0100(rc, header,
551 buf_size, _new_size);
552 break;
553
554 default:
555 break;
556 }
557out:
558 return result;
559}
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577static
578int hwarc_filter_event(struct uwb_rc *rc, struct uwb_rceb **header,
579 const size_t buf_size, size_t *_real_size,
580 size_t *_new_size)
581{
582 int result = -ENOANO;
583 if (rc->version == 0x0100)
584 result = hwarc_filter_event_WUSB_0100(
585 rc, header, buf_size, _real_size, _new_size);
586 return result;
587}
588
589
590
591
592
593
594
595
596
597
598
599static
600int hwarc_cmd(struct uwb_rc *uwb_rc, const struct uwb_rccb *cmd, size_t cmd_size)
601{
602 struct hwarc *hwarc = uwb_rc->priv;
603 return usb_control_msg(
604 hwarc->usb_dev, usb_sndctrlpipe(hwarc->usb_dev, 0),
605 WA_EXEC_RC_CMD, USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
606 0, hwarc->usb_iface->cur_altsetting->desc.bInterfaceNumber,
607 (void *) cmd, cmd_size, 100 );
608}
609
610static
611int hwarc_reset(struct uwb_rc *uwb_rc)
612{
613 struct hwarc *hwarc = uwb_rc->priv;
614 int result;
615
616
617 result = usb_lock_device_for_reset(hwarc->usb_dev, NULL);
618 if (result >= 0) {
619 result = usb_reset_device(hwarc->usb_dev);
620 usb_unlock_device(hwarc->usb_dev);
621 }
622
623 return result;
624}
625
626
627
628
629
630
631
632static
633void hwarc_neep_cb(struct urb *urb)
634{
635 struct hwarc *hwarc = urb->context;
636 struct usb_interface *usb_iface = hwarc->usb_iface;
637 struct device *dev = &usb_iface->dev;
638 int result;
639
640 switch (result = urb->status) {
641 case 0:
642 uwb_rc_neh_grok(hwarc->uwb_rc, urb->transfer_buffer,
643 urb->actual_length);
644 break;
645 case -ECONNRESET:
646 case -ENOENT:
647 goto out;
648 case -ESHUTDOWN:
649 goto out;
650 default:
651 if (edc_inc(&hwarc->neep_edc, EDC_MAX_ERRORS,
652 EDC_ERROR_TIMEFRAME))
653 goto error_exceeded;
654 dev_err(dev, "NEEP: URB error %d\n", urb->status);
655 }
656 result = usb_submit_urb(urb, GFP_ATOMIC);
657 if (result < 0 && result != -ENODEV && result != -EPERM) {
658
659 dev_err(dev, "NEEP: Can't resubmit URB (%d) resetting device\n",
660 result);
661 goto error;
662 }
663out:
664 return;
665
666error_exceeded:
667 dev_err(dev, "NEEP: URB max acceptable errors "
668 "exceeded, resetting device\n");
669error:
670 uwb_rc_neh_error(hwarc->uwb_rc, result);
671 uwb_rc_reset_all(hwarc->uwb_rc);
672 return;
673}
674
675static void hwarc_init(struct hwarc *hwarc)
676{
677 edc_init(&hwarc->neep_edc);
678}
679
680
681
682
683
684
685
686
687
688static int hwarc_neep_init(struct uwb_rc *rc)
689{
690 struct hwarc *hwarc = rc->priv;
691 struct usb_interface *iface = hwarc->usb_iface;
692 struct usb_device *usb_dev = interface_to_usbdev(iface);
693 struct device *dev = &iface->dev;
694 int result;
695 struct usb_endpoint_descriptor *epd;
696
697 epd = &iface->cur_altsetting->endpoint[0].desc;
698 hwarc->rd_buffer = (void *) __get_free_page(GFP_KERNEL);
699 if (hwarc->rd_buffer == NULL) {
700 dev_err(dev, "Unable to allocate notification's read buffer\n");
701 goto error_rd_buffer;
702 }
703 hwarc->neep_urb = usb_alloc_urb(0, GFP_KERNEL);
704 if (hwarc->neep_urb == NULL)
705 goto error_urb_alloc;
706 usb_fill_int_urb(hwarc->neep_urb, usb_dev,
707 usb_rcvintpipe(usb_dev, epd->bEndpointAddress),
708 hwarc->rd_buffer, PAGE_SIZE,
709 hwarc_neep_cb, hwarc, epd->bInterval);
710 result = usb_submit_urb(hwarc->neep_urb, GFP_ATOMIC);
711 if (result < 0) {
712 dev_err(dev, "Cannot submit notification URB: %d\n", result);
713 goto error_neep_submit;
714 }
715 return 0;
716
717error_neep_submit:
718 usb_free_urb(hwarc->neep_urb);
719 hwarc->neep_urb = NULL;
720error_urb_alloc:
721 free_page((unsigned long)hwarc->rd_buffer);
722 hwarc->rd_buffer = NULL;
723error_rd_buffer:
724 return -ENOMEM;
725}
726
727
728
729static void hwarc_neep_release(struct uwb_rc *rc)
730{
731 struct hwarc *hwarc = rc->priv;
732
733 usb_kill_urb(hwarc->neep_urb);
734 usb_free_urb(hwarc->neep_urb);
735 hwarc->neep_urb = NULL;
736
737 free_page((unsigned long)hwarc->rd_buffer);
738 hwarc->rd_buffer = NULL;
739}
740
741
742
743
744
745
746
747
748
749
750static int hwarc_get_version(struct uwb_rc *rc)
751{
752 int result;
753
754 struct hwarc *hwarc = rc->priv;
755 struct uwb_rc_control_intf_class_desc *descr;
756 struct device *dev = &rc->uwb_dev.dev;
757 struct usb_device *usb_dev = hwarc->usb_dev;
758 char *itr;
759 struct usb_descriptor_header *hdr;
760 size_t itr_size, actconfig_idx;
761 u16 version;
762
763 actconfig_idx = (usb_dev->actconfig - usb_dev->config) /
764 sizeof(usb_dev->config[0]);
765 itr = usb_dev->rawdescriptors[actconfig_idx];
766 itr_size = le16_to_cpu(usb_dev->actconfig->desc.wTotalLength);
767 while (itr_size >= sizeof(*hdr)) {
768 hdr = (struct usb_descriptor_header *) itr;
769 dev_dbg(dev, "Extra device descriptor: "
770 "type %02x/%u bytes @ %zu (%zu left)\n",
771 hdr->bDescriptorType, hdr->bLength,
772 (itr - usb_dev->rawdescriptors[actconfig_idx]),
773 itr_size);
774 if (hdr->bDescriptorType == USB_DT_CS_RADIO_CONTROL)
775 goto found;
776 itr += hdr->bLength;
777 itr_size -= hdr->bLength;
778 }
779 dev_err(dev, "cannot find Radio Control Interface Class descriptor\n");
780 return -ENODEV;
781
782found:
783 result = -EINVAL;
784 if (hdr->bLength > itr_size) {
785 dev_err(dev, "incomplete Radio Control Interface Class "
786 "descriptor (%zu bytes left, %u needed)\n",
787 itr_size, hdr->bLength);
788 goto error;
789 }
790 if (hdr->bLength < sizeof(*descr)) {
791 dev_err(dev, "short Radio Control Interface Class "
792 "descriptor\n");
793 goto error;
794 }
795 descr = (struct uwb_rc_control_intf_class_desc *) hdr;
796
797 version = __le16_to_cpu(descr->bcdRCIVersion);
798 if (version != 0x0100) {
799 dev_err(dev, "Device reports protocol version 0x%04x. We "
800 "do not support that. \n", version);
801 result = -EINVAL;
802 goto error;
803 }
804 rc->version = version;
805 dev_dbg(dev, "Device supports WUSB protocol version 0x%04x \n", rc->version);
806 result = 0;
807error:
808 return result;
809}
810
811
812
813
814
815
816
817
818static int hwarc_probe(struct usb_interface *iface,
819 const struct usb_device_id *id)
820{
821 int result;
822 struct uwb_rc *uwb_rc;
823 struct hwarc *hwarc;
824 struct device *dev = &iface->dev;
825
826 if (iface->cur_altsetting->desc.bNumEndpoints < 1)
827 return -ENODEV;
828 if (!usb_endpoint_xfer_int(&iface->cur_altsetting->endpoint[0].desc))
829 return -ENODEV;
830
831 result = -ENOMEM;
832 uwb_rc = uwb_rc_alloc();
833 if (uwb_rc == NULL) {
834 dev_err(dev, "unable to allocate RC instance\n");
835 goto error_rc_alloc;
836 }
837 hwarc = kzalloc(sizeof(*hwarc), GFP_KERNEL);
838 if (hwarc == NULL) {
839 dev_err(dev, "unable to allocate HWA RC instance\n");
840 goto error_alloc;
841 }
842 hwarc_init(hwarc);
843 hwarc->usb_dev = usb_get_dev(interface_to_usbdev(iface));
844 hwarc->usb_iface = usb_get_intf(iface);
845 hwarc->uwb_rc = uwb_rc;
846
847 uwb_rc->owner = THIS_MODULE;
848 uwb_rc->start = hwarc_neep_init;
849 uwb_rc->stop = hwarc_neep_release;
850 uwb_rc->cmd = hwarc_cmd;
851 uwb_rc->reset = hwarc_reset;
852 if (id->driver_info & WUSB_QUIRK_WHCI_CMD_EVT) {
853 uwb_rc->filter_cmd = NULL;
854 uwb_rc->filter_event = NULL;
855 } else {
856 uwb_rc->filter_cmd = hwarc_filter_cmd;
857 uwb_rc->filter_event = hwarc_filter_event;
858 }
859
860 result = uwb_rc_add(uwb_rc, dev, hwarc);
861 if (result < 0)
862 goto error_rc_add;
863 result = hwarc_get_version(uwb_rc);
864 if (result < 0) {
865 dev_err(dev, "cannot retrieve version of RC \n");
866 goto error_get_version;
867 }
868 usb_set_intfdata(iface, hwarc);
869 return 0;
870
871error_get_version:
872 uwb_rc_rm(uwb_rc);
873error_rc_add:
874 usb_put_intf(iface);
875 usb_put_dev(hwarc->usb_dev);
876 kfree(hwarc);
877error_alloc:
878 uwb_rc_put(uwb_rc);
879error_rc_alloc:
880 return result;
881}
882
883static void hwarc_disconnect(struct usb_interface *iface)
884{
885 struct hwarc *hwarc = usb_get_intfdata(iface);
886 struct uwb_rc *uwb_rc = hwarc->uwb_rc;
887
888 usb_set_intfdata(hwarc->usb_iface, NULL);
889 uwb_rc_rm(uwb_rc);
890 usb_put_intf(hwarc->usb_iface);
891 usb_put_dev(hwarc->usb_dev);
892 kfree(hwarc);
893 uwb_rc_put(uwb_rc);
894}
895
896static int hwarc_pre_reset(struct usb_interface *iface)
897{
898 struct hwarc *hwarc = usb_get_intfdata(iface);
899 struct uwb_rc *uwb_rc = hwarc->uwb_rc;
900
901 uwb_rc_pre_reset(uwb_rc);
902 return 0;
903}
904
905static int hwarc_post_reset(struct usb_interface *iface)
906{
907 struct hwarc *hwarc = usb_get_intfdata(iface);
908 struct uwb_rc *uwb_rc = hwarc->uwb_rc;
909
910 return uwb_rc_post_reset(uwb_rc);
911}
912
913
914static const struct usb_device_id hwarc_id_table[] = {
915
916 { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3d02, 0xe0, 0x01, 0x02),
917 .driver_info = WUSB_QUIRK_WHCI_CMD_EVT },
918
919 { USB_DEVICE_AND_INTERFACE_INFO(0x8086, 0x0c3b, 0xe0, 0x01, 0x02),
920 .driver_info = WUSB_QUIRK_WHCI_CMD_EVT },
921
922 { USB_DEVICE_AND_INTERFACE_INFO(0x13dc, 0x5310, 0xe0, 0x01, 0x02),
923 .driver_info = WUSB_QUIRK_WHCI_CMD_EVT },
924
925 { USB_DEVICE_AND_INTERFACE_INFO(0x13dc, 0x5611, 0xe0, 0x01, 0x02),
926 .driver_info = WUSB_QUIRK_WHCI_CMD_EVT },
927
928 { USB_INTERFACE_INFO(0xe0, 0x01, 0x02), },
929 { },
930};
931MODULE_DEVICE_TABLE(usb, hwarc_id_table);
932
933static struct usb_driver hwarc_driver = {
934 .name = "hwa-rc",
935 .id_table = hwarc_id_table,
936 .probe = hwarc_probe,
937 .disconnect = hwarc_disconnect,
938 .pre_reset = hwarc_pre_reset,
939 .post_reset = hwarc_post_reset,
940};
941
942module_usb_driver(hwarc_driver);
943
944MODULE_AUTHOR("Inaky Perez-Gonzalez <inaky.perez-gonzalez@intel.com>");
945MODULE_DESCRIPTION("Host Wireless Adapter Radio Control Driver");
946MODULE_LICENSE("GPL");
947