diff options
author | Jeff Garzik <jeff@garzik.org> | 2007-07-15 21:48:07 -0400 |
---|---|---|
committer | Jeff Garzik <jeff@garzik.org> | 2007-07-17 17:26:24 -0400 |
commit | 98fc4839aa00a02da83625e9fedad7a348c0af91 (patch) | |
tree | 6d73e31849d70fd930c93168bbc06c869ae407dd /drivers/isdn | |
parent | d825a49259a272d2451f0bfb0f789534377ac478 (diff) |
[ISDN] HiSax hfc_pci: minor cleanups
* trim trailing whitespace
* remove CONFIG_PCI ifdefs, this driver is always PCI (Kconfig enforced)
* remove return statements at the tail of a function
* remove indentation levels by returning an error code immediately.
Makes the code much more readable, and easier to update to PCI hotplug
API.
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/isdn')
-rw-r--r-- | drivers/isdn/hisax/hfc_pci.c | 191 |
1 files changed, 93 insertions, 98 deletions
diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c index 8a48a3ce0a55..077080aca799 100644 --- a/drivers/isdn/hisax/hfc_pci.c +++ b/drivers/isdn/hisax/hfc_pci.c | |||
@@ -6,7 +6,7 @@ | |||
6 | * based on existing driver for CCD hfc ISA cards | 6 | * based on existing driver for CCD hfc ISA cards |
7 | * Copyright by Werner Cornelius <werner@isdn4linux.de> | 7 | * Copyright by Werner Cornelius <werner@isdn4linux.de> |
8 | * by Karsten Keil <keil@isdn4linux.de> | 8 | * by Karsten Keil <keil@isdn4linux.de> |
9 | * | 9 | * |
10 | * This software may be used and distributed according to the terms | 10 | * This software may be used and distributed according to the terms |
11 | * of the GNU General Public License, incorporated herein by reference. | 11 | * of the GNU General Public License, incorporated herein by reference. |
12 | * | 12 | * |
@@ -67,8 +67,6 @@ static const PCI_ENTRY id_list[] = | |||
67 | }; | 67 | }; |
68 | 68 | ||
69 | 69 | ||
70 | #ifdef CONFIG_PCI | ||
71 | |||
72 | /******************************************/ | 70 | /******************************************/ |
73 | /* free hardware resources used by driver */ | 71 | /* free hardware resources used by driver */ |
74 | /******************************************/ | 72 | /******************************************/ |
@@ -237,7 +235,7 @@ static void hfcpci_clear_fifo_rx(struct IsdnCardState *cs, int fifo) | |||
237 | if (fifo_state) | 235 | if (fifo_state) |
238 | cs->hw.hfcpci.fifo_en |= fifo_state; | 236 | cs->hw.hfcpci.fifo_en |= fifo_state; |
239 | Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en); | 237 | Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en); |
240 | } | 238 | } |
241 | 239 | ||
242 | /***************************************/ | 240 | /***************************************/ |
243 | /* clear the desired B-channel tx fifo */ | 241 | /* clear the desired B-channel tx fifo */ |
@@ -263,7 +261,7 @@ static void hfcpci_clear_fifo_tx(struct IsdnCardState *cs, int fifo) | |||
263 | if (fifo_state) | 261 | if (fifo_state) |
264 | cs->hw.hfcpci.fifo_en |= fifo_state; | 262 | cs->hw.hfcpci.fifo_en |= fifo_state; |
265 | Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en); | 263 | Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en); |
266 | } | 264 | } |
267 | 265 | ||
268 | /*********************************************/ | 266 | /*********************************************/ |
269 | /* read a complete B-frame out of the buffer */ | 267 | /* read a complete B-frame out of the buffer */ |
@@ -511,7 +509,6 @@ main_rec_hfcpci(struct BCState *bcs) | |||
511 | test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); | 509 | test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); |
512 | if (count && receive) | 510 | if (count && receive) |
513 | goto Begin; | 511 | goto Begin; |
514 | return; | ||
515 | } | 512 | } |
516 | 513 | ||
517 | /**************************/ | 514 | /**************************/ |
@@ -582,7 +579,6 @@ hfcpci_fill_dfifo(struct IsdnCardState *cs) | |||
582 | 579 | ||
583 | dev_kfree_skb_any(cs->tx_skb); | 580 | dev_kfree_skb_any(cs->tx_skb); |
584 | cs->tx_skb = NULL; | 581 | cs->tx_skb = NULL; |
585 | return; | ||
586 | } | 582 | } |
587 | 583 | ||
588 | /**************************/ | 584 | /**************************/ |
@@ -729,7 +725,6 @@ hfcpci_fill_fifo(struct BCState *bcs) | |||
729 | dev_kfree_skb_any(bcs->tx_skb); | 725 | dev_kfree_skb_any(bcs->tx_skb); |
730 | bcs->tx_skb = NULL; | 726 | bcs->tx_skb = NULL; |
731 | test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); | 727 | test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); |
732 | return; | ||
733 | } | 728 | } |
734 | 729 | ||
735 | /**********************************************/ | 730 | /**********************************************/ |
@@ -924,7 +919,6 @@ receive_emsg(struct IsdnCardState *cs) | |||
924 | test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); | 919 | test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); |
925 | if (count && receive) | 920 | if (count && receive) |
926 | goto Begin; | 921 | goto Begin; |
927 | return; | ||
928 | } /* receive_emsg */ | 922 | } /* receive_emsg */ |
929 | 923 | ||
930 | /*********************/ | 924 | /*********************/ |
@@ -1350,13 +1344,13 @@ mode_hfcpci(struct BCState *bcs, int mode, int bc) | |||
1350 | cs->hw.hfcpci.sctrl_r |= SCTRL_B1_ENA; | 1344 | cs->hw.hfcpci.sctrl_r |= SCTRL_B1_ENA; |
1351 | } | 1345 | } |
1352 | if (fifo2) { | 1346 | if (fifo2) { |
1353 | cs->hw.hfcpci.last_bfifo_cnt[1] = 0; | 1347 | cs->hw.hfcpci.last_bfifo_cnt[1] = 0; |
1354 | cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B2; | 1348 | cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B2; |
1355 | cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC); | 1349 | cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC); |
1356 | cs->hw.hfcpci.ctmt &= ~2; | 1350 | cs->hw.hfcpci.ctmt &= ~2; |
1357 | cs->hw.hfcpci.conn &= ~0x18; | 1351 | cs->hw.hfcpci.conn &= ~0x18; |
1358 | } else { | 1352 | } else { |
1359 | cs->hw.hfcpci.last_bfifo_cnt[0] = 0; | 1353 | cs->hw.hfcpci.last_bfifo_cnt[0] = 0; |
1360 | cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B1; | 1354 | cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B1; |
1361 | cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC); | 1355 | cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC); |
1362 | cs->hw.hfcpci.ctmt &= ~1; | 1356 | cs->hw.hfcpci.ctmt &= ~1; |
@@ -1642,8 +1636,6 @@ hfcpci_card_msg(struct IsdnCardState *cs, int mt, void *arg) | |||
1642 | /* this variable is used as card index when more than one cards are present */ | 1636 | /* this variable is used as card index when more than one cards are present */ |
1643 | static struct pci_dev *dev_hfcpci __devinitdata = NULL; | 1637 | static struct pci_dev *dev_hfcpci __devinitdata = NULL; |
1644 | 1638 | ||
1645 | #endif /* CONFIG_PCI */ | ||
1646 | |||
1647 | int __devinit | 1639 | int __devinit |
1648 | setup_hfcpci(struct IsdnCard *card) | 1640 | setup_hfcpci(struct IsdnCard *card) |
1649 | { | 1641 | { |
@@ -1656,96 +1648,99 @@ setup_hfcpci(struct IsdnCard *card) | |||
1656 | #ifdef __BIG_ENDIAN | 1648 | #ifdef __BIG_ENDIAN |
1657 | #error "not running on big endian machines now" | 1649 | #error "not running on big endian machines now" |
1658 | #endif | 1650 | #endif |
1651 | |||
1659 | strcpy(tmp, hfcpci_revision); | 1652 | strcpy(tmp, hfcpci_revision); |
1660 | printk(KERN_INFO "HiSax: HFC-PCI driver Rev. %s\n", HiSax_getrev(tmp)); | 1653 | printk(KERN_INFO "HiSax: HFC-PCI driver Rev. %s\n", HiSax_getrev(tmp)); |
1661 | #ifdef CONFIG_PCI | 1654 | |
1662 | cs->hw.hfcpci.int_s1 = 0; | 1655 | cs->hw.hfcpci.int_s1 = 0; |
1663 | cs->dc.hfcpci.ph_state = 0; | 1656 | cs->dc.hfcpci.ph_state = 0; |
1664 | cs->hw.hfcpci.fifo = 255; | 1657 | cs->hw.hfcpci.fifo = 255; |
1665 | if (cs->typ == ISDN_CTYPE_HFC_PCI) { | 1658 | if (cs->typ != ISDN_CTYPE_HFC_PCI) |
1666 | i = 0; | 1659 | return(0); |
1667 | while (id_list[i].vendor_id) { | 1660 | |
1668 | tmp_hfcpci = pci_find_device(id_list[i].vendor_id, | 1661 | i = 0; |
1669 | id_list[i].device_id, | 1662 | while (id_list[i].vendor_id) { |
1670 | dev_hfcpci); | 1663 | tmp_hfcpci = pci_find_device(id_list[i].vendor_id, |
1671 | i++; | 1664 | id_list[i].device_id, |
1672 | if (tmp_hfcpci) { | 1665 | dev_hfcpci); |
1673 | if (pci_enable_device(tmp_hfcpci)) | 1666 | i++; |
1674 | continue; | ||
1675 | pci_set_master(tmp_hfcpci); | ||
1676 | if ((card->para[0]) && (card->para[0] != (tmp_hfcpci->resource[ 0].start & PCI_BASE_ADDRESS_IO_MASK))) | ||
1677 | continue; | ||
1678 | else | ||
1679 | break; | ||
1680 | } | ||
1681 | } | ||
1682 | |||
1683 | if (tmp_hfcpci) { | 1667 | if (tmp_hfcpci) { |
1684 | i--; | 1668 | if (pci_enable_device(tmp_hfcpci)) |
1685 | dev_hfcpci = tmp_hfcpci; /* old device */ | 1669 | continue; |
1686 | cs->hw.hfcpci.dev = dev_hfcpci; | 1670 | pci_set_master(tmp_hfcpci); |
1687 | cs->irq = dev_hfcpci->irq; | 1671 | if ((card->para[0]) && (card->para[0] != (tmp_hfcpci->resource[ 0].start & PCI_BASE_ADDRESS_IO_MASK))) |
1688 | if (!cs->irq) { | 1672 | continue; |
1689 | printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n"); | 1673 | else |
1690 | return (0); | 1674 | break; |
1691 | } | ||
1692 | cs->hw.hfcpci.pci_io = (char *)(unsigned long)dev_hfcpci->resource[1].start; | ||
1693 | printk(KERN_INFO "HiSax: HFC-PCI card manufacturer: %s card name: %s\n", id_list[i].vendor_name, id_list[i].card_name); | ||
1694 | } else { | ||
1695 | printk(KERN_WARNING "HFC-PCI: No PCI card found\n"); | ||
1696 | return (0); | ||
1697 | } | ||
1698 | if (!cs->hw.hfcpci.pci_io) { | ||
1699 | printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n"); | ||
1700 | return (0); | ||
1701 | } | ||
1702 | /* Allocate memory for FIFOS */ | ||
1703 | /* Because the HFC-PCI needs a 32K physical alignment, we */ | ||
1704 | /* need to allocate the double mem and align the address */ | ||
1705 | if (!(cs->hw.hfcpci.share_start = kmalloc(65536, GFP_KERNEL))) { | ||
1706 | printk(KERN_WARNING "HFC-PCI: Error allocating memory for FIFO!\n"); | ||
1707 | return 0; | ||
1708 | } | 1675 | } |
1709 | cs->hw.hfcpci.fifos = (void *) | 1676 | } |
1710 | (((ulong) cs->hw.hfcpci.share_start) & ~0x7FFF) + 0x8000; | 1677 | |
1711 | pci_write_config_dword(cs->hw.hfcpci.dev, 0x80, (u_int) virt_to_bus(cs->hw.hfcpci.fifos)); | 1678 | if (!tmp_hfcpci) { |
1712 | cs->hw.hfcpci.pci_io = ioremap((ulong) cs->hw.hfcpci.pci_io, 256); | 1679 | printk(KERN_WARNING "HFC-PCI: No PCI card found\n"); |
1713 | printk(KERN_INFO | 1680 | return (0); |
1714 | "HFC-PCI: defined at mem %p fifo %p(%#x) IRQ %d HZ %d\n", | 1681 | } |
1715 | cs->hw.hfcpci.pci_io, | 1682 | |
1716 | cs->hw.hfcpci.fifos, | 1683 | i--; |
1717 | (u_int) virt_to_bus(cs->hw.hfcpci.fifos), | 1684 | dev_hfcpci = tmp_hfcpci; /* old device */ |
1718 | cs->irq, HZ); | 1685 | cs->hw.hfcpci.dev = dev_hfcpci; |
1719 | spin_lock_irqsave(&cs->lock, flags); | 1686 | cs->irq = dev_hfcpci->irq; |
1720 | pci_write_config_word(cs->hw.hfcpci.dev, PCI_COMMAND, PCI_ENA_MEMIO); /* enable memory mapped ports, disable busmaster */ | 1687 | if (!cs->irq) { |
1721 | cs->hw.hfcpci.int_m2 = 0; /* disable alle interrupts */ | 1688 | printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n"); |
1722 | cs->hw.hfcpci.int_m1 = 0; | 1689 | return (0); |
1723 | Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); | 1690 | } |
1724 | Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2); | 1691 | cs->hw.hfcpci.pci_io = (char *)(unsigned long)dev_hfcpci->resource[1].start; |
1725 | /* At this point the needed PCI config is done */ | 1692 | printk(KERN_INFO "HiSax: HFC-PCI card manufacturer: %s card name: %s\n", id_list[i].vendor_name, id_list[i].card_name); |
1726 | /* fifos are still not enabled */ | 1693 | |
1727 | INIT_WORK(&cs->tqueue, hfcpci_bh); | 1694 | if (!cs->hw.hfcpci.pci_io) { |
1728 | cs->setstack_d = setstack_hfcpci; | 1695 | printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n"); |
1729 | cs->BC_Send_Data = &hfcpci_send_data; | 1696 | return (0); |
1730 | cs->readisac = NULL; | 1697 | } |
1731 | cs->writeisac = NULL; | 1698 | /* Allocate memory for FIFOS */ |
1732 | cs->readisacfifo = NULL; | 1699 | /* Because the HFC-PCI needs a 32K physical alignment, we */ |
1733 | cs->writeisacfifo = NULL; | 1700 | /* need to allocate the double mem and align the address */ |
1734 | cs->BC_Read_Reg = NULL; | 1701 | if (!(cs->hw.hfcpci.share_start = kmalloc(65536, GFP_KERNEL))) { |
1735 | cs->BC_Write_Reg = NULL; | 1702 | printk(KERN_WARNING "HFC-PCI: Error allocating memory for FIFO!\n"); |
1736 | cs->irq_func = &hfcpci_interrupt; | 1703 | return 0; |
1737 | cs->irq_flags |= IRQF_SHARED; | 1704 | } |
1738 | cs->hw.hfcpci.timer.function = (void *) hfcpci_Timer; | 1705 | cs->hw.hfcpci.fifos = (void *) |
1739 | cs->hw.hfcpci.timer.data = (long) cs; | 1706 | (((ulong) cs->hw.hfcpci.share_start) & ~0x7FFF) + 0x8000; |
1740 | init_timer(&cs->hw.hfcpci.timer); | 1707 | pci_write_config_dword(cs->hw.hfcpci.dev, 0x80, (u_int) virt_to_bus(cs->hw.hfcpci.fifos)); |
1741 | cs->cardmsg = &hfcpci_card_msg; | 1708 | cs->hw.hfcpci.pci_io = ioremap((ulong) cs->hw.hfcpci.pci_io, 256); |
1742 | cs->auxcmd = &hfcpci_auxcmd; | 1709 | printk(KERN_INFO |
1743 | spin_unlock_irqrestore(&cs->lock, flags); | 1710 | "HFC-PCI: defined at mem %p fifo %p(%#x) IRQ %d HZ %d\n", |
1744 | return (1); | 1711 | cs->hw.hfcpci.pci_io, |
1745 | } else | 1712 | cs->hw.hfcpci.fifos, |
1746 | return (0); /* no valid card type */ | 1713 | (u_int) virt_to_bus(cs->hw.hfcpci.fifos), |
1747 | #else | 1714 | cs->irq, HZ); |
1748 | printk(KERN_WARNING "HFC-PCI: NO_PCI_BIOS\n"); | 1715 | |
1749 | return (0); | 1716 | spin_lock_irqsave(&cs->lock, flags); |
1750 | #endif /* CONFIG_PCI */ | 1717 | |
1718 | pci_write_config_word(cs->hw.hfcpci.dev, PCI_COMMAND, PCI_ENA_MEMIO); /* enable memory mapped ports, disable busmaster */ | ||
1719 | cs->hw.hfcpci.int_m2 = 0; /* disable alle interrupts */ | ||
1720 | cs->hw.hfcpci.int_m1 = 0; | ||
1721 | Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); | ||
1722 | Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2); | ||
1723 | /* At this point the needed PCI config is done */ | ||
1724 | /* fifos are still not enabled */ | ||
1725 | |||
1726 | INIT_WORK(&cs->tqueue, hfcpci_bh); | ||
1727 | cs->setstack_d = setstack_hfcpci; | ||
1728 | cs->BC_Send_Data = &hfcpci_send_data; | ||
1729 | cs->readisac = NULL; | ||
1730 | cs->writeisac = NULL; | ||
1731 | cs->readisacfifo = NULL; | ||
1732 | cs->writeisacfifo = NULL; | ||
1733 | cs->BC_Read_Reg = NULL; | ||
1734 | cs->BC_Write_Reg = NULL; | ||
1735 | cs->irq_func = &hfcpci_interrupt; | ||
1736 | cs->irq_flags |= IRQF_SHARED; | ||
1737 | cs->hw.hfcpci.timer.function = (void *) hfcpci_Timer; | ||
1738 | cs->hw.hfcpci.timer.data = (long) cs; | ||
1739 | init_timer(&cs->hw.hfcpci.timer); | ||
1740 | cs->cardmsg = &hfcpci_card_msg; | ||
1741 | cs->auxcmd = &hfcpci_auxcmd; | ||
1742 | |||
1743 | spin_unlock_irqrestore(&cs->lock, flags); | ||
1744 | |||
1745 | return (1); | ||
1751 | } | 1746 | } |