mirror of
https://github.com/torvalds/linux.git
synced 2024-09-29 03:13:05 +00:00
[ISDN] HiSax elsa: split huge setup function into four smaller functions
Prep for hotplug API conversion. Just code movement (+glue). Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
This commit is contained in:
parent
2fbde4c092
commit
1e5d82e18b
|
@ -30,8 +30,6 @@
|
|||
#include <linux/serial.h>
|
||||
#include <linux/serial_reg.h>
|
||||
|
||||
extern const char *CardType[];
|
||||
|
||||
static const char *Elsa_revision = "$Revision: 2.32.2.4 $";
|
||||
static const char *Elsa_Types[] =
|
||||
{"None", "PC", "PCC-8", "PCC-16", "PCF", "PCF-Pro",
|
||||
|
@ -832,39 +830,12 @@ probe_elsa(struct IsdnCardState *cs)
|
|||
return (CARD_portlist[i]);
|
||||
}
|
||||
|
||||
static struct pci_dev *dev_qs1000 __devinitdata = NULL;
|
||||
static struct pci_dev *dev_qs3000 __devinitdata = NULL;
|
||||
|
||||
#ifdef __ISAPNP__
|
||||
static struct isapnp_device_id elsa_ids[] __devinitdata = {
|
||||
{ ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0133),
|
||||
ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0133),
|
||||
(unsigned long) "Elsa QS1000" },
|
||||
{ ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0134),
|
||||
ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0134),
|
||||
(unsigned long) "Elsa QS3000" },
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static struct isapnp_device_id *ipid __devinitdata = &elsa_ids[0];
|
||||
static struct pnp_card *pnp_c __devinitdata = NULL;
|
||||
#endif
|
||||
|
||||
int __devinit
|
||||
setup_elsa(struct IsdnCard *card)
|
||||
static int __devinit
|
||||
setup_elsa_isa(struct IsdnCard *card)
|
||||
{
|
||||
int bytecnt;
|
||||
u_char val;
|
||||
struct IsdnCardState *cs = card->cs;
|
||||
char tmp[64];
|
||||
u_char val;
|
||||
|
||||
strcpy(tmp, Elsa_revision);
|
||||
printk(KERN_INFO "HiSax: Elsa driver Rev. %s\n", HiSax_getrev(tmp));
|
||||
cs->hw.elsa.ctrl_reg = 0;
|
||||
cs->hw.elsa.status = 0;
|
||||
cs->hw.elsa.MFlag = 0;
|
||||
cs->subtyp = 0;
|
||||
if (cs->typ == ISDN_CTYPE_ELSA) {
|
||||
cs->hw.elsa.base = card->para[0];
|
||||
printk(KERN_INFO "Elsa: Microlink IO probing\n");
|
||||
if (cs->hw.elsa.base) {
|
||||
|
@ -877,7 +848,13 @@ setup_elsa(struct IsdnCard *card)
|
|||
}
|
||||
} else
|
||||
cs->hw.elsa.base = probe_elsa(cs);
|
||||
if (cs->hw.elsa.base) {
|
||||
|
||||
if (!cs->hw.elsa.base) {
|
||||
printk(KERN_WARNING
|
||||
"No Elsa Microlink found\n");
|
||||
return (0);
|
||||
}
|
||||
|
||||
cs->hw.elsa.cfg = cs->hw.elsa.base + ELSA_CONFIG;
|
||||
cs->hw.elsa.ctrl = cs->hw.elsa.base + ELSA_CONTROL;
|
||||
cs->hw.elsa.ale = cs->hw.elsa.base + ELSA_ALE;
|
||||
|
@ -919,12 +896,30 @@ setup_elsa(struct IsdnCard *card)
|
|||
"Elsa: Microlink S0 bus power bad\n");
|
||||
cs->hw.elsa.status |= ELSA_BAD_PWR;
|
||||
}
|
||||
} else {
|
||||
printk(KERN_WARNING
|
||||
"No Elsa Microlink found\n");
|
||||
return (0);
|
||||
|
||||
return (1);
|
||||
}
|
||||
} else if (cs->typ == ISDN_CTYPE_ELSA_PNP) {
|
||||
|
||||
#ifdef __ISAPNP__
|
||||
static struct isapnp_device_id elsa_ids[] __devinitdata = {
|
||||
{ ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0133),
|
||||
ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0133),
|
||||
(unsigned long) "Elsa QS1000" },
|
||||
{ ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0134),
|
||||
ISAPNP_VENDOR('E', 'L', 'S'), ISAPNP_FUNCTION(0x0134),
|
||||
(unsigned long) "Elsa QS3000" },
|
||||
{ 0, }
|
||||
};
|
||||
|
||||
static struct isapnp_device_id *ipid __devinitdata = &elsa_ids[0];
|
||||
static struct pnp_card *pnp_c __devinitdata = NULL;
|
||||
#endif /* __ISAPNP__ */
|
||||
|
||||
static int __devinit
|
||||
setup_elsa_isapnp(struct IsdnCard *card)
|
||||
{
|
||||
struct IsdnCardState *cs = card->cs;
|
||||
|
||||
#ifdef __ISAPNP__
|
||||
if (!card->para[1] && isapnp_present()) {
|
||||
struct pnp_dev *pnp_d;
|
||||
|
@ -972,7 +967,8 @@ setup_elsa(struct IsdnCard *card)
|
|||
return(0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* __ISAPNP__ */
|
||||
|
||||
if (card->para[1] && card->para[0]) {
|
||||
cs->hw.elsa.base = card->para[1];
|
||||
cs->irq = card->para[0];
|
||||
|
@ -993,7 +989,16 @@ setup_elsa(struct IsdnCard *card)
|
|||
Elsa_Types[cs->subtyp],
|
||||
cs->hw.elsa.base,
|
||||
cs->irq);
|
||||
} else if (cs->typ == ISDN_CTYPE_ELSA_PCMCIA) {
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
static void __devinit
|
||||
setup_elsa_pcmcia(struct IsdnCard *card)
|
||||
{
|
||||
struct IsdnCardState *cs = card->cs;
|
||||
u_char val;
|
||||
|
||||
cs->hw.elsa.base = card->para[1];
|
||||
cs->irq = card->para[0];
|
||||
val = readreg(cs->hw.elsa.base + 0, cs->hw.elsa.base + 2, IPAC_ID);
|
||||
|
@ -1018,8 +1023,17 @@ setup_elsa(struct IsdnCard *card)
|
|||
Elsa_Types[cs->subtyp],
|
||||
cs->hw.elsa.base,
|
||||
cs->irq);
|
||||
} else if (cs->typ == ISDN_CTYPE_ELSA_PCI) {
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PCI
|
||||
static struct pci_dev *dev_qs1000 __devinitdata = NULL;
|
||||
static struct pci_dev *dev_qs3000 __devinitdata = NULL;
|
||||
|
||||
static int __devinit
|
||||
setup_elsa_pci(struct IsdnCard *card)
|
||||
{
|
||||
struct IsdnCardState *cs = card->cs;
|
||||
|
||||
cs->subtyp = 0;
|
||||
if ((dev_qs1000 = pci_find_device(PCI_VENDOR_ID_ELSA,
|
||||
PCI_DEVICE_ID_ELSA_MICROLINK, dev_qs1000))) {
|
||||
|
@ -1068,13 +1082,25 @@ setup_elsa(struct IsdnCard *card)
|
|||
cs->hw.elsa.base,
|
||||
cs->hw.elsa.cfg,
|
||||
cs->irq);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
#else
|
||||
printk(KERN_WARNING "Elsa: Elsa PCI and NO_PCI_BIOS\n");
|
||||
printk(KERN_WARNING "Elsa: unable to config Elsa PCI\n");
|
||||
return (0);
|
||||
|
||||
static void __devinit
|
||||
setup_elsa_pci(struct IsdnCard *card)
|
||||
{
|
||||
return (1);
|
||||
}
|
||||
#endif /* CONFIG_PCI */
|
||||
} else
|
||||
return (0);
|
||||
|
||||
static int __devinit
|
||||
setup_elsa_common(struct IsdnCard *card)
|
||||
{
|
||||
struct IsdnCardState *cs = card->cs;
|
||||
u_char val;
|
||||
int bytecnt;
|
||||
|
||||
switch (cs->subtyp) {
|
||||
case ELSA_PC:
|
||||
|
@ -1104,8 +1130,7 @@ setup_elsa(struct IsdnCard *card)
|
|||
here, it would fail. */
|
||||
if (cs->typ != ISDN_CTYPE_ELSA_PCMCIA && !request_region(cs->hw.elsa.base, bytecnt, "elsa isdn")) {
|
||||
printk(KERN_WARNING
|
||||
"HiSax: %s config port %#lx-%#lx already in use\n",
|
||||
CardType[card->typ],
|
||||
"HiSax: ELSA config port %#lx-%#lx already in use\n",
|
||||
cs->hw.elsa.base,
|
||||
cs->hw.elsa.base + bytecnt);
|
||||
return (0);
|
||||
|
@ -1113,8 +1138,7 @@ setup_elsa(struct IsdnCard *card)
|
|||
if ((cs->subtyp == ELSA_QS1000PCI) || (cs->subtyp == ELSA_QS3000PCI)) {
|
||||
if (!request_region(cs->hw.elsa.cfg, 0x80, "elsa isdn pci")) {
|
||||
printk(KERN_WARNING
|
||||
"HiSax: %s pci port %x-%x already in use\n",
|
||||
CardType[card->typ],
|
||||
"HiSax: ELSA pci port %x-%x already in use\n",
|
||||
cs->hw.elsa.cfg,
|
||||
cs->hw.elsa.cfg + 0x80);
|
||||
release_region(cs->hw.elsa.base, bytecnt);
|
||||
|
@ -1186,3 +1210,41 @@ setup_elsa(struct IsdnCard *card)
|
|||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
int __devinit
|
||||
setup_elsa(struct IsdnCard *card)
|
||||
{
|
||||
int rc;
|
||||
struct IsdnCardState *cs = card->cs;
|
||||
char tmp[64];
|
||||
|
||||
strcpy(tmp, Elsa_revision);
|
||||
printk(KERN_INFO "HiSax: Elsa driver Rev. %s\n", HiSax_getrev(tmp));
|
||||
cs->hw.elsa.ctrl_reg = 0;
|
||||
cs->hw.elsa.status = 0;
|
||||
cs->hw.elsa.MFlag = 0;
|
||||
cs->subtyp = 0;
|
||||
|
||||
if (cs->typ == ISDN_CTYPE_ELSA) {
|
||||
rc = setup_elsa_isa(card);
|
||||
if (!rc)
|
||||
return (0);
|
||||
|
||||
} else if (cs->typ == ISDN_CTYPE_ELSA_PNP) {
|
||||
rc = setup_elsa_isapnp(card);
|
||||
if (!rc)
|
||||
return (0);
|
||||
|
||||
} else if (cs->typ == ISDN_CTYPE_ELSA_PCMCIA)
|
||||
setup_elsa_pcmcia(card);
|
||||
|
||||
else if (cs->typ == ISDN_CTYPE_ELSA_PCI) {
|
||||
rc = setup_elsa_pci(card);
|
||||
if (!rc)
|
||||
return (0);
|
||||
|
||||
} else
|
||||
return (0);
|
||||
|
||||
return setup_elsa_common(card);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user