This source file includes following definitions.
- is_targeted
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 static struct usb_device_id whitelist_table[] = {
16
17
18 { USB_DEVICE_INFO(USB_CLASS_HUB, 0, 0), },
19 { USB_DEVICE_INFO(USB_CLASS_HUB, 0, 1), },
20
21 #ifdef CONFIG_USB_PRINTER
22
23
24
25 { USB_DEVICE_INFO(7, 1, 1) },
26 { USB_DEVICE_INFO(7, 1, 2) },
27 { USB_DEVICE_INFO(7, 1, 3) },
28 #endif
29
30 #ifdef CONFIG_USB_NET_CDCETHER
31
32 { USB_DEVICE(0x0525, 0xa4a1), },
33
34 { USB_DEVICE(0x0525, 0xa4a2), },
35 #endif
36
37 #if IS_ENABLED(CONFIG_USB_TEST)
38
39 { USB_DEVICE(0x0525, 0xa4a0), },
40 #endif
41
42 { }
43 };
44
45 static int is_targeted(struct usb_device *dev)
46 {
47 struct usb_device_id *id = whitelist_table;
48
49
50 if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
51 le16_to_cpu(dev->descriptor.idProduct) == 0xbadd))
52 return 0;
53
54
55 if ((le16_to_cpu(dev->descriptor.idVendor) == 0x1a0a &&
56 le16_to_cpu(dev->descriptor.idProduct) == 0x0200))
57 return 1;
58
59
60
61
62 for (id = whitelist_table; id->match_flags; id++) {
63 if ((id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) &&
64 id->idVendor != le16_to_cpu(dev->descriptor.idVendor))
65 continue;
66
67 if ((id->match_flags & USB_DEVICE_ID_MATCH_PRODUCT) &&
68 id->idProduct != le16_to_cpu(dev->descriptor.idProduct))
69 continue;
70
71
72
73 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_LO) &&
74 (id->bcdDevice_lo > le16_to_cpu(dev->descriptor.bcdDevice)))
75 continue;
76
77 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_HI) &&
78 (id->bcdDevice_hi < le16_to_cpu(dev->descriptor.bcdDevice)))
79 continue;
80
81 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_CLASS) &&
82 (id->bDeviceClass != dev->descriptor.bDeviceClass))
83 continue;
84
85 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_SUBCLASS) &&
86 (id->bDeviceSubClass != dev->descriptor.bDeviceSubClass))
87 continue;
88
89 if ((id->match_flags & USB_DEVICE_ID_MATCH_DEV_PROTOCOL) &&
90 (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol))
91 continue;
92
93 return 1;
94 }
95
96
97
98
99
100 dev_err(&dev->dev, "device v%04x p%04x is not supported\n",
101 le16_to_cpu(dev->descriptor.idVendor),
102 le16_to_cpu(dev->descriptor.idProduct));
103
104 return 0;
105 }
106