forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/drivers/net/wireless/zydas/zd1211rw/zd_usb.c
....@@ -1,21 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* ZD1211 USB-WLAN driver for Linux
23 *
34 * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de>
45 * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org>
56 * Copyright (C) 2006-2007 Michael Wu <flamingice@sourmilk.net>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License
18
- * along with this program; if not, see <http://www.gnu.org/licenses/>.
197 */
208
219 #include <linux/kernel.h>
....@@ -390,7 +378,6 @@
390378 int len;
391379 u16 int_num;
392380
393
- ZD_ASSERT(in_interrupt());
394381 spin_lock_irqsave(&intr->lock, flags);
395382
396383 int_num = le16_to_cpu(*(__le16 *)(urb->transfer_buffer+2));
....@@ -612,9 +599,7 @@
612599 dev_dbg_f(zd_usb_dev(usb), "urb %p killed\n", urb);
613600 usb_free_urb(urb);
614601
615
- if (buffer)
616
- usb_free_coherent(udev, USB_MAX_EP_INT_BUFFER,
617
- buffer, buffer_dma);
602
+ usb_free_coherent(udev, USB_MAX_EP_INT_BUFFER, buffer, buffer_dma);
618603 }
619604
620605 static void handle_rx_packet(struct zd_usb *usb, const u8 *buffer,
....@@ -1154,9 +1139,9 @@
11541139 zd_usb_reset_rx(usb);
11551140 }
11561141
1157
-static void zd_usb_reset_rx_idle_timer_tasklet(unsigned long param)
1142
+static void zd_usb_reset_rx_idle_timer_tasklet(struct tasklet_struct *t)
11581143 {
1159
- struct zd_usb *usb = (struct zd_usb *)param;
1144
+ struct zd_usb *usb = from_tasklet(usb, t, rx.reset_timer_tasklet);
11601145
11611146 zd_usb_reset_rx_idle_timer(usb);
11621147 }
....@@ -1192,8 +1177,9 @@
11921177 }
11931178 ZD_ASSERT(rx->fragment_length == 0);
11941179 INIT_DELAYED_WORK(&rx->idle_work, zd_rx_idle_timer_handler);
1195
- rx->reset_timer_tasklet.func = zd_usb_reset_rx_idle_timer_tasklet;
1196
- rx->reset_timer_tasklet.data = (unsigned long)usb;
1180
+ rx->reset_timer_tasklet.func = (void (*))
1181
+ zd_usb_reset_rx_idle_timer_tasklet;
1182
+ rx->reset_timer_tasklet.data = (unsigned long)&rx->reset_timer_tasklet;
11971183 }
11981184
11991185 static inline void init_usb_tx(struct zd_usb *usb)
....@@ -1609,11 +1595,6 @@
16091595 }
16101596 }
16111597
1612
-static int usb_int_regs_length(unsigned int count)
1613
-{
1614
- return sizeof(struct usb_int_regs) + count * sizeof(struct reg_data);
1615
-}
1616
-
16171598 static void prepare_read_regs_int(struct zd_usb *usb,
16181599 struct usb_req_read_regs *req,
16191600 unsigned int count)
....@@ -1648,10 +1629,10 @@
16481629 /* The created block size seems to be larger than expected.
16491630 * However results appear to be correct.
16501631 */
1651
- if (rr->length < usb_int_regs_length(count)) {
1632
+ if (rr->length < struct_size(regs, regs, count)) {
16521633 dev_dbg_f(zd_usb_dev(usb),
1653
- "error: actual length %d less than expected %d\n",
1654
- rr->length, usb_int_regs_length(count));
1634
+ "error: actual length %d less than expected %zu\n",
1635
+ rr->length, struct_size(regs, regs, count));
16551636 return false;
16561637 }
16571638
....@@ -1917,8 +1898,7 @@
19171898 if (!urb)
19181899 return -ENOMEM;
19191900
1920
- req_len = sizeof(struct usb_req_write_regs) +
1921
- count * sizeof(struct reg_data);
1901
+ req_len = struct_size(req, reg_writes, count);
19221902 req = kmalloc(req_len, GFP_KERNEL);
19231903 if (!req) {
19241904 r = -ENOMEM;