hc
2024-05-10 748e4f3d702def1a4bff191e0cf93b6a05340f01
kernel/drivers/net/usb/hso.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /******************************************************************************
23 *
34 * Driver for Option High Speed Mobile Devices.
....@@ -10,21 +11,6 @@
1011 * <ajb@spheresystems.co.uk>
1112 * Copyright (C) 2008 Greg Kroah-Hartman <gregkh@suse.de>
1213 * Copyright (C) 2008 Novell, Inc.
13
- *
14
- * This program is free software; you can redistribute it and/or modify
15
- * it under the terms of the GNU General Public License version 2 as
16
- * published by the Free Software Foundation.
17
- *
18
- * This program is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License
24
- * along with this program; if not, write to the Free Software
25
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
26
- * USA
27
- *
2814 *
2915 *****************************************************************************/
3016
....@@ -200,7 +186,7 @@
200186 int intr_completed;
201187 struct usb_endpoint_descriptor *endp;
202188 struct urb *urb;
203
- struct hso_serial_state_notification serial_state_notification;
189
+ struct hso_serial_state_notification *serial_state_notification;
204190 u16 prev_UART_state_bitmap;
205191 struct uart_icount icount;
206192 };
....@@ -833,7 +819,7 @@
833819 };
834820
835821 /* called when a packet did not ack after watchdogtimeout */
836
-static void hso_net_tx_timeout(struct net_device *net)
822
+static void hso_net_tx_timeout(struct net_device *net, unsigned int txqueue)
837823 {
838824 struct hso_net *odev = netdev_priv(net);
839825
....@@ -844,8 +830,7 @@
844830 dev_warn(&net->dev, "Tx timed out.\n");
845831
846832 /* Tear the waiting frame off the list */
847
- if (odev->mux_bulk_tx_urb &&
848
- (odev->mux_bulk_tx_urb->status == -EINPROGRESS))
833
+ if (odev->mux_bulk_tx_urb)
849834 usb_unlink_urb(odev->mux_bulk_tx_urb);
850835
851836 /* Update statistics */
....@@ -1227,8 +1212,9 @@
12271212 * This needs to be a tasklet otherwise we will
12281213 * end up recursively calling this function.
12291214 */
1230
-static void hso_unthrottle_tasklet(struct hso_serial *serial)
1215
+static void hso_unthrottle_tasklet(unsigned long data)
12311216 {
1217
+ struct hso_serial *serial = (struct hso_serial *)data;
12321218 unsigned long flags;
12331219
12341220 spin_lock_irqsave(&serial->serial_lock, flags);
....@@ -1278,7 +1264,7 @@
12781264 /* Force default termio settings */
12791265 _hso_serial_set_termios(tty, NULL);
12801266 tasklet_init(&serial->unthrottle_tasklet,
1281
- (void (*)(unsigned long))hso_unthrottle_tasklet,
1267
+ hso_unthrottle_tasklet,
12821268 (unsigned long)serial);
12831269 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
12841270 if (result) {
....@@ -1446,7 +1432,7 @@
14461432 usb_rcvintpipe(usb,
14471433 tiocmget->endp->
14481434 bEndpointAddress & 0x7F),
1449
- &tiocmget->serial_state_notification,
1435
+ tiocmget->serial_state_notification,
14501436 sizeof(struct hso_serial_state_notification),
14511437 tiocmget_intr_callback, serial,
14521438 tiocmget->endp->bInterval);
....@@ -1493,7 +1479,7 @@
14931479 /* wIndex should be the USB interface number of the port to which the
14941480 * notification applies, which should always be the Modem port.
14951481 */
1496
- serial_state_notification = &tiocmget->serial_state_notification;
1482
+ serial_state_notification = tiocmget->serial_state_notification;
14971483 if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE ||
14981484 serial_state_notification->bNotification != B_NOTIFICATION ||
14991485 le16_to_cpu(serial_state_notification->wValue) != W_VALUE ||
....@@ -2476,10 +2462,9 @@
24762462 &interface_to_usbdev(interface)->dev,
24772463 RFKILL_TYPE_WWAN,
24782464 &hso_rfkill_ops, hso_dev);
2479
- if (!hso_net->rfkill) {
2480
- dev_err(dev, "%s - Out of memory\n", __func__);
2465
+ if (!hso_net->rfkill)
24812466 return;
2482
- }
2467
+
24832468 if (rfkill_register(hso_net->rfkill) < 0) {
24842469 rfkill_destroy(hso_net->rfkill);
24852470 hso_net->rfkill = NULL;
....@@ -2552,13 +2537,17 @@
25522537 if (!hso_net->mux_bulk_tx_buf)
25532538 goto err_free_tx_urb;
25542539
2555
- add_net_device(hso_dev);
2540
+ result = add_net_device(hso_dev);
2541
+ if (result) {
2542
+ dev_err(&interface->dev, "Failed to add net device\n");
2543
+ goto err_free_tx_buf;
2544
+ }
25562545
25572546 /* registering our net device */
25582547 result = register_netdev(net);
25592548 if (result) {
25602549 dev_err(&interface->dev, "Failed to register device\n");
2561
- goto err_free_tx_buf;
2550
+ goto err_rmv_ndev;
25622551 }
25632552
25642553 hso_log_port(hso_dev);
....@@ -2567,8 +2556,9 @@
25672556
25682557 return hso_dev;
25692558
2570
-err_free_tx_buf:
2559
+err_rmv_ndev:
25712560 remove_net_device(hso_dev);
2561
+err_free_tx_buf:
25722562 kfree(hso_net->mux_bulk_tx_buf);
25732563 err_free_tx_urb:
25742564 usb_free_urb(hso_net->mux_bulk_tx_urb);
....@@ -2594,6 +2584,8 @@
25942584 usb_free_urb(tiocmget->urb);
25952585 tiocmget->urb = NULL;
25962586 serial->tiocmget = NULL;
2587
+ kfree(tiocmget->serial_state_notification);
2588
+ tiocmget->serial_state_notification = NULL;
25972589 kfree(tiocmget);
25982590 }
25992591 }
....@@ -2644,29 +2636,31 @@
26442636 num_urbs = 2;
26452637 serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget),
26462638 GFP_KERNEL);
2647
- /* it isn't going to break our heart if serial->tiocmget
2648
- * allocation fails don't bother checking this.
2649
- */
2650
- if (serial->tiocmget) {
2651
- tiocmget = serial->tiocmget;
2652
- tiocmget->endp = hso_get_ep(interface,
2653
- USB_ENDPOINT_XFER_INT,
2654
- USB_DIR_IN);
2655
- if (!tiocmget->endp) {
2656
- dev_err(&interface->dev, "Failed to find INT IN ep\n");
2657
- goto exit;
2658
- }
2659
-
2660
- tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL);
2661
- if (tiocmget->urb) {
2662
- mutex_init(&tiocmget->mutex);
2663
- init_waitqueue_head(&tiocmget->waitq);
2664
- } else
2665
- hso_free_tiomget(serial);
2639
+ if (!serial->tiocmget)
2640
+ goto exit;
2641
+ serial->tiocmget->serial_state_notification
2642
+ = kzalloc(sizeof(struct hso_serial_state_notification),
2643
+ GFP_KERNEL);
2644
+ if (!serial->tiocmget->serial_state_notification)
2645
+ goto exit;
2646
+ tiocmget = serial->tiocmget;
2647
+ tiocmget->endp = hso_get_ep(interface,
2648
+ USB_ENDPOINT_XFER_INT,
2649
+ USB_DIR_IN);
2650
+ if (!tiocmget->endp) {
2651
+ dev_err(&interface->dev, "Failed to find INT IN ep\n");
2652
+ goto exit;
26662653 }
2667
- }
2668
- else
2654
+
2655
+ tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL);
2656
+ if (!tiocmget->urb)
2657
+ goto exit;
2658
+
2659
+ mutex_init(&tiocmget->mutex);
2660
+ init_waitqueue_head(&tiocmget->waitq);
2661
+ } else {
26692662 num_urbs = 1;
2663
+ }
26702664
26712665 if (hso_serial_common_create(serial, num_urbs, BULK_URB_RX_SIZE,
26722666 BULK_URB_TX_SIZE))
....@@ -2682,7 +2676,7 @@
26822676 if (!
26832677 (serial->out_endp =
26842678 hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, USB_DIR_OUT))) {
2685
- dev_err(&interface->dev, "Failed to find BULK IN ep\n");
2679
+ dev_err(&interface->dev, "Failed to find BULK OUT ep\n");
26862680 goto exit2;
26872681 }
26882682