Commit 51763947 authored by Chas Williams's avatar Chas Williams Committed by David S. Miller

[ATM]: [drivers] pci_enable_device() before finding irq

Signed-off-by: default avatarChas Williams <chas@cmf.nrl.navy.mil>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 46b2c02f
......@@ -2228,17 +2228,12 @@ static void setup_dev(amb_dev *dev, struct pci_dev *pci_dev)
spin_lock_init (&dev->rxq[pool].lock);
}
static int setup_pci_dev(struct pci_dev *pci_dev)
static void setup_pci_dev(struct pci_dev *pci_dev)
{
unsigned char lat;
int ret;
// enable bus master accesses
pci_set_master(pci_dev);
ret = pci_enable_device(pci_dev);
if (ret < 0)
goto out;
// frobnicate latency (upwards, usually)
pci_read_config_byte (pci_dev, PCI_LATENCY_TIMER, &lat);
......@@ -2251,22 +2246,27 @@ static int setup_pci_dev(struct pci_dev *pci_dev)
lat, pci_lat);
pci_write_config_byte(pci_dev, PCI_LATENCY_TIMER, pci_lat);
}
out:
return ret;
}
static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_id *pci_ent)
{
amb_dev * dev;
int err;
unsigned int irq;
err = pci_enable_device(pci_dev);
if (err < 0) {
PRINTK (KERN_ERR, "skipped broken (PLX rev 2) card");
goto out;
}
// read resources from PCI configuration space
unsigned int irq = pci_dev->irq;
irq = pci_dev->irq;
if (pci_dev->device == PCI_DEVICE_ID_MADGE_AMBASSADOR_BAD) {
PRINTK (KERN_ERR, "skipped broken (PLX rev 2) card");
err = -EINVAL;
goto out;
goto out_disable;
}
PRINTD (DBG_INFO, "found Madge ATM adapter (amb) at"
......@@ -2277,7 +2277,7 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_
err = pci_request_region(pci_dev, 1, DEV_LABEL);
if (err < 0) {
PRINTK (KERN_ERR, "IO range already in use!");
goto out;
goto out_disable;
}
dev = kmalloc (sizeof(amb_dev), GFP_KERNEL);
......@@ -2295,15 +2295,13 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_
goto out_free;
}
err = setup_pci_dev(pci_dev);
if (err < 0)
goto out_reset;
setup_pci_dev(pci_dev);
// grab (but share) IRQ and install handler
err = request_irq(irq, interrupt_handler, SA_SHIRQ, DEV_LABEL, dev);
if (err < 0) {
PRINTK (KERN_ERR, "request IRQ failed!");
goto out_disable;
goto out_reset;
}
dev->atm_dev = atm_dev_register (DEV_LABEL, &amb_ops, -1, NULL);
......@@ -2337,14 +2335,14 @@ static int __devinit amb_probe(struct pci_dev *pci_dev, const struct pci_device_
out_free_irq:
free_irq(irq, dev);
out_disable:
pci_disable_device(pci_dev);
out_reset:
amb_reset(dev, 0);
out_free:
kfree(dev);
out_release:
pci_release_region(pci_dev, 1);
out_disable:
pci_disable_device(pci_dev);
goto out;
}
......
......@@ -2706,18 +2706,18 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_
// adapter slot free, read resources from PCI configuration space
u32 iobase = pci_resource_start (pci_dev, 0);
u32 * membase = bus_to_virt (pci_resource_start (pci_dev, 1));
u8 irq = pci_dev->irq;
unsigned int irq;
unsigned char lat;
PRINTD (DBG_FLOW, "hrz_probe");
/* XXX DEV_LABEL is a guess */
if (!request_region(iobase, HRZ_IO_EXTENT, DEV_LABEL))
if (pci_enable_device(pci_dev))
return -EINVAL;
if (pci_enable_device(pci_dev)) {
err = -EINVAL;
goto out_release;
/* XXX DEV_LABEL is a guess */
if (!request_region(iobase, HRZ_IO_EXTENT, DEV_LABEL)) {
return -EINVAL;
goto out_disable;
}
dev = kmalloc(sizeof(hrz_dev), GFP_KERNEL);
......@@ -2725,7 +2725,7 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_
// perhaps we should be nice: deregister all adapters and abort?
PRINTD(DBG_ERR, "out of memory");
err = -ENOMEM;
goto out_disable;
goto out_release;
}
memset(dev, 0, sizeof(hrz_dev));
......@@ -2733,6 +2733,7 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_
pci_set_drvdata(pci_dev, dev);
// grab IRQ and install handler - move this someplace more sensible
irq = pci_dev->irq;
if (request_irq(irq,
interrupt_handler,
SA_SHIRQ, /* irqflags guess */
......@@ -2846,10 +2847,10 @@ static int __devinit hrz_probe(struct pci_dev *pci_dev, const struct pci_device_
free_irq(dev->irq, dev);
out_free:
kfree(dev);
out_disable:
pci_disable_device(pci_dev);
out_release:
release_region(iobase, HRZ_IO_EXTENT);
out_disable:
pci_disable_device(pci_dev);
goto out;
}
......
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