.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* ZD1211 USB-WLAN driver for Linux |
---|
2 | 3 | * |
---|
3 | 4 | * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de> |
---|
4 | 5 | * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org> |
---|
5 | 6 | * 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/>. |
---|
19 | 7 | */ |
---|
20 | 8 | |
---|
21 | 9 | #include <linux/kernel.h> |
---|
.. | .. |
---|
390 | 378 | int len; |
---|
391 | 379 | u16 int_num; |
---|
392 | 380 | |
---|
393 | | - ZD_ASSERT(in_interrupt()); |
---|
394 | 381 | spin_lock_irqsave(&intr->lock, flags); |
---|
395 | 382 | |
---|
396 | 383 | int_num = le16_to_cpu(*(__le16 *)(urb->transfer_buffer+2)); |
---|
.. | .. |
---|
612 | 599 | dev_dbg_f(zd_usb_dev(usb), "urb %p killed\n", urb); |
---|
613 | 600 | usb_free_urb(urb); |
---|
614 | 601 | |
---|
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); |
---|
618 | 603 | } |
---|
619 | 604 | |
---|
620 | 605 | static void handle_rx_packet(struct zd_usb *usb, const u8 *buffer, |
---|
.. | .. |
---|
1154 | 1139 | zd_usb_reset_rx(usb); |
---|
1155 | 1140 | } |
---|
1156 | 1141 | |
---|
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) |
---|
1158 | 1143 | { |
---|
1159 | | - struct zd_usb *usb = (struct zd_usb *)param; |
---|
| 1144 | + struct zd_usb *usb = from_tasklet(usb, t, rx.reset_timer_tasklet); |
---|
1160 | 1145 | |
---|
1161 | 1146 | zd_usb_reset_rx_idle_timer(usb); |
---|
1162 | 1147 | } |
---|
.. | .. |
---|
1192 | 1177 | } |
---|
1193 | 1178 | ZD_ASSERT(rx->fragment_length == 0); |
---|
1194 | 1179 | 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; |
---|
1197 | 1183 | } |
---|
1198 | 1184 | |
---|
1199 | 1185 | static inline void init_usb_tx(struct zd_usb *usb) |
---|
.. | .. |
---|
1609 | 1595 | } |
---|
1610 | 1596 | } |
---|
1611 | 1597 | |
---|
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 | | - |
---|
1617 | 1598 | static void prepare_read_regs_int(struct zd_usb *usb, |
---|
1618 | 1599 | struct usb_req_read_regs *req, |
---|
1619 | 1600 | unsigned int count) |
---|
.. | .. |
---|
1648 | 1629 | /* The created block size seems to be larger than expected. |
---|
1649 | 1630 | * However results appear to be correct. |
---|
1650 | 1631 | */ |
---|
1651 | | - if (rr->length < usb_int_regs_length(count)) { |
---|
| 1632 | + if (rr->length < struct_size(regs, regs, count)) { |
---|
1652 | 1633 | 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)); |
---|
1655 | 1636 | return false; |
---|
1656 | 1637 | } |
---|
1657 | 1638 | |
---|
.. | .. |
---|
1917 | 1898 | if (!urb) |
---|
1918 | 1899 | return -ENOMEM; |
---|
1919 | 1900 | |
---|
1920 | | - req_len = sizeof(struct usb_req_write_regs) + |
---|
1921 | | - count * sizeof(struct reg_data); |
---|
| 1901 | + req_len = struct_size(req, reg_writes, count); |
---|
1922 | 1902 | req = kmalloc(req_len, GFP_KERNEL); |
---|
1923 | 1903 | if (!req) { |
---|
1924 | 1904 | r = -ENOMEM; |
---|