diff --git a/drivers/mtd/maps/scx200_docflash.c b/drivers/mtd/maps/scx200_docflash.c --- a/drivers/mtd/maps/scx200_docflash.c +++ b/drivers/mtd/maps/scx200_docflash.c @@ -88,14 +88,16 @@ static int __init init_scx200_docflash(v printk(KERN_DEBUG NAME ": NatSemi SCx200 DOCCS Flash Driver\n"); - if ((bridge = pci_find_device(PCI_VENDOR_ID_NS, + if ((bridge = pci_get_device(PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SCx200_BRIDGE, NULL)) == NULL) return -ENODEV; /* check that we have found the configuration block */ - if (!scx200_cb_present()) + if (!scx200_cb_present()) { + pci_dev_put(bridge); return -ENODEV; + } if (probe) { /* Try to use the present flash mapping if any */ @@ -104,16 +106,20 @@ static int __init init_scx200_docflash(v pmr = inl(scx200_cb_base + SCx200_PMR); if (base == 0 - || (ctrl & 0x07000000) != 0x07000000 - || (ctrl & 0x0007ffff) == 0) + || (ctrl & 0x07000000) != 0x07000000 + || (ctrl & 0x0007ffff) == 0) { + pci_dev_put(bridge); return -ENODEV; + } size = ((ctrl&0x1fff)<<13) + (1<<13); for (u = size; u > 1; u >>= 1) ; - if (u != 1) + if (u != 1) { + pci_dev_put(bridge); return -ENODEV; + } if (pmr & (1<<6)) width = 16; @@ -125,6 +131,7 @@ static int __init init_scx200_docflash(v if (request_resource(&iomem_resource, &docmem)) { printk(KERN_ERR NAME ": unable to allocate memory for flash mapping\n"); + pci_dev_put(bridge); return -ENOMEM; } } else { @@ -132,11 +139,13 @@ static int __init init_scx200_docflash(v ; if (u != 1) { printk(KERN_ERR NAME ": invalid size for flash mapping\n"); + pci_dev_put(bridge); return -EINVAL; } if (width != 8 && width != 16) { printk(KERN_ERR NAME ": invalid bus width for flash mapping\n"); + pci_dev_put(bridge); return -EINVAL; } @@ -145,6 +154,7 @@ static int __init init_scx200_docflash(v 0xc0000000, 0xffffffff, size, NULL, NULL)) { printk(KERN_ERR NAME ": unable to allocate memory for flash mapping\n"); + pci_dev_put(bridge); return -ENOMEM; } @@ -163,6 +173,8 @@ static int __init init_scx200_docflash(v } outl(pmr, scx200_cb_base + SCx200_PMR); } + + pci_dev_put(bridge); printk(KERN_INFO NAME ": DOCCS mapped at 0x%lx-0x%lx, width %d\n", docmem.start, docmem.end, width); @@ -203,6 +215,7 @@ static int __init init_scx200_docflash(v #else add_mtd_device(mymtd); #endif + return 0; }