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