Commit e8108c98 authored by Marcelo Tosatti's avatar Marcelo Tosatti Committed by Linus Torvalds

[PATCH] PC300 pci_enable_device fix

Call pci_enable_device() before looking at IRQ and resources,
and pci_disable_device() when shutting the interface down.

The driver requires this fix or the "pci=routeirq" workaround
on 2.6.10 and later kernels.

Reported and tested by Artur Lipowski. 

From: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: default avatarMarcelo Tosatti <marcelo.tosatti@cyclades.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent efa54579
...@@ -3427,7 +3427,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -3427,7 +3427,7 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{ {
static int first_time = 1; static int first_time = 1;
ucchar cpc_rev_id; ucchar cpc_rev_id;
int err = 0, eeprom_outdated = 0; int err, eeprom_outdated = 0;
ucshort device_id; ucshort device_id;
pc300_t *card; pc300_t *card;
...@@ -3439,15 +3439,21 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -3439,15 +3439,21 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
#endif #endif
} }
if ((err = pci_enable_device(pdev)) < 0)
return err;
card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL); card = (pc300_t *) kmalloc(sizeof(pc300_t), GFP_KERNEL);
if (card == NULL) { if (card == NULL) {
printk("PC300 found at RAM 0x%08lx, " printk("PC300 found at RAM 0x%08lx, "
"but could not allocate card structure.\n", "but could not allocate card structure.\n",
pci_resource_start(pdev, 3)); pci_resource_start(pdev, 3));
return -ENOMEM; err = -ENOMEM;
goto err_disable_dev;
} }
memset(card, 0, sizeof(pc300_t)); memset(card, 0, sizeof(pc300_t));
err = -ENODEV;
/* read PCI configuration area */ /* read PCI configuration area */
device_id = ent->device; device_id = ent->device;
card->hw.irq = pdev->irq; card->hw.irq = pdev->irq;
...@@ -3507,7 +3513,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -3507,7 +3513,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
printk("PC300 found at RAM 0x%08x, " printk("PC300 found at RAM 0x%08x, "
"but could not allocate PLX mem region.\n", "but could not allocate PLX mem region.\n",
card->hw.ramphys); card->hw.ramphys);
err = -ENODEV;
goto err_release_io; goto err_release_io;
} }
if (!request_mem_region(card->hw.ramphys, card->hw.alloc_ramsize, if (!request_mem_region(card->hw.ramphys, card->hw.alloc_ramsize,
...@@ -3515,7 +3520,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -3515,7 +3520,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
printk("PC300 found at RAM 0x%08x, " printk("PC300 found at RAM 0x%08x, "
"but could not allocate RAM mem region.\n", "but could not allocate RAM mem region.\n",
card->hw.ramphys); card->hw.ramphys);
err = -ENODEV;
goto err_release_plx; goto err_release_plx;
} }
if (!request_mem_region(card->hw.scaphys, card->hw.scasize, if (!request_mem_region(card->hw.scaphys, card->hw.scasize,
...@@ -3523,13 +3527,9 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -3523,13 +3527,9 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
printk("PC300 found at RAM 0x%08x, " printk("PC300 found at RAM 0x%08x, "
"but could not allocate SCA mem region.\n", "but could not allocate SCA mem region.\n",
card->hw.ramphys); card->hw.ramphys);
err = -ENODEV;
goto err_release_ram; goto err_release_ram;
} }
if ((err = pci_enable_device(pdev)) != 0)
goto err_release_sca;
card->hw.plxbase = ioremap(card->hw.plxphys, card->hw.plxsize); card->hw.plxbase = ioremap(card->hw.plxphys, card->hw.plxsize);
card->hw.rambase = ioremap(card->hw.ramphys, card->hw.alloc_ramsize); card->hw.rambase = ioremap(card->hw.ramphys, card->hw.alloc_ramsize);
card->hw.scabase = ioremap(card->hw.scaphys, card->hw.scasize); card->hw.scabase = ioremap(card->hw.scaphys, card->hw.scasize);
...@@ -3619,7 +3619,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -3619,7 +3619,6 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
iounmap(card->hw.falcbase); iounmap(card->hw.falcbase);
release_mem_region(card->hw.falcphys, card->hw.falcsize); release_mem_region(card->hw.falcphys, card->hw.falcsize);
} }
err_release_sca:
release_mem_region(card->hw.scaphys, card->hw.scasize); release_mem_region(card->hw.scaphys, card->hw.scasize);
err_release_ram: err_release_ram:
release_mem_region(card->hw.ramphys, card->hw.alloc_ramsize); release_mem_region(card->hw.ramphys, card->hw.alloc_ramsize);
...@@ -3628,7 +3627,9 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -3628,7 +3627,9 @@ cpc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
err_release_io: err_release_io:
release_region(card->hw.iophys, card->hw.iosize); release_region(card->hw.iophys, card->hw.iosize);
kfree(card); kfree(card);
return -ENODEV; err_disable_dev:
pci_disable_device(pdev);
return err;
} }
static void __devexit cpc_remove_one(struct pci_dev *pdev) static void __devexit cpc_remove_one(struct pci_dev *pdev)
...@@ -3662,6 +3663,7 @@ static void __devexit cpc_remove_one(struct pci_dev *pdev) ...@@ -3662,6 +3663,7 @@ static void __devexit cpc_remove_one(struct pci_dev *pdev)
if (card->hw.irq) if (card->hw.irq)
free_irq(card->hw.irq, card); free_irq(card->hw.irq, card);
kfree(card); kfree(card);
pci_disable_device(pdev);
} }
} }
......
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