Commit 98fc4839 authored by Jeff Garzik's avatar Jeff Garzik

[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: default avatarJeff Garzik <jeff@garzik.org>
parent d825a492
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* based on existing driver for CCD hfc ISA cards * based on existing driver for CCD hfc ISA cards
* Copyright by Werner Cornelius <werner@isdn4linux.de> * Copyright by Werner Cornelius <werner@isdn4linux.de>
* by Karsten Keil <keil@isdn4linux.de> * by Karsten Keil <keil@isdn4linux.de>
* *
* This software may be used and distributed according to the terms * This software may be used and distributed according to the terms
* of the GNU General Public License, incorporated herein by reference. * of the GNU General Public License, incorporated herein by reference.
* *
...@@ -67,8 +67,6 @@ static const PCI_ENTRY id_list[] = ...@@ -67,8 +67,6 @@ static const PCI_ENTRY id_list[] =
}; };
#ifdef CONFIG_PCI
/******************************************/ /******************************************/
/* free hardware resources used by driver */ /* free hardware resources used by driver */
/******************************************/ /******************************************/
...@@ -237,7 +235,7 @@ static void hfcpci_clear_fifo_rx(struct IsdnCardState *cs, int fifo) ...@@ -237,7 +235,7 @@ static void hfcpci_clear_fifo_rx(struct IsdnCardState *cs, int fifo)
if (fifo_state) if (fifo_state)
cs->hw.hfcpci.fifo_en |= fifo_state; cs->hw.hfcpci.fifo_en |= fifo_state;
Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en); Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en);
} }
/***************************************/ /***************************************/
/* clear the desired B-channel tx fifo */ /* clear the desired B-channel tx fifo */
...@@ -263,7 +261,7 @@ static void hfcpci_clear_fifo_tx(struct IsdnCardState *cs, int fifo) ...@@ -263,7 +261,7 @@ static void hfcpci_clear_fifo_tx(struct IsdnCardState *cs, int fifo)
if (fifo_state) if (fifo_state)
cs->hw.hfcpci.fifo_en |= fifo_state; cs->hw.hfcpci.fifo_en |= fifo_state;
Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en); Write_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en);
} }
/*********************************************/ /*********************************************/
/* read a complete B-frame out of the buffer */ /* read a complete B-frame out of the buffer */
...@@ -511,7 +509,6 @@ main_rec_hfcpci(struct BCState *bcs) ...@@ -511,7 +509,6 @@ main_rec_hfcpci(struct BCState *bcs)
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
if (count && receive) if (count && receive)
goto Begin; goto Begin;
return;
} }
/**************************/ /**************************/
...@@ -582,7 +579,6 @@ hfcpci_fill_dfifo(struct IsdnCardState *cs) ...@@ -582,7 +579,6 @@ hfcpci_fill_dfifo(struct IsdnCardState *cs)
dev_kfree_skb_any(cs->tx_skb); dev_kfree_skb_any(cs->tx_skb);
cs->tx_skb = NULL; cs->tx_skb = NULL;
return;
} }
/**************************/ /**************************/
...@@ -729,7 +725,6 @@ hfcpci_fill_fifo(struct BCState *bcs) ...@@ -729,7 +725,6 @@ hfcpci_fill_fifo(struct BCState *bcs)
dev_kfree_skb_any(bcs->tx_skb); dev_kfree_skb_any(bcs->tx_skb);
bcs->tx_skb = NULL; bcs->tx_skb = NULL;
test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag); test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);
return;
} }
/**********************************************/ /**********************************************/
...@@ -924,7 +919,6 @@ receive_emsg(struct IsdnCardState *cs) ...@@ -924,7 +919,6 @@ receive_emsg(struct IsdnCardState *cs)
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags); test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
if (count && receive) if (count && receive)
goto Begin; goto Begin;
return;
} /* receive_emsg */ } /* receive_emsg */
/*********************/ /*********************/
...@@ -1350,13 +1344,13 @@ mode_hfcpci(struct BCState *bcs, int mode, int bc) ...@@ -1350,13 +1344,13 @@ mode_hfcpci(struct BCState *bcs, int mode, int bc)
cs->hw.hfcpci.sctrl_r |= SCTRL_B1_ENA; cs->hw.hfcpci.sctrl_r |= SCTRL_B1_ENA;
} }
if (fifo2) { if (fifo2) {
cs->hw.hfcpci.last_bfifo_cnt[1] = 0; cs->hw.hfcpci.last_bfifo_cnt[1] = 0;
cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B2; cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B2;
cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC); cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B2TRANS + HFCPCI_INTS_B2REC);
cs->hw.hfcpci.ctmt &= ~2; cs->hw.hfcpci.ctmt &= ~2;
cs->hw.hfcpci.conn &= ~0x18; cs->hw.hfcpci.conn &= ~0x18;
} else { } else {
cs->hw.hfcpci.last_bfifo_cnt[0] = 0; cs->hw.hfcpci.last_bfifo_cnt[0] = 0;
cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B1; cs->hw.hfcpci.fifo_en |= HFCPCI_FIFOEN_B1;
cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC); cs->hw.hfcpci.int_m1 |= (HFCPCI_INTS_B1TRANS + HFCPCI_INTS_B1REC);
cs->hw.hfcpci.ctmt &= ~1; cs->hw.hfcpci.ctmt &= ~1;
...@@ -1642,8 +1636,6 @@ hfcpci_card_msg(struct IsdnCardState *cs, int mt, void *arg) ...@@ -1642,8 +1636,6 @@ hfcpci_card_msg(struct IsdnCardState *cs, int mt, void *arg)
/* this variable is used as card index when more than one cards are present */ /* this variable is used as card index when more than one cards are present */
static struct pci_dev *dev_hfcpci __devinitdata = NULL; static struct pci_dev *dev_hfcpci __devinitdata = NULL;
#endif /* CONFIG_PCI */
int __devinit int __devinit
setup_hfcpci(struct IsdnCard *card) setup_hfcpci(struct IsdnCard *card)
{ {
...@@ -1656,96 +1648,99 @@ setup_hfcpci(struct IsdnCard *card) ...@@ -1656,96 +1648,99 @@ setup_hfcpci(struct IsdnCard *card)
#ifdef __BIG_ENDIAN #ifdef __BIG_ENDIAN
#error "not running on big endian machines now" #error "not running on big endian machines now"
#endif #endif
strcpy(tmp, hfcpci_revision); strcpy(tmp, hfcpci_revision);
printk(KERN_INFO "HiSax: HFC-PCI driver Rev. %s\n", HiSax_getrev(tmp)); printk(KERN_INFO "HiSax: HFC-PCI driver Rev. %s\n", HiSax_getrev(tmp));
#ifdef CONFIG_PCI
cs->hw.hfcpci.int_s1 = 0; cs->hw.hfcpci.int_s1 = 0;
cs->dc.hfcpci.ph_state = 0; cs->dc.hfcpci.ph_state = 0;
cs->hw.hfcpci.fifo = 255; cs->hw.hfcpci.fifo = 255;
if (cs->typ == ISDN_CTYPE_HFC_PCI) { if (cs->typ != ISDN_CTYPE_HFC_PCI)
i = 0; return(0);
while (id_list[i].vendor_id) {
tmp_hfcpci = pci_find_device(id_list[i].vendor_id, i = 0;
id_list[i].device_id, while (id_list[i].vendor_id) {
dev_hfcpci); tmp_hfcpci = pci_find_device(id_list[i].vendor_id,
i++; id_list[i].device_id,
if (tmp_hfcpci) { dev_hfcpci);
if (pci_enable_device(tmp_hfcpci)) i++;
continue;
pci_set_master(tmp_hfcpci);
if ((card->para[0]) && (card->para[0] != (tmp_hfcpci->resource[ 0].start & PCI_BASE_ADDRESS_IO_MASK)))
continue;
else
break;
}
}
if (tmp_hfcpci) { if (tmp_hfcpci) {
i--; if (pci_enable_device(tmp_hfcpci))
dev_hfcpci = tmp_hfcpci; /* old device */ continue;
cs->hw.hfcpci.dev = dev_hfcpci; pci_set_master(tmp_hfcpci);
cs->irq = dev_hfcpci->irq; if ((card->para[0]) && (card->para[0] != (tmp_hfcpci->resource[ 0].start & PCI_BASE_ADDRESS_IO_MASK)))
if (!cs->irq) { continue;
printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n"); else
return (0); break;
}
cs->hw.hfcpci.pci_io = (char *)(unsigned long)dev_hfcpci->resource[1].start;
printk(KERN_INFO "HiSax: HFC-PCI card manufacturer: %s card name: %s\n", id_list[i].vendor_name, id_list[i].card_name);
} else {
printk(KERN_WARNING "HFC-PCI: No PCI card found\n");
return (0);
}
if (!cs->hw.hfcpci.pci_io) {
printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n");
return (0);
}
/* Allocate memory for FIFOS */
/* Because the HFC-PCI needs a 32K physical alignment, we */
/* need to allocate the double mem and align the address */
if (!(cs->hw.hfcpci.share_start = kmalloc(65536, GFP_KERNEL))) {
printk(KERN_WARNING "HFC-PCI: Error allocating memory for FIFO!\n");
return 0;
} }
cs->hw.hfcpci.fifos = (void *) }
(((ulong) cs->hw.hfcpci.share_start) & ~0x7FFF) + 0x8000;
pci_write_config_dword(cs->hw.hfcpci.dev, 0x80, (u_int) virt_to_bus(cs->hw.hfcpci.fifos)); if (!tmp_hfcpci) {
cs->hw.hfcpci.pci_io = ioremap((ulong) cs->hw.hfcpci.pci_io, 256); printk(KERN_WARNING "HFC-PCI: No PCI card found\n");
printk(KERN_INFO return (0);
"HFC-PCI: defined at mem %p fifo %p(%#x) IRQ %d HZ %d\n", }
cs->hw.hfcpci.pci_io,
cs->hw.hfcpci.fifos, i--;
(u_int) virt_to_bus(cs->hw.hfcpci.fifos), dev_hfcpci = tmp_hfcpci; /* old device */
cs->irq, HZ); cs->hw.hfcpci.dev = dev_hfcpci;
spin_lock_irqsave(&cs->lock, flags); cs->irq = dev_hfcpci->irq;
pci_write_config_word(cs->hw.hfcpci.dev, PCI_COMMAND, PCI_ENA_MEMIO); /* enable memory mapped ports, disable busmaster */ if (!cs->irq) {
cs->hw.hfcpci.int_m2 = 0; /* disable alle interrupts */ printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n");
cs->hw.hfcpci.int_m1 = 0; return (0);
Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1); }
Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2); cs->hw.hfcpci.pci_io = (char *)(unsigned long)dev_hfcpci->resource[1].start;
/* At this point the needed PCI config is done */ printk(KERN_INFO "HiSax: HFC-PCI card manufacturer: %s card name: %s\n", id_list[i].vendor_name, id_list[i].card_name);
/* fifos are still not enabled */
INIT_WORK(&cs->tqueue, hfcpci_bh); if (!cs->hw.hfcpci.pci_io) {
cs->setstack_d = setstack_hfcpci; printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n");
cs->BC_Send_Data = &hfcpci_send_data; return (0);
cs->readisac = NULL; }
cs->writeisac = NULL; /* Allocate memory for FIFOS */
cs->readisacfifo = NULL; /* Because the HFC-PCI needs a 32K physical alignment, we */
cs->writeisacfifo = NULL; /* need to allocate the double mem and align the address */
cs->BC_Read_Reg = NULL; if (!(cs->hw.hfcpci.share_start = kmalloc(65536, GFP_KERNEL))) {
cs->BC_Write_Reg = NULL; printk(KERN_WARNING "HFC-PCI: Error allocating memory for FIFO!\n");
cs->irq_func = &hfcpci_interrupt; return 0;
cs->irq_flags |= IRQF_SHARED; }
cs->hw.hfcpci.timer.function = (void *) hfcpci_Timer; cs->hw.hfcpci.fifos = (void *)
cs->hw.hfcpci.timer.data = (long) cs; (((ulong) cs->hw.hfcpci.share_start) & ~0x7FFF) + 0x8000;
init_timer(&cs->hw.hfcpci.timer); pci_write_config_dword(cs->hw.hfcpci.dev, 0x80, (u_int) virt_to_bus(cs->hw.hfcpci.fifos));
cs->cardmsg = &hfcpci_card_msg; cs->hw.hfcpci.pci_io = ioremap((ulong) cs->hw.hfcpci.pci_io, 256);
cs->auxcmd = &hfcpci_auxcmd; printk(KERN_INFO
spin_unlock_irqrestore(&cs->lock, flags); "HFC-PCI: defined at mem %p fifo %p(%#x) IRQ %d HZ %d\n",
return (1); cs->hw.hfcpci.pci_io,
} else cs->hw.hfcpci.fifos,
return (0); /* no valid card type */ (u_int) virt_to_bus(cs->hw.hfcpci.fifos),
#else cs->irq, HZ);
printk(KERN_WARNING "HFC-PCI: NO_PCI_BIOS\n");
return (0); spin_lock_irqsave(&cs->lock, flags);
#endif /* CONFIG_PCI */
pci_write_config_word(cs->hw.hfcpci.dev, PCI_COMMAND, PCI_ENA_MEMIO); /* enable memory mapped ports, disable busmaster */
cs->hw.hfcpci.int_m2 = 0; /* disable alle interrupts */
cs->hw.hfcpci.int_m1 = 0;
Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1);
Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2);
/* At this point the needed PCI config is done */
/* fifos are still not enabled */
INIT_WORK(&cs->tqueue, hfcpci_bh);
cs->setstack_d = setstack_hfcpci;
cs->BC_Send_Data = &hfcpci_send_data;
cs->readisac = NULL;
cs->writeisac = NULL;
cs->readisacfifo = NULL;
cs->writeisacfifo = NULL;
cs->BC_Read_Reg = NULL;
cs->BC_Write_Reg = NULL;
cs->irq_func = &hfcpci_interrupt;
cs->irq_flags |= IRQF_SHARED;
cs->hw.hfcpci.timer.function = (void *) hfcpci_Timer;
cs->hw.hfcpci.timer.data = (long) cs;
init_timer(&cs->hw.hfcpci.timer);
cs->cardmsg = &hfcpci_card_msg;
cs->auxcmd = &hfcpci_auxcmd;
spin_unlock_irqrestore(&cs->lock, flags);
return (1);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment