hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/isdn/hardware/mISDN/hfcpci.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 *
34 * hfcpci.c low level driver for CCD's hfc-pci based cards
....@@ -8,20 +9,6 @@
89 *
910 * Copyright 1999 by Werner Cornelius (werner@isdn-development.de)
1011 * Copyright 2008 by Karsten Keil <kkeil@novell.com>
11
- *
12
- * This program is free software; you can redistribute it and/or modify
13
- * it under the terms of the GNU General Public License as published by
14
- * the Free Software Foundation; either version 2, or (at your option)
15
- * any later version.
16
- *
17
- * This program is distributed in the hope that it will be useful,
18
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20
- * GNU General Public License for more details.
21
- *
22
- * You should have received a copy of the GNU General Public License
23
- * along with this program; if not, write to the Free Software
24
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2512 *
2613 * Module options:
2714 *
....@@ -41,7 +28,6 @@
4128 * If kernel uses a frequency of 1000 Hz, steps of 8 samples are possible.
4229 * If the kernel uses 100 Hz, steps of 80 samples are possible.
4330 * If the kernel uses 300 Hz, steps of about 26 samples are possible.
44
- *
4531 */
4632
4733 #include <linux/interrupt.h>
....@@ -172,7 +158,8 @@
172158 /* disable memory mapped ports + busmaster */
173159 pci_write_config_word(hc->pdev, PCI_COMMAND, 0);
174160 del_timer(&hc->hw.timer);
175
- pci_free_consistent(hc->pdev, 0x8000, hc->hw.fifos, hc->hw.dmahandle);
161
+ dma_free_coherent(&hc->pdev->dev, 0x8000, hc->hw.fifos,
162
+ hc->hw.dmahandle);
176163 iounmap(hc->hw.pci_io);
177164 }
178165
....@@ -580,8 +567,7 @@
580567 }
581568 maxlen = bchannel_get_rxbuf(bch, fcnt_rx);
582569 if (maxlen < 0) {
583
- pr_warning("B%d: No bufferspace for %d bytes\n",
584
- bch->nr, fcnt_rx);
570
+ pr_warn("B%d: No bufferspace for %d bytes\n", bch->nr, fcnt_rx);
585571 } else {
586572 ptr = skb_put(bch->rx_skb, fcnt_rx);
587573 if (le16_to_cpu(*z2r) + fcnt_rx <= B_FIFO_SIZE + B_SUB_VAL)
....@@ -1133,8 +1119,7 @@
11331119 if (bch->tx_skb && bch->tx_idx < bch->tx_skb->len)
11341120 hfcpci_fill_fifo(bch);
11351121 else {
1136
- if (bch->tx_skb)
1137
- dev_kfree_skb(bch->tx_skb);
1122
+ dev_kfree_skb(bch->tx_skb);
11381123 if (get_next_bframe(bch))
11391124 hfcpci_fill_fifo(bch);
11401125 }
....@@ -1146,8 +1131,7 @@
11461131 if (dch->tx_skb && dch->tx_idx < dch->tx_skb->len)
11471132 hfcpci_fill_dfifo(dch->hw);
11481133 else {
1149
- if (dch->tx_skb)
1150
- dev_kfree_skb(dch->tx_skb);
1134
+ dev_kfree_skb(dch->tx_skb);
11511135 if (get_next_dframe(dch))
11521136 hfcpci_fill_dfifo(dch->hw);
11531137 }
....@@ -1296,7 +1280,7 @@
12961280 case (-1): /* used for init */
12971281 bch->state = -1;
12981282 bch->nr = bc;
1299
- /* fall through */
1283
+ fallthrough;
13001284 case (ISDN_P_NONE):
13011285 if (bch->state == ISDN_P_NONE)
13021286 return 0;
....@@ -2010,32 +1994,46 @@
20101994 pci_set_master(hc->pdev);
20111995 if (!hc->irq) {
20121996 printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n");
2013
- return 1;
1997
+ return -EINVAL;
20141998 }
20151999 hc->hw.pci_io =
20162000 (char __iomem *)(unsigned long)hc->pdev->resource[1].start;
20172001
20182002 if (!hc->hw.pci_io) {
20192003 printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n");
2020
- return 1;
2004
+ return -ENOMEM;
20212005 }
20222006 /* Allocate memory for FIFOS */
20232007 /* the memory needs to be on a 32k boundary within the first 4G */
2024
- pci_set_dma_mask(hc->pdev, 0xFFFF8000);
2025
- buffer = pci_alloc_consistent(hc->pdev, 0x8000, &hc->hw.dmahandle);
2008
+ if (dma_set_mask(&hc->pdev->dev, 0xFFFF8000)) {
2009
+ printk(KERN_WARNING
2010
+ "HFC-PCI: No usable DMA configuration!\n");
2011
+ return -EIO;
2012
+ }
2013
+ buffer = dma_alloc_coherent(&hc->pdev->dev, 0x8000, &hc->hw.dmahandle,
2014
+ GFP_KERNEL);
20262015 /* We silently assume the address is okay if nonzero */
20272016 if (!buffer) {
20282017 printk(KERN_WARNING
20292018 "HFC-PCI: Error allocating memory for FIFO!\n");
2030
- return 1;
2019
+ return -ENOMEM;
20312020 }
20322021 hc->hw.fifos = buffer;
20332022 pci_write_config_dword(hc->pdev, 0x80, hc->hw.dmahandle);
20342023 hc->hw.pci_io = ioremap((ulong) hc->hw.pci_io, 256);
2024
+ if (unlikely(!hc->hw.pci_io)) {
2025
+ printk(KERN_WARNING
2026
+ "HFC-PCI: Error in ioremap for PCI!\n");
2027
+ dma_free_coherent(&hc->pdev->dev, 0x8000, hc->hw.fifos,
2028
+ hc->hw.dmahandle);
2029
+ return -ENOMEM;
2030
+ }
2031
+
20352032 printk(KERN_INFO
2036
- "HFC-PCI: defined at mem %#lx fifo %#lx(%#lx) IRQ %d HZ %d\n",
2037
- (u_long) hc->hw.pci_io, (u_long) hc->hw.fifos,
2038
- (u_long) hc->hw.dmahandle, hc->irq, HZ);
2033
+ "HFC-PCI: defined at mem %#lx fifo %p(%pad) IRQ %d HZ %d\n",
2034
+ (u_long) hc->hw.pci_io, hc->hw.fifos,
2035
+ &hc->hw.dmahandle, hc->irq, HZ);
2036
+
20392037 /* enable memory mapped ports, disable busmaster */
20402038 pci_write_config_word(hc->pdev, PCI_COMMAND, PCI_ENA_MEMIO);
20412039 hc->hw.int_m2 = 0;