.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * |
---|
3 | 4 | * hfcpci.c low level driver for CCD's hfc-pci based cards |
---|
.. | .. |
---|
8 | 9 | * |
---|
9 | 10 | * Copyright 1999 by Werner Cornelius (werner@isdn-development.de) |
---|
10 | 11 | * 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. |
---|
25 | 12 | * |
---|
26 | 13 | * Module options: |
---|
27 | 14 | * |
---|
.. | .. |
---|
41 | 28 | * If kernel uses a frequency of 1000 Hz, steps of 8 samples are possible. |
---|
42 | 29 | * If the kernel uses 100 Hz, steps of 80 samples are possible. |
---|
43 | 30 | * If the kernel uses 300 Hz, steps of about 26 samples are possible. |
---|
44 | | - * |
---|
45 | 31 | */ |
---|
46 | 32 | |
---|
47 | 33 | #include <linux/interrupt.h> |
---|
.. | .. |
---|
172 | 158 | /* disable memory mapped ports + busmaster */ |
---|
173 | 159 | pci_write_config_word(hc->pdev, PCI_COMMAND, 0); |
---|
174 | 160 | 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); |
---|
176 | 163 | iounmap(hc->hw.pci_io); |
---|
177 | 164 | } |
---|
178 | 165 | |
---|
.. | .. |
---|
580 | 567 | } |
---|
581 | 568 | maxlen = bchannel_get_rxbuf(bch, fcnt_rx); |
---|
582 | 569 | 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); |
---|
585 | 571 | } else { |
---|
586 | 572 | ptr = skb_put(bch->rx_skb, fcnt_rx); |
---|
587 | 573 | if (le16_to_cpu(*z2r) + fcnt_rx <= B_FIFO_SIZE + B_SUB_VAL) |
---|
.. | .. |
---|
1133 | 1119 | if (bch->tx_skb && bch->tx_idx < bch->tx_skb->len) |
---|
1134 | 1120 | hfcpci_fill_fifo(bch); |
---|
1135 | 1121 | else { |
---|
1136 | | - if (bch->tx_skb) |
---|
1137 | | - dev_kfree_skb(bch->tx_skb); |
---|
| 1122 | + dev_kfree_skb(bch->tx_skb); |
---|
1138 | 1123 | if (get_next_bframe(bch)) |
---|
1139 | 1124 | hfcpci_fill_fifo(bch); |
---|
1140 | 1125 | } |
---|
.. | .. |
---|
1146 | 1131 | if (dch->tx_skb && dch->tx_idx < dch->tx_skb->len) |
---|
1147 | 1132 | hfcpci_fill_dfifo(dch->hw); |
---|
1148 | 1133 | else { |
---|
1149 | | - if (dch->tx_skb) |
---|
1150 | | - dev_kfree_skb(dch->tx_skb); |
---|
| 1134 | + dev_kfree_skb(dch->tx_skb); |
---|
1151 | 1135 | if (get_next_dframe(dch)) |
---|
1152 | 1136 | hfcpci_fill_dfifo(dch->hw); |
---|
1153 | 1137 | } |
---|
.. | .. |
---|
1296 | 1280 | case (-1): /* used for init */ |
---|
1297 | 1281 | bch->state = -1; |
---|
1298 | 1282 | bch->nr = bc; |
---|
1299 | | - /* fall through */ |
---|
| 1283 | + fallthrough; |
---|
1300 | 1284 | case (ISDN_P_NONE): |
---|
1301 | 1285 | if (bch->state == ISDN_P_NONE) |
---|
1302 | 1286 | return 0; |
---|
.. | .. |
---|
2010 | 1994 | pci_set_master(hc->pdev); |
---|
2011 | 1995 | if (!hc->irq) { |
---|
2012 | 1996 | printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n"); |
---|
2013 | | - return 1; |
---|
| 1997 | + return -EINVAL; |
---|
2014 | 1998 | } |
---|
2015 | 1999 | hc->hw.pci_io = |
---|
2016 | 2000 | (char __iomem *)(unsigned long)hc->pdev->resource[1].start; |
---|
2017 | 2001 | |
---|
2018 | 2002 | if (!hc->hw.pci_io) { |
---|
2019 | 2003 | printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n"); |
---|
2020 | | - return 1; |
---|
| 2004 | + return -ENOMEM; |
---|
2021 | 2005 | } |
---|
2022 | 2006 | /* Allocate memory for FIFOS */ |
---|
2023 | 2007 | /* 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); |
---|
2026 | 2015 | /* We silently assume the address is okay if nonzero */ |
---|
2027 | 2016 | if (!buffer) { |
---|
2028 | 2017 | printk(KERN_WARNING |
---|
2029 | 2018 | "HFC-PCI: Error allocating memory for FIFO!\n"); |
---|
2030 | | - return 1; |
---|
| 2019 | + return -ENOMEM; |
---|
2031 | 2020 | } |
---|
2032 | 2021 | hc->hw.fifos = buffer; |
---|
2033 | 2022 | pci_write_config_dword(hc->pdev, 0x80, hc->hw.dmahandle); |
---|
2034 | 2023 | 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 | + |
---|
2035 | 2032 | 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 | + |
---|
2039 | 2037 | /* enable memory mapped ports, disable busmaster */ |
---|
2040 | 2038 | pci_write_config_word(hc->pdev, PCI_COMMAND, PCI_ENA_MEMIO); |
---|
2041 | 2039 | hc->hw.int_m2 = 0; |
---|