forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/usb/serial/sierra.c
....@@ -45,10 +45,9 @@
4545
4646 static bool nmea;
4747
48
-/* Used in interface blacklisting */
49
-struct sierra_iface_info {
50
- const u32 infolen; /* number of interface numbers on blacklist */
51
- const u8 *ifaceinfo; /* pointer to the array holding the numbers */
48
+struct sierra_iface_list {
49
+ const u8 *nums; /* array of interface numbers */
50
+ size_t count; /* number of elements in array */
5251 };
5352
5453 struct sierra_intf_private {
....@@ -101,38 +100,19 @@
101100 return num_ports;
102101 }
103102
104
-static int is_blacklisted(const u8 ifnum,
105
- const struct sierra_iface_info *blacklist)
103
+static bool is_listed(const u8 ifnum, const struct sierra_iface_list *list)
106104 {
107
- const u8 *info;
108105 int i;
109106
110
- if (blacklist) {
111
- info = blacklist->ifaceinfo;
107
+ if (!list)
108
+ return false;
112109
113
- for (i = 0; i < blacklist->infolen; i++) {
114
- if (info[i] == ifnum)
115
- return 1;
116
- }
110
+ for (i = 0; i < list->count; i++) {
111
+ if (list->nums[i] == ifnum)
112
+ return true;
117113 }
118
- return 0;
119
-}
120114
121
-static int is_himemory(const u8 ifnum,
122
- const struct sierra_iface_info *himemorylist)
123
-{
124
- const u8 *info;
125
- int i;
126
-
127
- if (himemorylist) {
128
- info = himemorylist->ifaceinfo;
129
-
130
- for (i=0; i < himemorylist->infolen; i++) {
131
- if (info[i] == ifnum)
132
- return 1;
133
- }
134
- }
135
- return 0;
115
+ return false;
136116 }
137117
138118 static u8 sierra_interface_num(struct usb_serial *serial)
....@@ -143,6 +123,7 @@
143123 static int sierra_probe(struct usb_serial *serial,
144124 const struct usb_device_id *id)
145125 {
126
+ const struct sierra_iface_list *ignore_list;
146127 int result = 0;
147128 struct usb_device *udev;
148129 u8 ifnum;
....@@ -161,10 +142,10 @@
161142 usb_set_interface(udev, ifnum, 1);
162143 }
163144
164
- if (is_blacklisted(ifnum,
165
- (struct sierra_iface_info *)id->driver_info)) {
166
- dev_dbg(&serial->dev->dev,
167
- "Ignoring blacklisted interface #%d\n", ifnum);
145
+ ignore_list = (const struct sierra_iface_list *)id->driver_info;
146
+
147
+ if (is_listed(ifnum, ignore_list)) {
148
+ dev_dbg(&serial->dev->dev, "Ignoring interface #%d\n", ifnum);
168149 return -ENODEV;
169150 }
170151
....@@ -173,22 +154,22 @@
173154
174155 /* interfaces with higher memory requirements */
175156 static const u8 hi_memory_typeA_ifaces[] = { 0, 2 };
176
-static const struct sierra_iface_info typeA_interface_list = {
177
- .infolen = ARRAY_SIZE(hi_memory_typeA_ifaces),
178
- .ifaceinfo = hi_memory_typeA_ifaces,
157
+static const struct sierra_iface_list typeA_interface_list = {
158
+ .nums = hi_memory_typeA_ifaces,
159
+ .count = ARRAY_SIZE(hi_memory_typeA_ifaces),
179160 };
180161
181162 static const u8 hi_memory_typeB_ifaces[] = { 3, 4, 5, 6 };
182
-static const struct sierra_iface_info typeB_interface_list = {
183
- .infolen = ARRAY_SIZE(hi_memory_typeB_ifaces),
184
- .ifaceinfo = hi_memory_typeB_ifaces,
163
+static const struct sierra_iface_list typeB_interface_list = {
164
+ .nums = hi_memory_typeB_ifaces,
165
+ .count = ARRAY_SIZE(hi_memory_typeB_ifaces),
185166 };
186167
187
-/* 'blacklist' of interfaces not served by this driver */
168
+/* 'ignorelist' of interfaces not served by this driver */
188169 static const u8 direct_ip_non_serial_ifaces[] = { 7, 8, 9, 10, 11, 19, 20 };
189
-static const struct sierra_iface_info direct_ip_interface_blacklist = {
190
- .infolen = ARRAY_SIZE(direct_ip_non_serial_ifaces),
191
- .ifaceinfo = direct_ip_non_serial_ifaces,
170
+static const struct sierra_iface_list direct_ip_interface_ignore = {
171
+ .nums = direct_ip_non_serial_ifaces,
172
+ .count = ARRAY_SIZE(direct_ip_non_serial_ifaces),
192173 };
193174
194175 static const struct usb_device_id id_table[] = {
....@@ -264,19 +245,19 @@
264245 { USB_DEVICE(0x1199, 0x6893) }, /* Sierra Wireless Device */
265246 /* Sierra Wireless Direct IP modems */
266247 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68A3, 0xFF, 0xFF, 0xFF),
267
- .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
248
+ .driver_info = (kernel_ulong_t)&direct_ip_interface_ignore
268249 },
269250 { USB_DEVICE_AND_INTERFACE_INFO(0x1199, 0x68AA, 0xFF, 0xFF, 0xFF),
270
- .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
251
+ .driver_info = (kernel_ulong_t)&direct_ip_interface_ignore
271252 },
272253 { USB_DEVICE(0x1199, 0x68AB) }, /* Sierra Wireless AR8550 */
273254 /* AT&T Direct IP LTE modems */
274255 { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68AA, 0xFF, 0xFF, 0xFF),
275
- .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
256
+ .driver_info = (kernel_ulong_t)&direct_ip_interface_ignore
276257 },
277258 /* Airprime/Sierra Wireless Direct IP modems */
278259 { USB_DEVICE_AND_INTERFACE_INFO(0x0F3D, 0x68A3, 0xFF, 0xFF, 0xFF),
279
- .driver_info = (kernel_ulong_t)&direct_ip_interface_blacklist
260
+ .driver_info = (kernel_ulong_t)&direct_ip_interface_ignore
280261 },
281262
282263 { }
....@@ -589,8 +570,7 @@
589570 urb, port, portdata);
590571
591572 if (status == 0) {
592
- struct usb_ctrlrequest *req_pkt =
593
- (struct usb_ctrlrequest *)urb->transfer_buffer;
573
+ struct usb_ctrlrequest *req_pkt = urb->transfer_buffer;
594574
595575 if (!req_pkt) {
596576 dev_dbg(&port->dev, "%s: NULL req_pkt\n",
....@@ -757,7 +737,8 @@
757737
758738 /*
759739 * Need to take susp_lock to make sure port is not already being
760
- * resumed, but no need to hold it due to initialized
740
+ * resumed, but no need to hold it due to the tty-port initialized
741
+ * flag.
761742 */
762743 spin_lock_irq(&intfdata->susp_lock);
763744 if (--intfdata->open_ports == 0)
....@@ -879,7 +860,7 @@
879860 {
880861 struct usb_serial *serial = port->serial;
881862 struct sierra_port_private *portdata;
882
- const struct sierra_iface_info *himemoryp;
863
+ const struct sierra_iface_list *himemory_list;
883864 u8 ifnum;
884865
885866 portdata = kzalloc(sizeof(*portdata), GFP_KERNEL);
....@@ -898,16 +879,16 @@
898879 if (serial->num_ports == 1) {
899880 /* Get interface number for composite device */
900881 ifnum = sierra_interface_num(serial);
901
- himemoryp = &typeB_interface_list;
882
+ himemory_list = &typeB_interface_list;
902883 } else {
903884 /* This is really the usb-serial port number of the interface
904885 * rather than the interface number.
905886 */
906887 ifnum = port->port_number;
907
- himemoryp = &typeA_interface_list;
888
+ himemory_list = &typeA_interface_list;
908889 }
909890
910
- if (is_himemory(ifnum, himemoryp)) {
891
+ if (is_listed(ifnum, himemory_list)) {
911892 portdata->num_out_urbs = N_OUT_URB_HM;
912893 portdata->num_in_urbs = N_IN_URB_HM;
913894 }