From dd8e9ed6ed544e2b924429d29cd2a6b55590109b Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Fri, 22 Sep 2006 10:19:20 +0100 Subject: [MTD] Switch to pci_get_device and do ref counting Signed-off-by: Alan Cox Cc: Greg KH Signed-off-by: Andrew Morton Signed-off-by: David Woodhouse --- drivers/mtd/devices/pmc551.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'drivers/mtd/devices/pmc551.c') diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c index 2c014970873..a03a8a79e5c 100644 --- a/drivers/mtd/devices/pmc551.c +++ b/drivers/mtd/devices/pmc551.c @@ -674,7 +674,7 @@ static int __init init_pmc551(void) */ for( count = 0; count < MAX_MTD_DEVICES; count++ ) { - if ((PCI_Device = pci_find_device(PCI_VENDOR_ID_V3_SEMI, + if ((PCI_Device = pci_get_device(PCI_VENDOR_ID_V3_SEMI, PCI_DEVICE_ID_V3_SEMI_V370PDC, PCI_Device ) ) == NULL) { break; @@ -783,6 +783,10 @@ static int __init init_pmc551(void) kfree(mtd); break; } + + /* Keep a reference as the add_mtd_device worked */ + pci_dev_get(PCI_Device); + printk(KERN_NOTICE "Registered pmc551 memory device.\n"); printk(KERN_NOTICE "Mapped %dM of memory from 0x%p to 0x%p\n", priv->asize>>20, @@ -797,6 +801,10 @@ static int __init init_pmc551(void) found++; } + /* Exited early, reference left over */ + if (PCI_Device) + pci_dev_put(PCI_Device); + if( !pmc551list ) { printk(KERN_NOTICE "pmc551: not detected\n"); return -ENODEV; @@ -824,6 +832,7 @@ static void __exit cleanup_pmc551(void) priv->asize>>20, priv->start); iounmap (priv->start); } + pci_dev_put(priv->dev); kfree (mtd->priv); del_mtd_device (mtd); -- cgit v1.2.3