hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/isdn/hardware/mISDN/hfcsusb.c
....@@ -1,23 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /* hfcsusb.c
23 * mISDN driver for Colognechip HFC-S USB chip
34 *
45 * Copyright 2001 by Peter Sprenger (sprenger@moving-bytes.de)
56 * Copyright 2008 by Martin Bachem (info@bachem-it.com)
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, or (at your option)
10
- * 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, write to the Free Software
19
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
- *
217 *
228 * module params
239 * debug=<n>, default=0, with n=0xHHHHGGGG
....@@ -60,7 +46,7 @@
6046 static void hfcsusb_stop_endpoint(struct hfcsusb *hw, int channel);
6147 static int hfcsusb_setup_bch(struct bchannel *bch, int protocol);
6248 static void deactivate_bchannel(struct bchannel *bch);
63
-static void hfcsusb_ph_info(struct hfcsusb *hw);
49
+static int hfcsusb_ph_info(struct hfcsusb *hw);
6450
6551 /* start next background transfer for control channel */
6652 static void
....@@ -255,15 +241,17 @@
255241 * send full D/B channel status information
256242 * as MPH_INFORMATION_IND
257243 */
258
-static void
244
+static int
259245 hfcsusb_ph_info(struct hfcsusb *hw)
260246 {
261247 struct ph_info *phi;
262248 struct dchannel *dch = &hw->dch;
263249 int i;
264250
265
- phi = kzalloc(sizeof(struct ph_info) +
266
- dch->dev.nrbchan * sizeof(struct ph_info_ch), GFP_ATOMIC);
251
+ phi = kzalloc(struct_size(phi, bch, dch->dev.nrbchan), GFP_ATOMIC);
252
+ if (!phi)
253
+ return -ENOMEM;
254
+
267255 phi->dch.ch.protocol = hw->protocol;
268256 phi->dch.ch.Flags = dch->Flags;
269257 phi->dch.state = dch->state;
....@@ -273,9 +261,10 @@
273261 phi->bch[i].Flags = hw->bch[i].Flags;
274262 }
275263 _queue_data(&dch->dev.D, MPH_INFORMATION_IND, MISDN_ID_ANY,
276
- sizeof(struct ph_info_dch) + dch->dev.nrbchan *
277
- sizeof(struct ph_info_ch), phi, GFP_ATOMIC);
264
+ struct_size(phi, bch, dch->dev.nrbchan), phi, GFP_ATOMIC);
278265 kfree(phi);
266
+
267
+ return 0;
279268 }
280269
281270 /*
....@@ -337,20 +326,24 @@
337326 test_and_clear_bit(FLG_L2_ACTIVATED, &dch->Flags);
338327
339328 if (hw->protocol == ISDN_P_NT_S0) {
329
+ struct sk_buff_head free_queue;
330
+
331
+ __skb_queue_head_init(&free_queue);
340332 hfcsusb_ph_command(hw, HFC_L1_DEACTIVATE_NT);
341333 spin_lock_irqsave(&hw->lock, flags);
342
- skb_queue_purge(&dch->squeue);
334
+ skb_queue_splice_init(&dch->squeue, &free_queue);
343335 if (dch->tx_skb) {
344
- dev_kfree_skb(dch->tx_skb);
336
+ __skb_queue_tail(&free_queue, dch->tx_skb);
345337 dch->tx_skb = NULL;
346338 }
347339 dch->tx_idx = 0;
348340 if (dch->rx_skb) {
349
- dev_kfree_skb(dch->rx_skb);
341
+ __skb_queue_tail(&free_queue, dch->rx_skb);
350342 dch->rx_skb = NULL;
351343 }
352344 test_and_clear_bit(FLG_TX_BUSY, &dch->Flags);
353345 spin_unlock_irqrestore(&hw->lock, flags);
346
+ __skb_queue_purge(&free_queue);
354347 #ifdef FIXME
355348 if (test_and_clear_bit(FLG_L1_BUSY, &dch->Flags))
356349 dchannel_sched_event(&hc->dch, D_CLEARBUSY);
....@@ -360,8 +353,7 @@
360353 ret = l1_event(dch->l1, hh->prim);
361354 break;
362355 case MPH_INFORMATION_REQ:
363
- hfcsusb_ph_info(hw);
364
- ret = 0;
356
+ ret = hfcsusb_ph_info(hw);
365357 break;
366358 }
367359
....@@ -416,8 +408,7 @@
416408 hw->name, __func__, cmd);
417409 return -1;
418410 }
419
- hfcsusb_ph_info(hw);
420
- return 0;
411
+ return hfcsusb_ph_info(hw);
421412 }
422413
423414 static int
....@@ -708,7 +699,7 @@
708699 switch (protocol) {
709700 case (-1): /* used for init */
710701 bch->state = -1;
711
- /* fall through */
702
+ fallthrough;
712703 case (ISDN_P_NONE):
713704 if (bch->state == ISDN_P_NONE)
714705 return 0; /* already in idle state */
....@@ -759,8 +750,7 @@
759750 handle_led(hw, (bch->nr == 1) ? LED_B1_OFF :
760751 LED_B2_OFF);
761752 }
762
- hfcsusb_ph_info(hw);
763
- return 0;
753
+ return hfcsusb_ph_info(hw);
764754 }
765755
766756 static void
....@@ -853,8 +843,8 @@
853843 if (maxlen < 0) {
854844 if (rx_skb)
855845 skb_trim(rx_skb, 0);
856
- pr_warning("%s.B%d: No bufferspace for %d bytes\n",
857
- hw->name, fifo->bch->nr, len);
846
+ pr_warn("%s.B%d: No bufferspace for %d bytes\n",
847
+ hw->name, fifo->bch->nr, len);
858848 spin_unlock_irqrestore(&hw->lock, flags);
859849 return;
860850 }
....@@ -1344,7 +1334,7 @@
13441334 printk("\n");
13451335 }
13461336
1347
- dev_kfree_skb(tx_skb);
1337
+ dev_consume_skb_irq(tx_skb);
13481338 tx_skb = NULL;
13491339 if (fifo->dch && get_next_dframe(fifo->dch))
13501340 tx_skb = fifo->dch->tx_skb;