.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* hfcsusb.c |
---|
2 | 3 | * mISDN driver for Colognechip HFC-S USB chip |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2001 by Peter Sprenger (sprenger@moving-bytes.de) |
---|
5 | 6 | * 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 | | - * |
---|
21 | 7 | * |
---|
22 | 8 | * module params |
---|
23 | 9 | * debug=<n>, default=0, with n=0xHHHHGGGG |
---|
.. | .. |
---|
60 | 46 | static void hfcsusb_stop_endpoint(struct hfcsusb *hw, int channel); |
---|
61 | 47 | static int hfcsusb_setup_bch(struct bchannel *bch, int protocol); |
---|
62 | 48 | 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); |
---|
64 | 50 | |
---|
65 | 51 | /* start next background transfer for control channel */ |
---|
66 | 52 | static void |
---|
.. | .. |
---|
255 | 241 | * send full D/B channel status information |
---|
256 | 242 | * as MPH_INFORMATION_IND |
---|
257 | 243 | */ |
---|
258 | | -static void |
---|
| 244 | +static int |
---|
259 | 245 | hfcsusb_ph_info(struct hfcsusb *hw) |
---|
260 | 246 | { |
---|
261 | 247 | struct ph_info *phi; |
---|
262 | 248 | struct dchannel *dch = &hw->dch; |
---|
263 | 249 | int i; |
---|
264 | 250 | |
---|
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 | + |
---|
267 | 255 | phi->dch.ch.protocol = hw->protocol; |
---|
268 | 256 | phi->dch.ch.Flags = dch->Flags; |
---|
269 | 257 | phi->dch.state = dch->state; |
---|
.. | .. |
---|
273 | 261 | phi->bch[i].Flags = hw->bch[i].Flags; |
---|
274 | 262 | } |
---|
275 | 263 | _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); |
---|
278 | 265 | kfree(phi); |
---|
| 266 | + |
---|
| 267 | + return 0; |
---|
279 | 268 | } |
---|
280 | 269 | |
---|
281 | 270 | /* |
---|
.. | .. |
---|
360 | 349 | ret = l1_event(dch->l1, hh->prim); |
---|
361 | 350 | break; |
---|
362 | 351 | case MPH_INFORMATION_REQ: |
---|
363 | | - hfcsusb_ph_info(hw); |
---|
364 | | - ret = 0; |
---|
| 352 | + ret = hfcsusb_ph_info(hw); |
---|
365 | 353 | break; |
---|
366 | 354 | } |
---|
367 | 355 | |
---|
.. | .. |
---|
416 | 404 | hw->name, __func__, cmd); |
---|
417 | 405 | return -1; |
---|
418 | 406 | } |
---|
419 | | - hfcsusb_ph_info(hw); |
---|
420 | | - return 0; |
---|
| 407 | + return hfcsusb_ph_info(hw); |
---|
421 | 408 | } |
---|
422 | 409 | |
---|
423 | 410 | static int |
---|
.. | .. |
---|
708 | 695 | switch (protocol) { |
---|
709 | 696 | case (-1): /* used for init */ |
---|
710 | 697 | bch->state = -1; |
---|
711 | | - /* fall through */ |
---|
| 698 | + fallthrough; |
---|
712 | 699 | case (ISDN_P_NONE): |
---|
713 | 700 | if (bch->state == ISDN_P_NONE) |
---|
714 | 701 | return 0; /* already in idle state */ |
---|
.. | .. |
---|
759 | 746 | handle_led(hw, (bch->nr == 1) ? LED_B1_OFF : |
---|
760 | 747 | LED_B2_OFF); |
---|
761 | 748 | } |
---|
762 | | - hfcsusb_ph_info(hw); |
---|
763 | | - return 0; |
---|
| 749 | + return hfcsusb_ph_info(hw); |
---|
764 | 750 | } |
---|
765 | 751 | |
---|
766 | 752 | static void |
---|
.. | .. |
---|
853 | 839 | if (maxlen < 0) { |
---|
854 | 840 | if (rx_skb) |
---|
855 | 841 | 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); |
---|
858 | 844 | spin_unlock_irqrestore(&hw->lock, flags); |
---|
859 | 845 | return; |
---|
860 | 846 | } |
---|