hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
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 /*
....@@ -360,8 +349,7 @@
360349 ret = l1_event(dch->l1, hh->prim);
361350 break;
362351 case MPH_INFORMATION_REQ:
363
- hfcsusb_ph_info(hw);
364
- ret = 0;
352
+ ret = hfcsusb_ph_info(hw);
365353 break;
366354 }
367355
....@@ -416,8 +404,7 @@
416404 hw->name, __func__, cmd);
417405 return -1;
418406 }
419
- hfcsusb_ph_info(hw);
420
- return 0;
407
+ return hfcsusb_ph_info(hw);
421408 }
422409
423410 static int
....@@ -708,7 +695,7 @@
708695 switch (protocol) {
709696 case (-1): /* used for init */
710697 bch->state = -1;
711
- /* fall through */
698
+ fallthrough;
712699 case (ISDN_P_NONE):
713700 if (bch->state == ISDN_P_NONE)
714701 return 0; /* already in idle state */
....@@ -759,8 +746,7 @@
759746 handle_led(hw, (bch->nr == 1) ? LED_B1_OFF :
760747 LED_B2_OFF);
761748 }
762
- hfcsusb_ph_info(hw);
763
- return 0;
749
+ return hfcsusb_ph_info(hw);
764750 }
765751
766752 static void
....@@ -853,8 +839,8 @@
853839 if (maxlen < 0) {
854840 if (rx_skb)
855841 skb_trim(rx_skb, 0);
856
- pr_warning("%s.B%d: No bufferspace for %d bytes\n",
857
- hw->name, fifo->bch->nr, len);
842
+ pr_warn("%s.B%d: No bufferspace for %d bytes\n",
843
+ hw->name, fifo->bch->nr, len);
858844 spin_unlock_irqrestore(&hw->lock, flags);
859845 return;
860846 }