Commit 0566a663 authored by Jeff Garzik's avatar Jeff Garzik

[ISDN] HiSax netjet_s: code movement, prep for hotplug

1) Remove CONFIG_PCI ifdefs.  PCI is required in Kconfig.

2) Break up setup_netjet_s() into three separate internal functions.
This helps facilitate upcoming use of PCI hotplug API, and in addition
makes the code much easier to follow.

No code is changed, just moved around.  I even kept the out-of-favor
"return(0)" style used in the current source code.
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 881ebdc9
......@@ -148,30 +148,11 @@ NETjet_S_card_msg(struct IsdnCardState *cs, int mt, void *arg)
return(0);
}
static struct pci_dev *dev_netjet __devinitdata = NULL;
int __devinit
setup_netjet_s(struct IsdnCard *card)
static int __devinit njs_pci_probe(struct pci_dev *dev_netjet,
struct IsdnCardState *cs)
{
int bytecnt,cfg;
struct IsdnCardState *cs = card->cs;
char tmp[64];
#ifdef __BIG_ENDIAN
#error "not running on big endian machines now"
#endif
strcpy(tmp, NETjet_S_revision);
printk(KERN_INFO "HiSax: Traverse Tech. NETjet-S driver Rev. %s\n", HiSax_getrev(tmp));
if (cs->typ != ISDN_CTYPE_NETJET_S)
return(0);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
#ifdef CONFIG_PCI
int cfg;
for ( ;; )
{
if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) {
if (pci_enable_device(dev_netjet))
return(0);
pci_set_master(dev_netjet);
......@@ -202,10 +183,13 @@ setup_netjet_s(struct IsdnCard *card)
return(0);
}
/* end new code */
} else {
printk(KERN_WARNING "NETjet-S: No PCI card found\n");
return(0);
}
return(1);
}
static int __devinit njs_cs_init(struct IsdnCard *card,
struct IsdnCardState *cs)
{
cs->hw.njet.auxa = cs->hw.njet.base + NETJET_AUXDATA;
cs->hw.njet.isac = cs->hw.njet.base | NETJET_ISAC_OFF;
......@@ -228,27 +212,23 @@ setup_netjet_s(struct IsdnCard *card)
switch ( ( ( NETjet_ReadIC( cs, ISAC_RBCH ) >> 5 ) & 3 ) )
{
case 0 :
break;
return 1; /* end loop */
case 3 :
printk( KERN_WARNING "NETjet-S: NETspider-U PCI card found\n" );
continue;
return -1; /* continue looping */
default :
printk( KERN_WARNING "NETjet-S: No PCI card found\n" );
return 0;
}
break;
return 0; /* end loop & function */
}
#else
printk(KERN_WARNING "NETjet-S: NO_PCI_BIOS\n");
printk(KERN_WARNING "NETjet-S: unable to config NETJET-S PCI\n");
return (0);
#endif /* CONFIG_PCI */
return 1; /* end loop */
}
bytecnt = 256;
static int __devinit njs_cs_init_rest(struct IsdnCard *card,
struct IsdnCardState *cs)
{
const int bytecnt = 256;
printk(KERN_INFO
"NETjet-S: %s card configured at %#lx IRQ %d\n",
......@@ -273,5 +253,47 @@ setup_netjet_s(struct IsdnCard *card)
cs->irq_func = &netjet_s_interrupt;
cs->irq_flags |= IRQF_SHARED;
ISACVersion(cs, "NETjet-S:");
return (1);
}
static struct pci_dev *dev_netjet __devinitdata = NULL;
int __devinit
setup_netjet_s(struct IsdnCard *card)
{
int ret;
struct IsdnCardState *cs = card->cs;
char tmp[64];
#ifdef __BIG_ENDIAN
#error "not running on big endian machines now"
#endif
strcpy(tmp, NETjet_S_revision);
printk(KERN_INFO "HiSax: Traverse Tech. NETjet-S driver Rev. %s\n", HiSax_getrev(tmp));
if (cs->typ != ISDN_CTYPE_NETJET_S)
return(0);
test_and_clear_bit(FLG_LOCK_ATOMIC, &cs->HW_Flags);
for ( ;; )
{
if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET,
PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) {
ret = njs_pci_probe(dev_netjet, cs);
if (!ret)
return(0);
} else {
printk(KERN_WARNING "NETjet-S: No PCI card found\n");
return(0);
}
ret = njs_cs_init(card, cs);
if (!ret)
return(0);
if (ret > 0)
break;
/* otherwise, ret < 0, continue looping */
}
return njs_cs_init_rest(card, cs);
}
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