[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>
This commit is contained in:
parent
d825a49259
commit
98fc4839aa
1 changed files with 92 additions and 97 deletions
|
@ -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[] =
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#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)
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
|
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
/* 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)
|
||||||
#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,
|
|
||||||
id_list[i].device_id,
|
|
||||||
dev_hfcpci);
|
|
||||||
i++;
|
|
||||||
if (tmp_hfcpci) {
|
|
||||||
if (pci_enable_device(tmp_hfcpci))
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (id_list[i].vendor_id) {
|
||||||
|
tmp_hfcpci = pci_find_device(id_list[i].vendor_id,
|
||||||
|
id_list[i].device_id,
|
||||||
|
dev_hfcpci);
|
||||||
|
i++;
|
||||||
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);
|
if (!tmp_hfcpci) {
|
||||||
}
|
printk(KERN_WARNING "HFC-PCI: No PCI card found\n");
|
||||||
/* Allocate memory for FIFOS */
|
return (0);
|
||||||
/* 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))) {
|
i--;
|
||||||
printk(KERN_WARNING "HFC-PCI: Error allocating memory for FIFO!\n");
|
dev_hfcpci = tmp_hfcpci; /* old device */
|
||||||
return 0;
|
cs->hw.hfcpci.dev = dev_hfcpci;
|
||||||
}
|
cs->irq = dev_hfcpci->irq;
|
||||||
cs->hw.hfcpci.fifos = (void *)
|
if (!cs->irq) {
|
||||||
(((ulong) cs->hw.hfcpci.share_start) & ~0x7FFF) + 0x8000;
|
printk(KERN_WARNING "HFC-PCI: No IRQ for PCI card found\n");
|
||||||
pci_write_config_dword(cs->hw.hfcpci.dev, 0x80, (u_int) virt_to_bus(cs->hw.hfcpci.fifos));
|
return (0);
|
||||||
cs->hw.hfcpci.pci_io = ioremap((ulong) cs->hw.hfcpci.pci_io, 256);
|
}
|
||||||
printk(KERN_INFO
|
cs->hw.hfcpci.pci_io = (char *)(unsigned long)dev_hfcpci->resource[1].start;
|
||||||
"HFC-PCI: defined at mem %p fifo %p(%#x) IRQ %d HZ %d\n",
|
printk(KERN_INFO "HiSax: HFC-PCI card manufacturer: %s card name: %s\n", id_list[i].vendor_name, id_list[i].card_name);
|
||||||
cs->hw.hfcpci.pci_io,
|
|
||||||
cs->hw.hfcpci.fifos,
|
if (!cs->hw.hfcpci.pci_io) {
|
||||||
(u_int) virt_to_bus(cs->hw.hfcpci.fifos),
|
printk(KERN_WARNING "HFC-PCI: No IO-Mem for PCI card found\n");
|
||||||
cs->irq, HZ);
|
return (0);
|
||||||
spin_lock_irqsave(&cs->lock, flags);
|
}
|
||||||
pci_write_config_word(cs->hw.hfcpci.dev, PCI_COMMAND, PCI_ENA_MEMIO); /* enable memory mapped ports, disable busmaster */
|
/* Allocate memory for FIFOS */
|
||||||
cs->hw.hfcpci.int_m2 = 0; /* disable alle interrupts */
|
/* Because the HFC-PCI needs a 32K physical alignment, we */
|
||||||
cs->hw.hfcpci.int_m1 = 0;
|
/* need to allocate the double mem and align the address */
|
||||||
Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1);
|
if (!(cs->hw.hfcpci.share_start = kmalloc(65536, GFP_KERNEL))) {
|
||||||
Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2);
|
printk(KERN_WARNING "HFC-PCI: Error allocating memory for FIFO!\n");
|
||||||
/* At this point the needed PCI config is done */
|
return 0;
|
||||||
/* fifos are still not enabled */
|
}
|
||||||
INIT_WORK(&cs->tqueue, hfcpci_bh);
|
cs->hw.hfcpci.fifos = (void *)
|
||||||
cs->setstack_d = setstack_hfcpci;
|
(((ulong) cs->hw.hfcpci.share_start) & ~0x7FFF) + 0x8000;
|
||||||
cs->BC_Send_Data = &hfcpci_send_data;
|
pci_write_config_dword(cs->hw.hfcpci.dev, 0x80, (u_int) virt_to_bus(cs->hw.hfcpci.fifos));
|
||||||
cs->readisac = NULL;
|
cs->hw.hfcpci.pci_io = ioremap((ulong) cs->hw.hfcpci.pci_io, 256);
|
||||||
cs->writeisac = NULL;
|
printk(KERN_INFO
|
||||||
cs->readisacfifo = NULL;
|
"HFC-PCI: defined at mem %p fifo %p(%#x) IRQ %d HZ %d\n",
|
||||||
cs->writeisacfifo = NULL;
|
cs->hw.hfcpci.pci_io,
|
||||||
cs->BC_Read_Reg = NULL;
|
cs->hw.hfcpci.fifos,
|
||||||
cs->BC_Write_Reg = NULL;
|
(u_int) virt_to_bus(cs->hw.hfcpci.fifos),
|
||||||
cs->irq_func = &hfcpci_interrupt;
|
cs->irq, HZ);
|
||||||
cs->irq_flags |= IRQF_SHARED;
|
|
||||||
cs->hw.hfcpci.timer.function = (void *) hfcpci_Timer;
|
spin_lock_irqsave(&cs->lock, flags);
|
||||||
cs->hw.hfcpci.timer.data = (long) cs;
|
|
||||||
init_timer(&cs->hw.hfcpci.timer);
|
pci_write_config_word(cs->hw.hfcpci.dev, PCI_COMMAND, PCI_ENA_MEMIO); /* enable memory mapped ports, disable busmaster */
|
||||||
cs->cardmsg = &hfcpci_card_msg;
|
cs->hw.hfcpci.int_m2 = 0; /* disable alle interrupts */
|
||||||
cs->auxcmd = &hfcpci_auxcmd;
|
cs->hw.hfcpci.int_m1 = 0;
|
||||||
spin_unlock_irqrestore(&cs->lock, flags);
|
Write_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1);
|
||||||
return (1);
|
Write_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2);
|
||||||
} else
|
/* At this point the needed PCI config is done */
|
||||||
return (0); /* no valid card type */
|
/* fifos are still not enabled */
|
||||||
#else
|
|
||||||
printk(KERN_WARNING "HFC-PCI: NO_PCI_BIOS\n");
|
INIT_WORK(&cs->tqueue, hfcpci_bh);
|
||||||
return (0);
|
cs->setstack_d = setstack_hfcpci;
|
||||||
#endif /* CONFIG_PCI */
|
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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue