diff --git a/arch/alpha/kernel/sys_alcor.c b/arch/alpha/kernel/sys_alcor.c --- a/arch/alpha/kernel/sys_alcor.c +++ b/arch/alpha/kernel/sys_alcor.c @@ -254,7 +254,7 @@ alcor_init_pci(void) * motherboard, by looking for a 21040 TULIP in slot 6, which is * built into XLT and BRET/MAVERICK, but not available on ALCOR. */ - dev = pci_find_device(PCI_VENDOR_ID_DEC, + dev = pci_get_device(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP, NULL); if (dev && dev->devfn == PCI_DEVFN(6,0)) { @@ -262,6 +262,7 @@ alcor_init_pci(void) printk(KERN_INFO "%s: Detected AS500 or XLT motherboard.\n", __FUNCTION__); } + pci_dev_put(dev); } diff --git a/arch/alpha/kernel/sys_sio.c b/arch/alpha/kernel/sys_sio.c --- a/arch/alpha/kernel/sys_sio.c +++ b/arch/alpha/kernel/sys_sio.c @@ -105,7 +105,7 @@ sio_collect_irq_levels(void) struct pci_dev *dev = NULL; /* Iterate through the devices, collecting IRQ levels. */ - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + for_each_pci_dev(dev) { if ((dev->class >> 16 == PCI_BASE_CLASS_BRIDGE) && (dev->class >> 8 != PCI_CLASS_BRIDGE_PCMCIA)) continue; @@ -229,8 +229,8 @@ alphabook1_init_pci(void) */ dev = NULL; - while ((dev = pci_find_device(PCI_VENDOR_ID_NCR, PCI_ANY_ID, dev))) { - if (dev->device == PCI_DEVICE_ID_NCR_53C810 + while ((dev = pci_get_device(PCI_VENDOR_ID_NCR, PCI_ANY_ID, dev))) { + if (dev->device == PCI_DEVICE_ID_NCR_53C810 || dev->device == PCI_DEVICE_ID_NCR_53C815 || dev->device == PCI_DEVICE_ID_NCR_53C820 || dev->device == PCI_DEVICE_ID_NCR_53C825) { @@ -244,7 +244,7 @@ alphabook1_init_pci(void) " burst disable\n"); outb(ctest4 | 0x80, io_port+0x21); } - } + } } /* Do not set *ANY* level triggers for AlphaBook1. */ diff --git a/arch/frv/mb93090-mb00/pci-frv.c b/arch/frv/mb93090-mb00/pci-frv.c --- a/arch/frv/mb93090-mb00/pci-frv.c +++ b/arch/frv/mb93090-mb00/pci-frv.c @@ -142,9 +142,7 @@ static void __init pcibios_allocate_reso u16 command; struct resource *r, *pr; - while (dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev), - dev != NULL - ) { + for_each_pci_dev(dev) { pci_read_config_word(dev, PCI_COMMAND, &command); for(idx = 0; idx < 6; idx++) { r = &dev->resource[idx]; @@ -188,9 +186,7 @@ static void __init pcibios_assign_resour int idx; struct resource *r; - while (dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev), - dev != NULL - ) { + for_each_pci_dev(dev) { int class = dev->class >> 8; /* Don't touch classless devices and host bridges */ diff --git a/arch/frv/mb93090-mb00/pci-irq.c b/arch/frv/mb93090-mb00/pci-irq.c --- a/arch/frv/mb93090-mb00/pci-irq.c +++ b/arch/frv/mb93090-mb00/pci-irq.c @@ -48,9 +48,7 @@ void __init pcibios_fixup_irqs(void) struct pci_dev *dev = NULL; uint8_t line, pin; - while (dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev), - dev != NULL - ) { + for_each_pci_dev(dev) { pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); if (pin) { dev->irq = pci_bus0_irq_routing[PCI_SLOT(dev->devfn)][pin - 1]; diff --git a/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c b/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c --- a/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c +++ b/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c @@ -189,11 +189,9 @@ static __init struct pci_dev *gx_detect_ } /* detect which companion chip is used */ - while ((gx_pci = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, gx_pci)) != NULL) { - if ((pci_match_id(gx_chipset_tbl, gx_pci)) != NULL) { + for_each_pci_dev(gx_pci) + if ((pci_match_id(gx_chipset_tbl, gx_pci)) != NULL) return gx_pci; - } - } dprintk("error: no supported chipset found!\n"); return NULL; diff --git a/arch/i386/pci/acpi.c b/arch/i386/pci/acpi.c --- a/arch/i386/pci/acpi.c +++ b/arch/i386/pci/acpi.c @@ -38,7 +38,7 @@ static int __init pci_acpi_init(void) * don't use pci_enable_device(). */ printk(KERN_INFO "PCI: Routing PCI interrupts for all devices because \"pci=routeirq\" specified\n"); - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) + for_each_pci_dev(dev) acpi_pci_irq_enable(dev); } else printk(KERN_INFO "PCI: If a device doesn't work, try \"pci=routeirq\". If it helps, post a report\n"); diff --git a/arch/i386/pci/irq.c b/arch/i386/pci/irq.c --- a/arch/i386/pci/irq.c +++ b/arch/i386/pci/irq.c @@ -866,7 +866,7 @@ static int pcibios_lookup_irq(struct pci printk(KERN_INFO "PCI: %s IRQ %d for device %s\n", msg, irq, pci_name(dev)); /* Update IRQ for all devices with the same pirq value */ - while ((dev2 = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev2)) != NULL) { + for_each_pci_dev(dev2) { pci_read_config_byte(dev2, PCI_INTERRUPT_PIN, &pin); if (!pin) continue; @@ -900,7 +900,7 @@ static void __init pcibios_fixup_irqs(vo u8 pin; DBG("PCI: IRQ fixup\n"); - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + for_each_pci_dev(dev) { /* * If the BIOS has set an out of range IRQ number, just ignore it. * Also keep track of which IRQ's are already in use. @@ -916,7 +916,7 @@ static void __init pcibios_fixup_irqs(vo } dev = NULL; - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + for_each_pci_dev(dev) { pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin); #ifdef CONFIG_X86_IO_APIC /* diff --git a/arch/m68k/atari/hades-pci.c b/arch/m68k/atari/hades-pci.c --- a/arch/m68k/atari/hades-pci.c +++ b/arch/m68k/atari/hades-pci.c @@ -311,8 +311,7 @@ static void __init hades_fixup(int pci_m * Go through all devices, fixing up irqs as we see fit: */ - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) - { + for_each_pci_dev(dev) if (dev->class >> 16 != PCI_BASE_CLASS_BRIDGE) { slot = PCI_SLOT(dev->devfn); /* Determine slot number. */ @@ -320,7 +319,6 @@ static void __init hades_fixup(int pci_m if (pci_modify) pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); } - } } /* diff --git a/arch/ppc/kernel/pci.c b/arch/ppc/kernel/pci.c --- a/arch/ppc/kernel/pci.c +++ b/arch/ppc/kernel/pci.c @@ -503,7 +503,7 @@ pcibios_allocate_resources(int pass) u16 command; struct resource *r; - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + for_each_pci_dev(dev) { pci_read_config_word(dev, PCI_COMMAND, &command); for (idx = 0; idx < 6; idx++) { r = &dev->resource[idx]; @@ -540,7 +540,7 @@ pcibios_assign_resources(void) int idx; struct resource *r; - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + for_each_pci_dev(dev) { int class = dev->class >> 8; /* Don't touch classless devices and host bridges */ @@ -866,14 +866,14 @@ pci_device_from_OF_node(struct device_no */ if (!pci_to_OF_bus_map) return 0; - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { - if (pci_to_OF_bus_map[dev->bus->number] != *bus) - continue; - if (dev->devfn != *devfn) - continue; - *bus = dev->bus->number; - return 0; - } + for_each_pci_dev(dev) + if (pci_to_OF_bus_map[dev->bus->number] == *bus && + dev->devfn == *devfn) { + *bus = dev->bus->number; + pci_dev_put(dev); + return 0; + } + return -ENODEV; } @@ -1396,8 +1396,8 @@ int pcibios_enable_device(struct pci_dev int idx; struct resource *r; - if (ppc_md.pcibios_enable_device_hook) - if (ppc_md.pcibios_enable_device_hook(dev, 0)) + if ((ppc_md.pcibios_enable_device_hook) && + (ppc_md.pcibios_enable_device_hook(dev, 0))) return -EINVAL; pci_read_config_word(dev, PCI_COMMAND, &cmd); diff --git a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c --- a/arch/ppc/platforms/85xx/mpc85xx_cds_common.c +++ b/arch/ppc/platforms/85xx/mpc85xx_cds_common.c @@ -357,7 +357,7 @@ mpc85xx_cds_pcibios_fixup(void) struct pci_dev *dev = NULL; u_char c; - if ((dev = pci_find_device(PCI_VENDOR_ID_VIA, + if ((dev = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_1, NULL))) { /* * U-Boot does not set the enable bits @@ -374,21 +374,24 @@ mpc85xx_cds_pcibios_fixup(void) */ dev->irq = 14; pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq); + pci_dev_put(dev); } /* * Force legacy USB interrupt routing */ - if ((dev = pci_find_device(PCI_VENDOR_ID_VIA, + if ((dev = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_2, NULL))) { dev->irq = 10; pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 10); + pci_dev_put(dev); } - if ((dev = pci_find_device(PCI_VENDOR_ID_VIA, + if ((dev = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C586_2, dev))) { dev->irq = 11; pci_write_config_byte(dev, PCI_INTERRUPT_LINE, 11); + pci_dev_put(dev); } } #endif /* CONFIG_PCI */ diff --git a/arch/ppc64/kernel/eeh.c b/arch/ppc64/kernel/eeh.c --- a/arch/ppc64/kernel/eeh.c +++ b/arch/ppc64/kernel/eeh.c @@ -373,7 +373,7 @@ void __init pci_addr_cache_build(void) spin_lock_init(&pci_io_addr_cache_root.piar_lock); - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + for_each_pci_dev(dev) { /* Ignore PCI bridges ( XXX why ??) */ if ((dev->class >> 16) == PCI_BASE_CLASS_BRIDGE) { continue; diff --git a/arch/sparc64/kernel/ebus.c b/arch/sparc64/kernel/ebus.c --- a/arch/sparc64/kernel/ebus.c +++ b/arch/sparc64/kernel/ebus.c @@ -527,19 +527,13 @@ static struct pci_dev *find_next_ebus(st { struct pci_dev *pdev = start; - do { - pdev = pci_find_device(PCI_VENDOR_ID_SUN, PCI_ANY_ID, pdev); - if (pdev && - (pdev->device == PCI_DEVICE_ID_SUN_EBUS || - pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS)) + while (pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_ANY_ID, pdev)) + if (pdev->device == PCI_DEVICE_ID_SUN_EBUS || + pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS) break; - } while (pdev != NULL); - - if (pdev && (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS)) - *is_rio_p = 1; - else - *is_rio_p = 0; + *is_rio_p = !!(pdev && (pdev->device == PCI_DEVICE_ID_SUN_RIO_EBUS)); + return pdev; } diff --git a/drivers/char/ip2main.c b/drivers/char/ip2main.c --- a/drivers/char/ip2main.c +++ b/drivers/char/ip2main.c @@ -19,6 +19,9 @@ // // Done: // +// 1.2.15 Jiri Slaby +// Obsolete pci_find_device changed to pci_get_device. +// // 1.2.14 /\/\|=mhw=|\/\/ // Added bounds checking to ip2_ipl_ioctl to avoid potential terroristic acts. // Changed the definition of ip2trace to be more consistent with kernel style @@ -173,7 +176,7 @@ static int Fip_firmware_size; /* Private (static) functions */ static int ip2_open(PTTY, struct file *); static void ip2_close(PTTY, struct file *); -static int ip2_write(PTTY, int, const unsigned char *, int); +static int ip2_write(PTTY, /*int,*/ const unsigned char *, int); static void ip2_putchar(PTTY, unsigned char); static void ip2_flush_chars(PTTY); static int ip2_write_room(PTTY); @@ -442,6 +445,7 @@ cleanup_module(void) #ifdef CONFIG_PCI if (ip2config.type[i] == PCI && ip2config.pci_dev[i]) { pci_disable_device(ip2config.pci_dev[i]); + pci_dev_put(ip2config.pci_dev[i]); ip2config.pci_dev[i] = NULL; } #endif @@ -595,7 +599,7 @@ ip2_loadmain(int *iop, int *irqp, unsign #ifdef CONFIG_PCI { struct pci_dev *pci_dev_i = NULL; - pci_dev_i = pci_find_device(PCI_VENDOR_ID_COMPUTONE, + pci_dev_i = pci_get_device(PCI_VENDOR_ID_COMPUTONE, PCI_DEVICE_ID_COMPUTONE_IP2EX, pci_dev_i); if (pci_dev_i != NULL) { unsigned int addr; @@ -1712,7 +1716,7 @@ ip2_hangup ( PTTY tty ) /* */ /******************************************************************************/ static int -ip2_write( PTTY tty, int user, const unsigned char *pData, int count) +ip2_write( PTTY tty, /*int user,*/ const unsigned char *pData, int count) { i2ChanStrPtr pCh = tty->driver_data; int bytesSent = 0; @@ -1725,7 +1729,7 @@ ip2_write( PTTY tty, int user, const uns /* This is the actual move bit. Make sure it does what we need!!!!! */ WRITE_LOCK_IRQSAVE(&pCh->Pbuf_spinlock,flags); - bytesSent = i2Output( pCh, pData, count, user ); + bytesSent = i2Output( pCh, pData, count, 0 /*user*/ ); // XXX: which space? WRITE_UNLOCK_IRQRESTORE(&pCh->Pbuf_spinlock,flags); ip2trace (CHANN, ITRC_WRITE, ITRC_RETURN, 1, bytesSent ); @@ -2000,7 +2004,7 @@ ip2_stop ( PTTY tty ) static int ip2_tiocmget(struct tty_struct *tty, struct file *file) { i2ChanStrPtr pCh = DevTable[tty->index]; - wait_queue_t wait; +// wait_queue_t wait; if (pCh == NULL) return -ENODEV; diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c --- a/drivers/char/isicom.c +++ b/drivers/char/isicom.c @@ -91,6 +91,8 @@ * 06/01/05 Alan Cox Merged the ISI and base kernel strands * into a single 2.6 driver * + * 25/05/05 Jiri Slaby obsolete pci_find_device changed to + * pci_get_device * *********************************************************** * * To use this driver you also need the support package. You @@ -1963,7 +1965,7 @@ MODULE_PARM_DESC(irq, "Interrupts for th static int __devinit isicom_setup(void) { - struct pci_dev *dev = NULL; + struct pci_dev *dev; int retval, card, idx, count; unsigned char pciirq; unsigned int ioaddr; @@ -2001,14 +2003,11 @@ static int __devinit isicom_setup(void) if (card < BOARD_COUNT) { for (idx=0; idx < DEVID_COUNT; idx++) { dev = NULL; - for (;;){ - if (!(dev = pci_find_device(VENDOR_ID, isicom_pci_tbl[idx].device, dev))) - break; - if (card >= BOARD_COUNT) - break; - - if (pci_enable_device(dev)) + while (card < BOARD_COUNT && (dev = pci_get_device(VENDOR_ID, isicom_pci_tbl[idx].device, dev))) { + if (pci_enable_device(dev)) { + pci_dev_put(dev); break; + } /* found a PCI ISI card! */ ioaddr = pci_resource_start (dev, 3); /* i.e at offset 0x1c in the @@ -2020,7 +2019,7 @@ static int __devinit isicom_setup(void) /* * allot the first empty slot in the array */ - for (count=0; count < BOARD_COUNT; count++) { + for (count=0; count < BOARD_COUNT; count++) if (isi_card[count].base == 0) { isi_card[count].base = ioaddr; isi_card[count].irq = pciirq; @@ -2028,9 +2027,11 @@ static int __devinit isicom_setup(void) card++; break; } - } } - if (card >= BOARD_COUNT) break; + if (card >= BOARD_COUNT) { + pci_dev_put(dev); + break; + } } } diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c @@ -4602,11 +4602,12 @@ static int stli_findpcibrds(void) printk("stli_findpcibrds()\n"); #endif - while ((dev = pci_find_device(PCI_VENDOR_ID_STALLION, - PCI_DEVICE_ID_ECRA, dev))) { - if ((rc = stli_initpcibrd(BRD_ECPPCI, dev))) + while ((dev = pci_get_device(PCI_VENDOR_ID_STALLION, + PCI_DEVICE_ID_ECRA, dev))) + if ((rc = stli_initpcibrd(BRD_ECPPCI, dev))) { + pci_dev_put(dev); return(rc); - } + } return(0); } diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c @@ -28,6 +28,8 @@ * 02/06/01 Fix the problem for H/W flow control. * 02/06/01 Fix the compling warning when CONFIG_PCI * don't be defined. + * 15/05/05 Jiri Slaby obsolete pci_find_device + * changed to pci_get_device. * * Fed through a cleanup, indent and remove of non 2.6 code by Alan Cox * . The original 1.8 code is available on www.moxa.com. @@ -512,6 +514,7 @@ static void __exit mxser_module_exit(voi if (pdev != NULL) { //PCI release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2)); release_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3)); + pci_dev_put(pdev); } else { release_region(mxsercfg[i].ioaddr[0], 8 * mxsercfg[i].ports); release_region(mxsercfg[i].vector, 1); @@ -832,7 +835,7 @@ static int mxser_init(void) index = 0; b = 0; while (b < n) { - pdev = pci_find_device(mxser_pcibrds[b].vendor, mxser_pcibrds[b].device, pdev); + pdev = pci_get_device(mxser_pcibrds[b].vendor, mxser_pcibrds[b].device, pdev); if (pdev == NULL) { b++; continue; diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c --- a/drivers/char/rocket.c +++ b/drivers/char/rocket.c @@ -2233,7 +2233,7 @@ static int __init init_PCI(int boards_fo int count = 0; /* Work through the PCI device list, pulling out ours */ - while ((dev = pci_find_device(PCI_VENDOR_ID_RP, PCI_ANY_ID, dev))) { + while ((dev = pci_get_device(PCI_VENDOR_ID_RP, PCI_ANY_ID, dev))) { if (register_PCI(count + boards_found, dev)) count++; } diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c --- a/drivers/char/specialix.c +++ b/drivers/char/specialix.c @@ -63,7 +63,9 @@ * Revision 1.10: Oct 22 1999 / Jan 21 2000. * Added stuff for setserial. * Nicolas Mailhot (Nicolas.Mailhot@email.enst.fr) - * + * Revision 1.11: May 25 2005 + * obsolete pci_find_device --> pci_get_device + * Jiri Slaby */ #define VERSION "1.11" @@ -2512,9 +2514,9 @@ static int __init specialix_init(void) i++; continue; } - pdev = pci_find_device (PCI_VENDOR_ID_SPECIALIX, - PCI_DEVICE_ID_SPECIALIX_IO8, - pdev); + pdev = pci_get_device (PCI_VENDOR_ID_SPECIALIX, + PCI_DEVICE_ID_SPECIALIX_IO8, + pdev); if (!pdev) break; if (pci_enable_device(pdev)) @@ -2527,7 +2529,10 @@ static int __init specialix_init(void) sx_board[i].flags |= SX_BOARD_IS_PCI; if (!sx_probe(&sx_board[i])) found ++; + } + if (i >= SX_NBOARD) + pci_dev_put(pdev); } #endif diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c @@ -2726,7 +2726,7 @@ static inline int stl_findpcibrds(void) #endif for (i = 0; (i < stl_nrpcibrds); i++) - while ((dev = pci_find_device(stl_pcibrds[i].vendid, + while ((dev = pci_get_device(stl_pcibrds[i].vendid, stl_pcibrds[i].devid, dev))) { /* @@ -2737,8 +2737,10 @@ static inline int stl_findpcibrds(void) continue; rc = stl_initpcibrd(stl_pcibrds[i].brdtype, dev); - if (rc) + if (rc) { + pci_dev_put(dev); return(rc); + } } return(0); diff --git a/drivers/char/sx.c b/drivers/char/sx.c --- a/drivers/char/sx.c +++ b/drivers/char/sx.c @@ -2439,7 +2439,7 @@ static int __init sx_init(void) } #ifdef CONFIG_PCI - while ((pdev = pci_find_device (PCI_VENDOR_ID_SPECIALIX, + while ((pdev = pci_get_device (PCI_VENDOR_ID_SPECIALIX, PCI_DEVICE_ID_SPECIALIX_SX_XIO_IO8, pdev))) { if (pci_enable_device(pdev)) diff --git a/drivers/char/watchdog/alim1535_wdt.c b/drivers/char/watchdog/alim1535_wdt.c --- a/drivers/char/watchdog/alim1535_wdt.c +++ b/drivers/char/watchdog/alim1535_wdt.c @@ -5,6 +5,11 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. + * + * Changes: + * + * Jiri Slaby + * Obsolete pci_find_device changed to pci_get_device. */ #include @@ -335,17 +340,20 @@ static int __init ali_find_watchdog(void u32 wdog; /* Check for a 1535 series bridge */ - pdev = pci_find_device(PCI_VENDOR_ID_AL, 0x1535, NULL); + pdev = pci_get_device(PCI_VENDOR_ID_AL, 0x1535, NULL); if(pdev == NULL) return -ENODEV; + pci_dev_put(pdev); /* Check for the a 7101 PMU */ - pdev = pci_find_device(PCI_VENDOR_ID_AL, 0x7101, NULL); + pdev = pci_get_device(PCI_VENDOR_ID_AL, 0x7101, NULL); if(pdev == NULL) return -ENODEV; - if(pci_enable_device(pdev)) + if(pci_enable_device(pdev)) { + pci_dev_put(pdev); return -EIO; + } ali_pci = pdev; @@ -450,6 +458,7 @@ static void __exit watchdog_exit(void) ali_stop(); /* Deregister */ + pci_dev_put(ali_pci); // decrement the reference count unregister_reboot_notifier(&ali_notifier); misc_deregister(&ali_miscdev); } diff --git a/drivers/char/watchdog/alim7101_wdt.c b/drivers/char/watchdog/alim7101_wdt.c --- a/drivers/char/watchdog/alim7101_wdt.c +++ b/drivers/char/watchdog/alim7101_wdt.c @@ -338,6 +338,8 @@ static void __exit alim7101_wdt_unload(v /* Deregister */ misc_deregister(&wdt_miscdev); unregister_reboot_notifier(&wdt_notifier); + + pci_dev_put(alim7101_pmu); } static int __init alim7101_wdt_init(void) @@ -347,7 +349,7 @@ static int __init alim7101_wdt_init(void char tmp; printk(KERN_INFO PFX "Steve Hill .\n"); - alim7101_pmu = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101,NULL); + alim7101_pmu = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101,NULL); if (!alim7101_pmu) { printk(KERN_INFO PFX "ALi M7101 PMU not present - WDT not set\n"); return -EBUSY; @@ -356,12 +358,13 @@ static int __init alim7101_wdt_init(void /* Set the WDT in the PMU to 1 second */ pci_write_config_byte(alim7101_pmu, ALI_7101_WDT, 0x02); - ali1543_south = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); + ali1543_south = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); if (!ali1543_south) { printk(KERN_INFO PFX "ALi 1543 South-Bridge not present - WDT not set\n"); return -EBUSY; } pci_read_config_byte(ali1543_south, 0x5e, &tmp); + pci_dev_put(ali1543_south); if ((tmp & 0x1e) == 0x00) { if (!use_gpio) { printk(KERN_INFO PFX "Detected old alim7101 revision 'a1d'. If this is a cobalt board, set the 'use_gpio' module parameter.\n"); diff --git a/drivers/char/watchdog/i8xx_tco.c b/drivers/char/watchdog/i8xx_tco.c --- a/drivers/char/watchdog/i8xx_tco.c +++ b/drivers/char/watchdog/i8xx_tco.c @@ -400,12 +400,11 @@ static unsigned char __init i8xx_tco_get * Find the PCI device */ - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + for_each_pci_dev(dev) if (pci_match_id(i8xx_tco_pci_tbl, dev)) { i8xx_tco_pci = dev; break; } - } if (i8xx_tco_pci) { /* @@ -525,6 +524,8 @@ static void __exit watchdog_cleanup (voi misc_deregister (&i8xx_tco_miscdev); unregister_reboot_notifier(&i8xx_tco_notifier); release_region (TCOBASE, 0x10); + + pci_dev_put(i8xx_tco_pci); } module_init(watchdog_init); diff --git a/drivers/ide/pci/alim15x3.c b/drivers/ide/pci/alim15x3.c --- a/drivers/ide/pci/alim15x3.c +++ b/drivers/ide/pci/alim15x3.c @@ -591,7 +591,7 @@ static unsigned int __devinit init_chips pci_read_config_byte(dev, PCI_REVISION_ID, &m5229_revision); - isa_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); + isa_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); #if defined(DISPLAY_ALI_TIMINGS) && defined(CONFIG_PROC_FS) if (!ali_proc) { @@ -877,9 +877,13 @@ static ide_pci_device_t ali15x3_chipset static int __devinit alim15x3_init_one(struct pci_dev *dev, const struct pci_device_id *id) { ide_pci_device_t *d = &ali15x3_chipset; + struct pci_dev *pdev; - if(pci_find_device(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS100, NULL)) + if((pdev = pci_get_device(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_RS100, + NULL))) { + pci_dev_put(pdev); printk(KERN_ERR "Warning: ATI Radeon IGP Northbridge is not yet fully tested.\n"); + } #if defined(CONFIG_SPARC64) d->init_hwif = init_hwif_common_ali15x3; @@ -903,9 +907,18 @@ static struct pci_driver driver = { static int ali15x3_ide_init(void) { + isa_dev = NULL; return ide_pci_register_driver(&driver); } +#ifdef MODULE +static void __exit ali15x3_ide_exit(void) +{ + pci_dev_put(isa_dev); +} + +module_exit(ali15x3_ide_exit); +#endif module_init(ali15x3_ide_init); MODULE_AUTHOR("Michael Aubry, Andrzej Krzysztofowicz, CJ, Andre Hedrick, Alan Cox"); diff --git a/drivers/ide/pci/cs5530.c b/drivers/ide/pci/cs5530.c --- a/drivers/ide/pci/cs5530.c +++ b/drivers/ide/pci/cs5530.c @@ -223,7 +223,7 @@ static unsigned int __devinit init_chips unsigned long flags; dev = NULL; - while ((dev = pci_find_device(PCI_VENDOR_ID_CYRIX, PCI_ANY_ID, dev)) != NULL) { + while ((dev = pci_get_device(PCI_VENDOR_ID_CYRIX, PCI_ANY_ID, dev)) != NULL) { switch (dev->device) { case PCI_DEVICE_ID_CYRIX_PCI_MASTER: master_0 = dev; @@ -235,10 +235,12 @@ static unsigned int __devinit init_chips } if (!master_0) { printk(KERN_ERR "%s: unable to locate PCI MASTER function\n", name); + pci_dev_put(cs5530_0); return 0; } if (!cs5530_0) { printk(KERN_ERR "%s: unable to locate CS5530 LEGACY function\n", name); + pci_dev_put(master_0); return 0; } @@ -297,6 +299,9 @@ static unsigned int __devinit init_chips spin_unlock_irqrestore(&ide_lock, flags); + pci_dev_put(master_0); + pci_dev_put(cs5530_0); + return 0; } diff --git a/drivers/ide/pci/hpt366.c b/drivers/ide/pci/hpt366.c --- a/drivers/ide/pci/hpt366.c +++ b/drivers/ide/pci/hpt366.c @@ -1542,11 +1542,12 @@ static void __devinit init_iops_hpt366(i static int __devinit init_setup_hpt374(struct pci_dev *dev, ide_pci_device_t *d) { struct pci_dev *findev = NULL; + int ret; if (PCI_FUNC(dev->devfn) & 1) return -ENODEV; - while ((findev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) { + while ((findev = pci_get_device(dev->vendor, dev->device, findev)) != NULL) if ((findev->vendor == dev->vendor) && (findev->device == dev->device) && ((findev->devfn - dev->devfn) == 1) && @@ -1557,9 +1558,10 @@ static int __devinit init_setup_hpt374(s printk(KERN_WARNING "%s: pci-config space interrupt " "fixed.\n", d->name); } - return ide_setup_pci_devices(dev, findev, d); + ret = ide_setup_pci_devices(dev, findev, d); + pci_dev_put(findev); + return ret; } - } return ide_setup_pci_device(dev, d); } @@ -1571,6 +1573,7 @@ static int __devinit init_setup_hpt37x(s static int __devinit init_setup_hpt366(struct pci_dev *dev, ide_pci_device_t *d) { struct pci_dev *findev = NULL; + int ret; u8 pin1 = 0, pin2 = 0; unsigned int class_rev; char *chipset_names[] = {"HPT366", "HPT366", "HPT368", @@ -1602,7 +1605,8 @@ static int __devinit init_setup_hpt366(s d->channels = 1; pci_read_config_byte(dev, PCI_INTERRUPT_PIN, &pin1); - while ((findev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) { + + while ((findev = pci_get_device(dev->vendor, dev->device, findev)) != NULL) if ((findev->vendor == dev->vendor) && (findev->device == dev->device) && ((findev->devfn - dev->devfn) == 1) && @@ -1614,9 +1618,10 @@ static int __devinit init_setup_hpt366(s "pin1=%d pin2=%d\n", d->name, pin1, pin2); } - return ide_setup_pci_devices(dev, findev, d); + ret = ide_setup_pci_devices(dev, findev, d); + pci_dev_put(findev); + return ret; } - } init_single: return ide_setup_pci_device(dev, d); } diff --git a/drivers/ide/pci/pdc202xx_new.c b/drivers/ide/pci/pdc202xx_new.c --- a/drivers/ide/pci/pdc202xx_new.c +++ b/drivers/ide/pci/pdc202xx_new.c @@ -361,6 +361,7 @@ static int __devinit init_setup_pdc20270 ide_pci_device_t *d) { struct pci_dev *findev = NULL; + int ret; if ((dev->bus->self && dev->bus->self->vendor == PCI_VENDOR_ID_DEC) && @@ -368,16 +369,16 @@ static int __devinit init_setup_pdc20270 if (PCI_SLOT(dev->devfn) & 2) return -ENODEV; d->extra = 0; - while ((findev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, findev)) != NULL) { - if ((findev->vendor == dev->vendor) && - (findev->device == dev->device) && - (PCI_SLOT(findev->devfn) & 2)) { + while ((findev = pci_get_device(dev->vendor, dev->device, findev)) + != NULL) + if (PCI_SLOT(findev->devfn) & 2) { if (findev->irq != dev->irq) { findev->irq = dev->irq; } - return ide_setup_pci_devices(dev, findev, d); + ret = ide_setup_pci_devices(dev, findev, d); + pci_dev_put(findev); + return ret; } - } } return ide_setup_pci_device(dev, d); } diff --git a/drivers/ide/pci/piix.c b/drivers/ide/pci/piix.c --- a/drivers/ide/pci/piix.c +++ b/drivers/ide/pci/piix.c @@ -605,8 +605,7 @@ static void __devinit piix_check_450nx(v struct pci_dev *pdev = NULL; u16 cfg; u8 rev; - while((pdev=pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev))!=NULL) - { + while((pdev=pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82454NX, pdev))!=NULL) { /* Look for 450NX PXB. Check for problem configurations A PCI quirk checks bit 6 already */ pci_read_config_byte(pdev, PCI_REVISION_ID, &rev); diff --git a/drivers/ide/pci/serverworks.c b/drivers/ide/pci/serverworks.c --- a/drivers/ide/pci/serverworks.c +++ b/drivers/ide/pci/serverworks.c @@ -354,7 +354,7 @@ static unsigned int __devinit init_chips /* OSB4 : South Bridge and IDE */ if (dev->device == PCI_DEVICE_ID_SERVERWORKS_OSB4IDE) { - isa_dev = pci_find_device(PCI_VENDOR_ID_SERVERWORKS, + isa_dev = pci_get_device(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_OSB4, NULL); if (isa_dev) { pci_read_config_dword(isa_dev, 0x64, ®); @@ -375,7 +375,7 @@ static unsigned int __devinit init_chips if (!(PCI_FUNC(dev->devfn) & 1)) { struct pci_dev * findev = NULL; u32 reg4c = 0; - findev = pci_find_device(PCI_VENDOR_ID_SERVERWORKS, + findev = pci_get_device(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB5, NULL); if (findev) { pci_read_config_dword(findev, 0x4C, ®4c); @@ -383,6 +383,7 @@ static unsigned int __devinit init_chips reg4c |= 0x00000040; reg4c |= 0x00000020; pci_write_config_dword(findev, 0x4C, reg4c); + pci_dev_put(findev); } outb_p(0x06, 0x0c00); dev->irq = inb_p(0x0c01); @@ -400,12 +401,13 @@ static unsigned int __devinit init_chips struct pci_dev * findev = NULL; u8 reg41 = 0; - findev = pci_find_device(PCI_VENDOR_ID_SERVERWORKS, + findev = pci_get_device(PCI_VENDOR_ID_SERVERWORKS, PCI_DEVICE_ID_SERVERWORKS_CSB6, NULL); if (findev) { pci_read_config_byte(findev, 0x41, ®41); reg41 &= ~0x40; pci_write_config_byte(findev, 0x41, reg41); + pci_dev_put(findev); } /* * This is a device pin issue on CSB6. @@ -665,9 +667,18 @@ static struct pci_driver driver = { static int svwks_ide_init(void) { + isa_dev = NULL; return ide_pci_register_driver(&driver); } +#ifdef MODULE +static void __exit svwks_ide_exit() +{ + pci_dev_put(isa_dev); +} +module_exit(svwks_ide_exit); +#endif + module_init(svwks_ide_init); MODULE_AUTHOR("Michael Aubry. Andrzej Krzysztofowicz, Andre Hedrick"); diff --git a/drivers/ide/pci/sis5513.c b/drivers/ide/pci/sis5513.c --- a/drivers/ide/pci/sis5513.c +++ b/drivers/ide/pci/sis5513.c @@ -735,7 +735,7 @@ static unsigned int __devinit init_chips for (i = 0; i < ARRAY_SIZE(SiSHostChipInfo) && !chipset_family; i++) { - host = pci_find_device(PCI_VENDOR_ID_SI, SiSHostChipInfo[i].host_id, NULL); + host = pci_get_device(PCI_VENDOR_ID_SI, SiSHostChipInfo[i].host_id, NULL); if (!host) continue; @@ -752,6 +752,7 @@ static unsigned int __devinit init_chips printk(KERN_INFO "SIS5513: %s %s controller\n", SiSHostChipInfo[i].name, chipset_capability[chipset_family]); + pci_dev_put(host); } if (!chipset_family) { /* Belongs to pci-quirks */ diff --git a/drivers/ide/pci/via82cxxx.c b/drivers/ide/pci/via82cxxx.c --- a/drivers/ide/pci/via82cxxx.c +++ b/drivers/ide/pci/via82cxxx.c @@ -427,7 +427,7 @@ static unsigned int __devinit init_chips */ for (via_config = via_isa_bridges; via_config->id; via_config++) - if ((isa = pci_find_device(PCI_VENDOR_ID_VIA + + if ((isa = pci_get_device(PCI_VENDOR_ID_VIA + !!(via_config->flags & VIA_BAD_ID), via_config->id, NULL))) { @@ -435,6 +435,7 @@ static unsigned int __devinit init_chips if (t >= via_config->rev_min && t <= via_config->rev_max) break; + pci_dev_put(isa); } if (!via_config->id) { @@ -572,6 +573,8 @@ static unsigned int __devinit init_chips ide_pci_create_host_proc("via", via_get_info); via_proc = 1; } +#else + pci_dev_put(isa); #endif /* DISPLAY_VIA_TIMINGS && CONFIG_PROC_FS */ return 0; } @@ -646,9 +649,18 @@ static struct pci_driver driver = { static int via_ide_init(void) { + isa_dev = NULL; return ide_pci_register_driver(&driver); } +#ifdef MODULE +static void __exit via_ide_exit() +{ + pci_dev_put(isa_dev); +} +module_exit(via_ide_exit); +#endif + module_init(via_ide_init); MODULE_AUTHOR("Vojtech Pavlik, Michel Aubry, Jeff Garzik, Andre Hedrick"); diff --git a/drivers/ide/setup-pci.c b/drivers/ide/setup-pci.c --- a/drivers/ide/setup-pci.c +++ b/drivers/ide/setup-pci.c @@ -878,9 +878,8 @@ void __init ide_scan_pcibus (int scan_di pre_init = 0; if (!scan_direction) { - while ((dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + for_each_pci_dev(dev) ide_scan_pcidev(dev); - } } else { while ((dev = pci_find_device_reverse(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { ide_scan_pcidev(dev); diff --git a/drivers/isdn/hisax/avm_pci.c b/drivers/isdn/hisax/avm_pci.c --- a/drivers/isdn/hisax/avm_pci.c +++ b/drivers/isdn/hisax/avm_pci.c @@ -794,16 +794,20 @@ setup_avm_pcipnp(struct IsdnCard *card) } #endif #ifdef CONFIG_PCI - if ((dev_avm = pci_find_device(PCI_VENDOR_ID_AVM, + if ((dev_avm = pci_get_device(PCI_VENDOR_ID_AVM, PCI_DEVICE_ID_AVM_A1, dev_avm))) { - if (pci_enable_device(dev_avm)) + if (pci_enable_device(dev_avm)) { + pci_dev_put(dev_avm); return(0); + } cs->irq = dev_avm->irq; if (!cs->irq) { printk(KERN_ERR "FritzPCI: No IRQ for PCI card found\n"); + pci_dev_put(dev_avm); return(0); } cs->hw.avm.cfg_reg = pci_resource_start(dev_avm, 1); + pci_dev_put(dev_avm); if (!cs->hw.avm.cfg_reg) { printk(KERN_ERR "FritzPCI: No IO-Adr for PCI card found\n"); return(0); diff --git a/drivers/isdn/hisax/bkm_a4t.c b/drivers/isdn/hisax/bkm_a4t.c --- a/drivers/isdn/hisax/bkm_a4t.c +++ b/drivers/isdn/hisax/bkm_a4t.c @@ -276,7 +276,7 @@ setup_bkm_a4t(struct IsdnCard *card) return (0); #ifdef CONFIG_PCI - while ((dev_a4t = pci_find_device(PCI_VENDOR_ID_ZORAN, + while ((dev_a4t = pci_get_device(PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120, dev_a4t))) { u16 sub_sys; u16 sub_vendor; diff --git a/drivers/isdn/hisax/bkm_a8.c b/drivers/isdn/hisax/bkm_a8.c --- a/drivers/isdn/hisax/bkm_a8.c +++ b/drivers/isdn/hisax/bkm_a8.c @@ -311,7 +311,7 @@ setup_sct_quadro(struct IsdnCard *card) (sub_vendor_id != PCI_VENDOR_ID_BERKOM))) return (0); if (cs->subtyp == SCT_1) { - while ((dev_a8 = pci_find_device(PCI_VENDOR_ID_PLX, + while ((dev_a8 = pci_get_device(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, dev_a8))) { sub_vendor_id = dev_a8->subsystem_vendor; diff --git a/drivers/isdn/hisax/diva.c b/drivers/isdn/hisax/diva.c --- a/drivers/isdn/hisax/diva.c +++ b/drivers/isdn/hisax/diva.c @@ -1029,21 +1029,21 @@ setup_diva(struct IsdnCard *card) #endif #ifdef CONFIG_PCI cs->subtyp = 0; - if ((dev_diva = pci_find_device(PCI_VENDOR_ID_EICON, + if ((dev_diva = pci_get_device(PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA20, dev_diva))) { if (pci_enable_device(dev_diva)) return(0); cs->subtyp = DIVA_PCI; cs->irq = dev_diva->irq; cs->hw.diva.cfg_reg = pci_resource_start(dev_diva, 2); - } else if ((dev_diva_u = pci_find_device(PCI_VENDOR_ID_EICON, + } else if ((dev_diva_u = pci_get_device(PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA20_U, dev_diva_u))) { if (pci_enable_device(dev_diva_u)) return(0); cs->subtyp = DIVA_PCI; cs->irq = dev_diva_u->irq; cs->hw.diva.cfg_reg = pci_resource_start(dev_diva_u, 2); - } else if ((dev_diva201 = pci_find_device(PCI_VENDOR_ID_EICON, + } else if ((dev_diva201 = pci_get_device(PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA201, dev_diva201))) { if (pci_enable_device(dev_diva201)) return(0); @@ -1053,7 +1053,7 @@ setup_diva(struct IsdnCard *card) (ulong) ioremap(pci_resource_start(dev_diva201, 0), 4096); cs->hw.diva.cfg_reg = (ulong) ioremap(pci_resource_start(dev_diva201, 1), 4096); - } else if ((dev_diva202 = pci_find_device(PCI_VENDOR_ID_EICON, + } else if ((dev_diva202 = pci_get_device(PCI_VENDOR_ID_EICON, PCI_DEVICE_ID_EICON_DIVA202, dev_diva202))) { if (pci_enable_device(dev_diva202)) return(0); diff --git a/drivers/isdn/hisax/elsa.c b/drivers/isdn/hisax/elsa.c --- a/drivers/isdn/hisax/elsa.c +++ b/drivers/isdn/hisax/elsa.c @@ -1023,7 +1023,7 @@ setup_elsa(struct IsdnCard *card) } else if (cs->typ == ISDN_CTYPE_ELSA_PCI) { #ifdef CONFIG_PCI cs->subtyp = 0; - if ((dev_qs1000 = pci_find_device(PCI_VENDOR_ID_ELSA, + if ((dev_qs1000 = pci_get_device(PCI_VENDOR_ID_ELSA, PCI_DEVICE_ID_ELSA_MICROLINK, dev_qs1000))) { if (pci_enable_device(dev_qs1000)) return(0); @@ -1031,7 +1031,7 @@ setup_elsa(struct IsdnCard *card) cs->irq = dev_qs1000->irq; cs->hw.elsa.cfg = pci_resource_start(dev_qs1000, 1); cs->hw.elsa.base = pci_resource_start(dev_qs1000, 3); - } else if ((dev_qs3000 = pci_find_device(PCI_VENDOR_ID_ELSA, + } else if ((dev_qs3000 = pci_get_device(PCI_VENDOR_ID_ELSA, PCI_DEVICE_ID_ELSA_QS3000, dev_qs3000))) { if (pci_enable_device(dev_qs3000)) return(0); diff --git a/drivers/isdn/hisax/enternow_pci.c b/drivers/isdn/hisax/enternow_pci.c --- a/drivers/isdn/hisax/enternow_pci.c +++ b/drivers/isdn/hisax/enternow_pci.c @@ -324,7 +324,7 @@ setup_enternow_pci(struct IsdnCard *card for ( ;; ) { - if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET, + if ((dev_netjet = pci_get_device(PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) { if (pci_enable_device(dev_netjet)) return(0); @@ -342,9 +342,9 @@ setup_enternow_pci(struct IsdnCard *card if ((dev_netjet->subsystem_vendor != 0x55) || (dev_netjet->subsystem_device != 0x02)) { printk(KERN_WARNING "enter:now: You tried to load this driver with an incompatible TigerJet-card\n"); - printk(KERN_WARNING "Use type=20 for Traverse NetJet PCI Card.\n"); - return(0); - } + printk(KERN_WARNING "Use type=20 for Traverse NetJet PCI Card.\n"); + return(0); + } } else { printk(KERN_WARNING "enter:now PCI: No PCI card found\n"); return(0); diff --git a/drivers/isdn/hisax/gazel.c b/drivers/isdn/hisax/gazel.c --- a/drivers/isdn/hisax/gazel.c +++ b/drivers/isdn/hisax/gazel.c @@ -547,7 +547,7 @@ setup_gazelpci(struct IsdnCardState *cs) found = 0; seekcard = PCI_DEVICE_ID_PLX_R685; for (nbseek = 0; nbseek < 3; nbseek++) { - if ((dev_tel = pci_find_device(PCI_VENDOR_ID_PLX, seekcard, dev_tel))) { + if ((dev_tel = pci_get_device(PCI_VENDOR_ID_PLX, seekcard, dev_tel))) { if (pci_enable_device(dev_tel)) return 1; pci_irq = dev_tel->irq; diff --git a/drivers/isdn/hisax/hfc_pci.c b/drivers/isdn/hisax/hfc_pci.c --- a/drivers/isdn/hisax/hfc_pci.c +++ b/drivers/isdn/hisax/hfc_pci.c @@ -1661,16 +1661,22 @@ setup_hfcpci(struct IsdnCard *card) if (cs->typ == ISDN_CTYPE_HFC_PCI) { i = 0; while (id_list[i].vendor_id) { - tmp_hfcpci = pci_find_device(id_list[i].vendor_id, + tmp_hfcpci = pci_get_device(id_list[i].vendor_id, id_list[i].device_id, dev_hfcpci); i++; if (tmp_hfcpci) { - if (pci_enable_device(tmp_hfcpci)) + if (pci_enable_device(tmp_hfcpci)) { + pci_dev_put(tmp_hfcpci); +/* XXX shouldn't be here dev_hfcpci=tmp_hfcpci; for pci_get_device's 3rd param + instead of dev_put? */ continue; + } pci_set_master(tmp_hfcpci); - if ((card->para[0]) && (card->para[0] != (tmp_hfcpci->resource[ 0].start & PCI_BASE_ADDRESS_IO_MASK))) + if ((card->para[0]) && (card->para[0] != (tmp_hfcpci->resource[ 0].start & PCI_BASE_ADDRESS_IO_MASK))) { + pci_dev_put(tmp_hfcpci); continue; + } else break; } diff --git a/drivers/isdn/hisax/niccy.c b/drivers/isdn/hisax/niccy.c --- a/drivers/isdn/hisax/niccy.c +++ b/drivers/isdn/hisax/niccy.c @@ -312,7 +312,7 @@ setup_niccy(struct IsdnCard *card) #ifdef CONFIG_PCI u_int pci_ioaddr; cs->subtyp = 0; - if ((niccy_dev = pci_find_device(PCI_VENDOR_ID_SATSAGEM, + if ((niccy_dev = pci_get_device(PCI_VENDOR_ID_SATSAGEM, PCI_DEVICE_ID_SATSAGEM_NICCY, niccy_dev))) { if (pci_enable_device(niccy_dev)) return(0); diff --git a/drivers/isdn/hisax/nj_s.c b/drivers/isdn/hisax/nj_s.c --- a/drivers/isdn/hisax/nj_s.c +++ b/drivers/isdn/hisax/nj_s.c @@ -171,7 +171,7 @@ setup_netjet_s(struct IsdnCard *card) for ( ;; ) { - if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET, + if ((dev_netjet = pci_get_device(PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) { if (pci_enable_device(dev_netjet)) return(0); diff --git a/drivers/isdn/hisax/nj_u.c b/drivers/isdn/hisax/nj_u.c --- a/drivers/isdn/hisax/nj_u.c +++ b/drivers/isdn/hisax/nj_u.c @@ -152,7 +152,7 @@ setup_netjet_u(struct IsdnCard *card) for ( ;; ) { - if ((dev_netjet = pci_find_device(PCI_VENDOR_ID_TIGERJET, + if ((dev_netjet = pci_get_device(PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_300, dev_netjet))) { if (pci_enable_device(dev_netjet)) return(0); diff --git a/drivers/isdn/hisax/sedlbauer.c b/drivers/isdn/hisax/sedlbauer.c --- a/drivers/isdn/hisax/sedlbauer.c +++ b/drivers/isdn/hisax/sedlbauer.c @@ -619,7 +619,7 @@ setup_sedlbauer(struct IsdnCard *card) #endif /* Probe for Sedlbauer speed pci */ #ifdef CONFIG_PCI - if ((dev_sedl = pci_find_device(PCI_VENDOR_ID_TIGERJET, + if ((dev_sedl = pci_get_device(PCI_VENDOR_ID_TIGERJET, PCI_DEVICE_ID_TIGERJET_100, dev_sedl))) { if (pci_enable_device(dev_sedl)) return(0); diff --git a/drivers/isdn/hisax/telespci.c b/drivers/isdn/hisax/telespci.c --- a/drivers/isdn/hisax/telespci.c +++ b/drivers/isdn/hisax/telespci.c @@ -301,7 +301,7 @@ setup_telespci(struct IsdnCard *card) if (cs->typ != ISDN_CTYPE_TELESPCI) return (0); #ifdef CONFIG_PCI - if ((dev_tel = pci_find_device (PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120, dev_tel))) { + if ((dev_tel = pci_get_device (PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36120, dev_tel))) { if (pci_enable_device(dev_tel)) return(0); cs->irq = dev_tel->irq; diff --git a/drivers/isdn/hisax/w6692.c b/drivers/isdn/hisax/w6692.c --- a/drivers/isdn/hisax/w6692.c +++ b/drivers/isdn/hisax/w6692.c @@ -1014,7 +1014,7 @@ setup_w6692(struct IsdnCard *card) return (0); #ifdef CONFIG_PCI while (id_list[id_idx].vendor_id) { - dev_w6692 = pci_find_device(id_list[id_idx].vendor_id, + dev_w6692 = pci_get_device(id_list[id_idx].vendor_id, id_list[id_idx].device_id, dev_w6692); if (dev_w6692) { diff --git a/drivers/isdn/hysdn/hysdn_init.c b/drivers/isdn/hysdn/hysdn_init.c --- a/drivers/isdn/hysdn/hysdn_init.c +++ b/drivers/isdn/hysdn/hysdn_init.c @@ -78,13 +78,14 @@ search_cards(void) card_root = NULL; card_last = NULL; - while ((akt_pcidev = pci_find_device(PCI_VENDOR_ID_HYPERCOPE, PCI_DEVICE_ID_HYPERCOPE_PLX, - akt_pcidev)) != NULL) { + while ((akt_pcidev = pci_get_device(PCI_VENDOR_ID_HYPERCOPE, + PCI_DEVICE_ID_HYPERCOPE_PLX, akt_pcidev)) != NULL) { if (pci_enable_device(akt_pcidev)) continue; if (!(card = kmalloc(sizeof(hysdn_card), GFP_KERNEL))) { printk(KERN_ERR "HYSDN: unable to alloc device mem \n"); + pci_dev_put(akt_pcidev); return; } memset(card, 0, sizeof(hysdn_card)); diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c @@ -2139,9 +2139,9 @@ pbook_alloc_pci_save(void) struct pci_dev *pd = NULL; npci = 0; - while ((pd = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) { + for_each_pci_dev(pd) ++npci; - } + if (npci == 0) return; pbook_pci_saves = (struct pci_save *) @@ -2169,9 +2169,11 @@ pbook_pci_save(void) if (ps == NULL) return; - while ((pd = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) { - if (npci-- == 0) + for_each_pci_dev(pd) { + if (npci-- == 0) { + pci_dev_put(pd); return; + } #ifndef HACKED_PCI_SAVE pci_read_config_word(pd, PCI_COMMAND, &ps->command); pci_read_config_word(pd, PCI_CACHE_LINE_SIZE, &ps->cache_lat); @@ -2199,18 +2201,22 @@ pbook_pci_restore(void) int npci = pbook_npci_saves; int j; - while ((pd = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) { + for_each_pci_dev(pd) { #ifdef HACKED_PCI_SAVE int i; - if (npci-- == 0) + if (npci-- == 0) { + pci_dev_put(pd); return; + } ps++; for (i=2;i<16;i++) pci_write_config_dword(pd, i<<4, ps->config[i]); pci_write_config_dword(pd, 4, ps->config[1]); #else - if (npci-- == 0) + if (npci-- == 0) { + pci_dev_put(pd); return; + } ps++; if (ps->command == 0) continue; diff --git a/drivers/macintosh/via-pmu68k.c b/drivers/macintosh/via-pmu68k.c --- a/drivers/macintosh/via-pmu68k.c +++ b/drivers/macintosh/via-pmu68k.c @@ -843,7 +843,7 @@ pbook_pci_save(void) struct pci_save *ps; npci = 0; - while ((pd = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) + for_each_pci_dev(pd) ++npci; n_pbook_pci_saves = npci; if (npci == 0) @@ -854,7 +854,7 @@ pbook_pci_save(void) return; pd = NULL; - while ((pd = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) { + for_each_pci_dev(pd) { pci_read_config_word(pd, PCI_COMMAND, &ps->command); pci_read_config_word(pd, PCI_CACHE_LINE_SIZE, &ps->cache_lat); pci_read_config_word(pd, PCI_INTERRUPT_LINE, &ps->intr); @@ -871,7 +871,7 @@ pbook_pci_restore(void) struct pci_dev *pd = NULL; int j; - while ((pd = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pd)) != NULL) { + for_each_pci_dev(pd) { if (ps->command == 0) continue; pci_read_config_word(pd, PCI_COMMAND, &cmd); diff --git a/drivers/media/radio/radio-maestro.c b/drivers/media/radio/radio-maestro.c --- a/drivers/media/radio/radio-maestro.c +++ b/drivers/media/radio/radio-maestro.c @@ -265,11 +265,12 @@ static int __init maestro_radio_init(voi { register __u16 found=0; struct pci_dev *pcidev = NULL; - while(!found && (pcidev = pci_find_device(PCI_VENDOR_ESS, + while(!found && (pcidev = pci_get_device(PCI_VENDOR_ESS, PCI_DEVICE_ID_ESS_ESS1968, pcidev))) found |= radio_install(pcidev); - while(!found && (pcidev = pci_find_device(PCI_VENDOR_ESS, + + while(!found && (pcidev = pci_get_device(PCI_VENDOR_ESS, PCI_DEVICE_ID_ESS_ESS1978, pcidev))) found |= radio_install(pcidev); @@ -277,6 +278,7 @@ static int __init maestro_radio_init(voi printk(KERN_INFO "radio-maestro: no devices found.\n"); return -ENODEV; } + pci_dev_put(pcidev); return 0; } diff --git a/drivers/media/video/bttv-cards.c b/drivers/media/video/bttv-cards.c --- a/drivers/media/video/bttv-cards.c +++ b/drivers/media/video/bttv-cards.c @@ -4306,7 +4306,7 @@ void __devinit bttv_check_chipset(void) if (UNSET != latency) printk(KERN_INFO "bttv: pci latency fixup [%d]\n",latency); - while ((dev = pci_find_device(PCI_VENDOR_ID_INTEL, + while ((dev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, dev))) { unsigned char b; pci_read_config_byte(dev, 0x53, &b); diff --git a/drivers/media/video/stradis.c b/drivers/media/video/stradis.c --- a/drivers/media/video/stradis.c +++ b/drivers/media/video/stradis.c @@ -2177,6 +2177,7 @@ static void release_saa(void) pci_read_config_byte(saa->dev, PCI_COMMAND, &command); command &= ~PCI_COMMAND_MASTER; pci_write_config_byte(saa->dev, PCI_COMMAND, command); + pci_dev_put(saa->dev); /* unmap and free memory */ saa->audhead = saa->audtail = saa->osdhead = 0; @@ -2224,7 +2225,7 @@ static int __init stradis_init (void) saa_num = 0; - while ((dev = pci_find_device(PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA7146, dev))) { + while ((dev = pci_get_device(PCI_VENDOR_ID_PHILIPS, PCI_DEVICE_ID_PHILIPS_SAA7146, dev))) { if (!dev->subsystem_vendor) printk(KERN_INFO "stradis%d: rev1 decoder\n", saa_num); else diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c --- a/drivers/media/video/zoran_card.c +++ b/drivers/media/video/zoran_card.c @@ -1199,7 +1199,7 @@ find_zr36057 (void) zoran_num = 0; while (zoran_num < BUZ_MAX && (dev = - pci_find_device(PCI_VENDOR_ID_ZORAN, + pci_get_device(PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36057, dev)) != NULL) { card_num = card[zoran_num]; zr = &zoran[zoran_num]; diff --git a/drivers/media/video/zr36120.c b/drivers/media/video/zr36120.c --- a/drivers/media/video/zr36120.c +++ b/drivers/media/video/zr36120.c @@ -1839,14 +1839,15 @@ int __init find_zoran(void) unsigned char revision; int zoran_num=0; - while ((dev = pci_find_device(PCI_VENDOR_ID_ZORAN,PCI_DEVICE_ID_ZORAN_36120, dev))) - { + while ((dev = pci_get_device(PCI_VENDOR_ID_ZORAN,PCI_DEVICE_ID_ZORAN_36120, dev))) { /* Ok, a ZR36120/ZR36125 found! */ ztv = &zorans[zoran_num]; ztv->dev = dev; - if (pci_enable_device(dev)) + if (pci_enable_device(dev)) { + pci_dev_put(dev); return -EIO; + } pci_read_config_byte(dev, PCI_CLASS_REVISION, &revision); printk(KERN_INFO "zoran: Zoran %x (rev %d) ", @@ -1864,12 +1865,14 @@ int __init find_zoran(void) { iounmap(ztv->zoran_mem); printk(KERN_ERR "zoran: Bad irq number or handler\n"); + pci_dev_put(dev); return -EINVAL; } if (result==-EBUSY) printk(KERN_ERR "zoran: IRQ %d busy, change your PnP config in BIOS\n",dev->irq); if (result < 0) { iounmap(ztv->zoran_mem); + pci_dev_put(dev); return result; } /* Enable bus-mastering */ diff --git a/drivers/mtd/devices/pmc551.c b/drivers/mtd/devices/pmc551.c --- a/drivers/mtd/devices/pmc551.c +++ b/drivers/mtd/devices/pmc551.c @@ -678,13 +678,10 @@ static int __init init_pmc551(void) /* * PCU-bus chipset probe. */ - for( count = 0; count < MAX_MTD_DEVICES; count++ ) { - - if ((PCI_Device = pci_find_device(PCI_VENDOR_ID_V3_SEMI, - PCI_DEVICE_ID_V3_SEMI_V370PDC, - PCI_Device ) ) == NULL) { - break; - } + for( count = 0; count < MAX_MTD_DEVICES; count++ ) { + if ((PCI_Device = pci_get_device(PCI_VENDOR_ID_V3_SEMI, + PCI_DEVICE_ID_V3_SEMI_V370PDC, PCI_Device )) == NULL) + break; printk(KERN_NOTICE "pmc551: Found PCI V370PDC at 0x%lX\n", PCI_Device->resource[0].start); @@ -699,6 +696,7 @@ static int __init init_pmc551(void) */ if((length = fixup_pmc551(PCI_Device)) <= 0) { printk(KERN_NOTICE "pmc551: Cannot init SDRAM\n"); + pci_dev_put(PCI_Device); break; } @@ -747,6 +745,7 @@ static int __init init_pmc551(void) if (!priv->start) { printk(KERN_NOTICE "pmc551: Unable to map IO space\n"); + pci_dev_put(priv->dev); kfree(mtd->priv); kfree(mtd); break; @@ -784,6 +783,7 @@ static int __init init_pmc551(void) if (add_mtd_device(mtd)) { printk(KERN_NOTICE "pmc551: Failed to register new device\n"); iounmap(priv->start); + pci_dev_put(priv->dev); kfree(mtd->priv); kfree(mtd); break; @@ -829,6 +829,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); diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c --- a/drivers/mtd/maps/amd76xrom.c +++ b/drivers/mtd/maps/amd76xrom.c @@ -58,6 +58,7 @@ static void amd76xrom_cleanup(struct amd /* Disable writes through the rom window */ pci_read_config_byte(window->pdev, 0x40, &byte); pci_write_config_byte(window->pdev, 0x40, byte & ~1); + pci_dev_put(window->pdev); } /* Free all of the mtd devices */ @@ -304,7 +305,7 @@ static int __init init_amd76xrom(void) struct pci_device_id *id; pdev = NULL; for(id = amd76xrom_pci_tbl; id->vendor; id++) { - pdev = pci_find_device(id->vendor, id->device, NULL); + pdev = pci_get_device(id->vendor, id->device, NULL); if (pdev) { break; } diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c --- a/drivers/mtd/maps/ichxrom.c +++ b/drivers/mtd/maps/ichxrom.c @@ -62,6 +62,7 @@ static void ichxrom_cleanup(struct ichxr /* Disable writes through the rom window */ pci_read_config_word(window->pdev, BIOS_CNTL, &word); pci_write_config_word(window->pdev, BIOS_CNTL, word & ~1); + pci_dev_put(window->pdev); /* Free all of the mtd devices */ list_for_each_entry_safe(map, scratch, &window->maps, list) { @@ -356,7 +357,7 @@ static int __init init_ichxrom(void) pdev = NULL; for (id = ichxrom_pci_tbl; id->vendor; id++) { - pdev = pci_find_device(id->vendor, id->device, NULL); + pdev = pci_get_device(id->vendor, id->device, NULL); if (pdev) { break; } diff --git a/drivers/mtd/maps/l440gx.c b/drivers/mtd/maps/l440gx.c --- a/drivers/mtd/maps/l440gx.c +++ b/drivers/mtd/maps/l440gx.c @@ -62,14 +62,16 @@ static int __init init_l440gx(void) struct resource *pm_iobase; __u16 word; - dev = pci_find_device(PCI_VENDOR_ID_INTEL, + dev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_0, NULL); - pm_dev = pci_find_device(PCI_VENDOR_ID_INTEL, + pm_dev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL); if (!dev || !pm_dev) { printk(KERN_NOTICE "L440GX flash mapping: failed to find PIIX4 ISA bridge, cannot continue\n"); + pci_dev_put(dev); + pci_dev_put(pm_dev); return -ENODEV; } @@ -77,6 +79,8 @@ static int __init init_l440gx(void) if (!l440gx_map.virt) { printk(KERN_WARNING "Failed to ioremap L440GX flash region\n"); + pci_dev_put(dev); + pci_dev_put(pm_dev); return -ENOMEM; } simple_map_init(&l440gx_map); @@ -104,6 +108,8 @@ static int __init init_l440gx(void) if (pci_assign_resource(pm_dev, PIIXE_IOBASE_RESOURCE) != 0) { printk(KERN_WARNING "Could not allocate pm iobase resource\n"); iounmap(l440gx_map.virt); + pci_dev_put(dev); + pci_dev_put(pm_dev); return -ENXIO; } } @@ -134,10 +140,14 @@ static int __init init_l440gx(void) mymtd->owner = THIS_MODULE; add_mtd_device(mymtd); + pci_dev_put(dev); + pci_dev_put(pm_dev); return 0; } iounmap(l440gx_map.virt); + pci_dev_put(dev); + pci_dev_put(pm_dev); return -ENXIO; } 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; } diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c @@ -3660,10 +3660,9 @@ e1000_notify_reboot(struct notifier_bloc case SYS_DOWN: case SYS_HALT: case SYS_POWER_OFF: - while((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev))) { + for_each_pci_dev(pdev) if(pci_dev_driver(pdev) == &e1000_driver) e1000_suspend(pdev, 3); - } } return NOTIFY_DONE; } diff --git a/drivers/net/gt96100eth.c b/drivers/net/gt96100eth.c --- a/drivers/net/gt96100eth.c +++ b/drivers/net/gt96100eth.c @@ -19,7 +19,9 @@ * Ethernet driver for the MIPS GT96100 Advanced Communication Controller. * * Revision history - * + * + * 27.05.2005 Obsolete pci_find_device changed to pci_get_device. + * * 11.11.2001 Moved to 2.4.14, ppopov@mvista.com. Modified driver to add * proper gt96100A support. * 12.05.2001 Moved eth port 0 to irq 3 (mapped to GT_SERINT0 on EV96100A) @@ -615,10 +617,10 @@ static int gt96100_init_module(void) /* * Stupid probe because this really isn't a PCI device */ - if (!(pci = pci_find_device(PCI_VENDOR_ID_MARVELL, - PCI_DEVICE_ID_MARVELL_GT96100, NULL)) && - !(pci = pci_find_device(PCI_VENDOR_ID_MARVELL, - PCI_DEVICE_ID_MARVELL_GT96100A, NULL))) { + if (!(pci = pci_get_device(PCI_VENDOR_ID_MARVELL, + PCI_DEVICE_ID_MARVELL_GT96100, NULL)) && + !(pci = pci_get_device(PCI_VENDOR_ID_MARVELL, + PCI_DEVICE_ID_MARVELL_GT96100A, NULL))) { printk(KERN_ERR __FILE__ ": GT96100 not found!\n"); return -ENODEV; } @@ -627,12 +629,15 @@ static int gt96100_init_module(void) if (cpuConfig & (1<<12)) { printk(KERN_ERR __FILE__ ": must be in Big Endian mode!\n"); + pci_dev_put(pci); return -ENODEV; } for (i=0; i < NUM_INTERFACES; i++) retval |= gt96100_probe1(pci, i); + pci_dev_put(pci); + return retval; } diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c @@ -6,6 +6,8 @@ * Copyright (C) 1996, 1998, 1999, 2002, 2003 David S. Miller (davem@redhat.com) * * Changes : + * 2005/05/27 Jiri Slaby + * - obsolete pci_find_device changed to pci_get_device * 2000/11/11 Willy Tarreau * - port to non-sparc architectures. Tested only on x86 and * only currently works with QFE PCI cards. @@ -3318,7 +3320,7 @@ static int __init happy_meal_pci_probe(v struct pci_dev *pdev = NULL; int cards = 0; - while ((pdev = pci_find_device(PCI_VENDOR_ID_SUN, + while ((pdev = pci_get_device(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_HAPPYMEAL, pdev)) != NULL) { if (pci_enable_device(pdev)) continue; @@ -3398,6 +3400,7 @@ static void __exit happy_meal_cleanup_mo hp->hblock_dvma); iounmap(hp->gregs); pci_release_regions(hp->happy_dev); + pci_dev_put(hp->happy_dev); } #endif free_netdev(dev); diff --git a/drivers/net/wan/sdladrv.c b/drivers/net/wan/sdladrv.c --- a/drivers/net/wan/sdladrv.c +++ b/drivers/net/wan/sdladrv.c @@ -13,6 +13,8 @@ * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * ============================================================================ +* Mar 27, 2005 Jiri Slaby Obsolete pci_find_device changed to +* pci_get_device * Mar 20, 2001 Nenad Corbic Added the auto_pci_cfg filed, to support * the PCISLOT #0. * Apr 04, 2000 Nenad Corbic Fixed the auto memory detection code. @@ -2032,8 +2034,7 @@ static int find_s514_adapter(sdlahw_t* h slot_no = hw->S514_slot_no; - while ((pci_dev = pci_find_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_dev)) - != NULL) { + while ((pci_dev = pci_get_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_dev))) { pci_read_config_word(pci_dev, PCI_SUBSYS_VENDOR_WORD, &PCI_subsys_vendor); @@ -2066,6 +2067,7 @@ static int find_s514_adapter(sdlahw_t* h /* if no S514 adapter has been found, then exit */ if (!number_S514_cards) { printk(KERN_INFO "%s: Error, no S514 adapters found\n", modname); + pci_dev_put(pci_dev); return 0; } /* if more than one S514 card has been found, then the user must have */ /* defined a slot number so that the correct adapter is used */ @@ -2075,6 +2077,7 @@ static int find_s514_adapter(sdlahw_t* h "%s: Disable the Autodetect feature and supply\n" "%s: the PCISLOT numbers for each card.\n", modname,modname,modname,modname); + pci_dev_put(pci_dev); return 0; } /* if the user has specified a slot number and the S514 adapter has */ @@ -2083,6 +2086,7 @@ static int find_s514_adapter(sdlahw_t* h printk(KERN_INFO "%s: Error, S514 card not found in specified slot #%d\n", modname, slot_no); + pci_dev_put(pci_dev); return 0; } @@ -2245,8 +2249,7 @@ static int pci_probe(sdlahw_t *hw) slot_no = 0; - while ((pci_dev = pci_find_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_dev)) - != NULL) { + while (pci_dev = pci_get_device(V3_VENDOR_ID, V3_DEVICE_ID, pci_dev)) { pci_read_config_word(pci_dev, PCI_SUBSYS_VENDOR_WORD, &PCI_subsys_vendor); diff --git a/drivers/parport/parport_pc.c b/drivers/parport/parport_pc.c --- a/drivers/parport/parport_pc.c +++ b/drivers/parport/parport_pc.c @@ -3007,7 +3007,7 @@ static int __init parport_pc_init_superi struct pci_dev *pdev = NULL; int ret = 0; - while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) { + for_each_pci_dev(pdev) { id = pci_match_id(parport_pc_pci_tbl, pdev); if (id == NULL || id->driver_data >= last_sio) continue; diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c --- a/drivers/pci/hotplug/fakephp.c +++ b/drivers/pci/hotplug/fakephp.c @@ -144,7 +144,7 @@ static int __init pci_scan_buses(void) struct pci_dev *dev = NULL; int retval = 0; - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + for_each_pci_dev(dev) { retval = add_slot(dev); if (retval) { pci_dev_put(dev); diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -774,9 +774,9 @@ static int __devinit pci_init(void) { struct pci_dev *dev = NULL; - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + for_each_pci_dev(dev) pci_fixup_device(pci_fixup_final, dev); - } + return 0; } diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c --- a/drivers/pci/proc.c +++ b/drivers/pci/proc.c @@ -609,9 +609,10 @@ static int __init pci_proc_init(void) if (entry) entry->proc_fops = &proc_bus_pci_dev_operations; proc_initialized = 1; - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + + for_each_pci_dev(dev) pci_proc_attach_device(dev); - } + legacy_proc_init(); return 0; } diff --git a/drivers/pci/setup-irq.c b/drivers/pci/setup-irq.c --- a/drivers/pci/setup-irq.c +++ b/drivers/pci/setup-irq.c @@ -58,7 +58,7 @@ pci_fixup_irqs(u8 (*swizzle)(struct pci_ int (*map_irq)(struct pci_dev *, u8, u8)) { struct pci_dev *dev = NULL; - while ((dev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, dev)) != NULL) { + + for_each_pci_dev(dev) pdev_fixup_irq(dev, swizzle, map_irq); - } } diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c @@ -661,7 +661,7 @@ static int __init BusLogic_InitializeMul particular standard ISA I/O Address need not be probed. */ PrimaryProbeInfo->IO_Address = 0; - while ((PCI_Device = pci_find_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, PCI_Device)) != NULL) { + while ((PCI_Device = pci_get_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER, PCI_Device)) != NULL) { struct BusLogic_HostAdapter *HostAdapter = PrototypeHostAdapter; struct BusLogic_PCIHostAdapterInformation PCIHostAdapterInformation; enum BusLogic_ISACompatibleIOPort ModifyIOAddressRequest; @@ -822,7 +822,7 @@ static int __init BusLogic_InitializeMul noting the PCI bus location and assigned IRQ Channel. */ PCI_Device = NULL; - while ((PCI_Device = pci_find_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC, PCI_Device)) != NULL) { + while ((PCI_Device = pci_get_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_MULTIMASTER_NC, PCI_Device)) != NULL) { unsigned char Bus; unsigned char Device; unsigned int IRQ_Channel; @@ -873,7 +873,7 @@ static int __init BusLogic_InitializeFla /* Interrogate PCI Configuration Space for any FlashPoint Host Adapters. */ - while ((PCI_Device = pci_find_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT, PCI_Device)) != NULL) { + while ((PCI_Device = pci_get_device(PCI_VENDOR_ID_BUSLOGIC, PCI_DEVICE_ID_BUSLOGIC_FLASHPOINT, PCI_Device)) != NULL) { unsigned char Bus; unsigned char Device; unsigned int IRQ_Channel; diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c --- a/drivers/scsi/advansys.c +++ b/drivers/scsi/advansys.c @@ -4472,7 +4472,7 @@ advansys_detect(struct scsi_host_templat /* Find all PCI cards. */ while (pci_device_id_cnt < ASC_PCI_DEVICE_ID_CNT) { - if ((pci_devp = pci_find_device(ASC_PCI_VENDORID, + if ((pci_devp = pci_get_device(ASC_PCI_VENDORID, pci_device_id[pci_device_id_cnt], pci_devp)) == NULL) { pci_device_id_cnt++; @@ -5433,6 +5433,10 @@ advansys_detect(struct scsi_host_templat } } + for (pci_card_cnt = 0; pci_card_cnt < pci_card_cnt_max; pci_card_cnt++) + pci_dev_put(pci_devicep[pci_card_cnt]); + + ASC_DBG1(1, "advansys_detect: done: asc_board_count %d\n", asc_board_count); return asc_board_count; } diff --git a/drivers/scsi/aic7xxx_old.c b/drivers/scsi/aic7xxx_old.c --- a/drivers/scsi/aic7xxx_old.c +++ b/drivers/scsi/aic7xxx_old.c @@ -9198,7 +9198,7 @@ aic7xxx_detect(Scsi_Host_Template *templ for (i = 0; i < ARRAY_SIZE(aic_pdevs); i++) { pdev = NULL; - while ((pdev = pci_find_device(aic_pdevs[i].vendor_id, + while ((pdev = pci_get_device(aic_pdevs[i].vendor_id, aic_pdevs[i].device_id, pdev))) { if (pci_enable_device(pdev)) diff --git a/drivers/scsi/cpqfcTSinit.c b/drivers/scsi/cpqfcTSinit.c --- a/drivers/scsi/cpqfcTSinit.c +++ b/drivers/scsi/cpqfcTSinit.c @@ -298,7 +298,7 @@ int cpqfcTS_detect(Scsi_Host_Template *S { // look for all HBAs of each type - while((PciDev = pci_find_device(cpqfc_boards[i].vendor_id, + while((PciDev = pci_get_device(cpqfc_boards[i].vendor_id, cpqfc_boards[i].device_id, PciDev))) { @@ -459,6 +459,7 @@ int cpqfcTS_detect(Scsi_Host_Template *S NumberOfAdapters++; spin_unlock_irq(HostAdapter->host_lock); + pci_dev_put(PciDev); continue; err_release_region_L: @@ -472,6 +473,7 @@ err_unregister: err_disable_dev: pci_disable_device( PciDev ); err_continue: + pci_dev_put(PciDev); continue; } // end of while() } diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c --- a/drivers/scsi/dpt_i2o.c +++ b/drivers/scsi/dpt_i2o.c @@ -183,7 +183,7 @@ static int adpt_detect(struct scsi_host_ PINFO("Detecting Adaptec I2O RAID controllers...\n"); /* search for all Adatpec I2O RAID cards */ - while ((pDev = pci_find_device( PCI_DPT_VENDOR_ID, PCI_ANY_ID, pDev))) { + while ((pDev = pci_get_device( PCI_DPT_VENDOR_ID, PCI_ANY_ID, pDev))) { if(pDev->device == PCI_DPT_DEVICE_ID || pDev->device == PCI_DPT_RAPTOR_DEVICE_ID){ if(adpt_install_hba(sht, pDev) ){ @@ -973,7 +973,7 @@ static int adpt_install_hba(struct scsi_ pHba->status_block = NULL; pHba->post_count = 0; pHba->state = DPTI_STATE_RESET; - pHba->pDev = pDev; +// pHba->pDev = pDev; // this is a few line above this pHba->devices = NULL; // Initializing the spinlocks @@ -1063,6 +1063,7 @@ static void adpt_i2o_delete_hba(adpt_hba } } } + pci_dev_put(pHba->pDev); kfree(pHba); if(hba_count <= 0){ diff --git a/drivers/scsi/eata_pio.c b/drivers/scsi/eata_pio.c --- a/drivers/scsi/eata_pio.c +++ b/drivers/scsi/eata_pio.c @@ -890,7 +890,7 @@ static void find_pio_PCI(struct get_conf struct pci_dev *dev = NULL; u32 base, x; - while ((dev = pci_find_device(PCI_VENDOR_ID_DPT, PCI_DEVICE_ID_DPT, dev)) != NULL) { + while ((dev = pci_get_device(PCI_VENDOR_ID_DPT, PCI_DEVICE_ID_DPT, dev)) != NULL) { DBG(DBG_PROBE && DBG_PCI, printk("eata_pio: find_PCI, HBA at %s\n", pci_name(dev))); if (pci_enable_device(dev)) continue; @@ -901,6 +901,7 @@ static void find_pio_PCI(struct get_conf continue; } base = pci_resource_start(dev, 0); + pci_dev_put(dev); /* EISA tag there ? */ if ((inb(base) == 0x12) && (inb(base + 1) == 0x14)) continue; /* Jep, it's forced, so move on */ diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c --- a/drivers/scsi/fdomain.c +++ b/drivers/scsi/fdomain.c @@ -801,7 +801,7 @@ static int fdomain_pci_bios_detect( int { unsigned int pci_irq; /* PCI interrupt line */ unsigned long pci_base; /* PCI I/O base address */ - struct pci_dev *pdev = NULL; + struct pci_dev *pdev; #if DEBUG_DETECT /* Tell how to print a list of the known PCI devices from bios32 and @@ -814,9 +814,13 @@ static int fdomain_pci_bios_detect( int PCI_DEVICE_ID_FD_36C70 ); #endif - if ((pdev = pci_find_device(PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70, pdev)) == NULL) + if ((pdev = pci_get_device(PCI_VENDOR_ID_FD, PCI_DEVICE_ID_FD_36C70, + NULL)) == NULL) return 0; - if (pci_enable_device(pdev)) return 0; + if (pci_enable_device(pdev)) { + pci_dev_put(pdev); + return 0; + } #if DEBUG_DETECT printk( "scsi: TMC-3260 detect:" @@ -832,8 +836,10 @@ static int fdomain_pci_bios_detect( int pci_base = pci_resource_start(pdev, 0); pci_irq = pdev->irq; - if (!request_region( pci_base, 0x10, "fdomain" )) - return 0; + if (!request_region( pci_base, 0x10, "fdomain" )) { + pci_dev_put(pdev); + return 0; + } /* Now we have the I/O base address and interrupt from the PCI configuration registers. */ @@ -847,11 +853,13 @@ static int fdomain_pci_bios_detect( int " IRQ = %d, I/O base = 0x%x [0x%lx]\n", *irq, *iobase, pci_base ); #endif - if (!fdomain_is_valid_port(pci_base)) { - printk(KERN_ERR "scsi: PCI card detected, but driver not loaded (invalid port)\n" ); - release_region(pci_base, 0x10); - return 0; - } + if (!fdomain_is_valid_port(pci_base)) { + printk(KERN_ERR "scsi: PCI card detected, but driver not " + "loaded (invalid port)\n" ); + release_region(pci_base, 0x10); + pci_dev_put(pdev); + return 0; + } /* Fill in a few global variables. Ugh. */ bios_major = bios_minor = -1; @@ -952,7 +960,7 @@ struct Scsi_Host *__fdomain_16x0_detect( retcode = request_irq( interrupt_level, do_fdomain_16x0_intr, pdev?SA_SHIRQ:0, "fdomain", shpnt); - + pci_dev_put(pdev); if (retcode < 0) { if (retcode == -EINVAL) { printk(KERN_ERR "scsi: IRQ %d is bad!\n", interrupt_level ); diff --git a/drivers/scsi/gdth.c b/drivers/scsi/gdth.c --- a/drivers/scsi/gdth.c +++ b/drivers/scsi/gdth.c @@ -781,12 +781,13 @@ static void __init gdth_search_dev(gdth_ *cnt, vendor, device)); pdev = NULL; - while ((pdev = pci_find_device(vendor, device, pdev)) - != NULL) { + while ((pdev = pci_get_device(vendor, device, pdev)) != NULL) { if (pci_enable_device(pdev)) continue; - if (*cnt >= MAXHA) + if (*cnt >= MAXHA) { + pci_dev_put(pdev); return; + } /* GDT PCI controller found, resources are already in pdev */ pcistr[*cnt].pdev = pdev; pcistr[*cnt].vendor_id = vendor; @@ -4544,6 +4545,8 @@ static int __init gdth_detect(Scsi_Host_ } } + pci_dev_put(pcistr[ctr].pdev); + if (err) { printk("GDT-PCI %d: Error during device scan\n", hanum); --gdth_ctr_count; diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c --- a/drivers/scsi/initio.c +++ b/drivers/scsi/initio.c @@ -108,6 +108,8 @@ * - added new DMA API support * 06/01/04 jmd - v1.04a * - Re-add reset_bus support + * 13/06/05 js - v1.04b + * - Obsolete pci_find_device changed to pci_get_device **************************************************************************/ #include @@ -2772,7 +2774,7 @@ static int tul_NewReturnNumberOfAdapters for (i = 0; i < TULSZ(i91u_pci_devices); i++) { - while ((pDev = pci_find_device(i91u_pci_devices[i].vendor_id, i91u_pci_devices[i].device_id, pDev)) != NULL) { + while ((pDev = pci_get_device(i91u_pci_devices[i].vendor_id, i91u_pci_devices[i].device_id, pDev)) != NULL) { if (pci_enable_device(pDev)) continue; pci_read_config_dword(pDev, 0x44, (u32 *) & dRegValue); diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c --- a/drivers/scsi/qla1280.c +++ b/drivers/scsi/qla1280.c @@ -1220,7 +1220,7 @@ qla1280_detect(Scsi_Host_Template *templ #endif /* First Initialize QLA12160 on PCI Bus 1 Dev 2 */ - while ((pdev = pci_find_device(id->vendor, id->device, pdev))) { + while ((pdev = pci_get_device(id->vendor, id->device, pdev))) { if (pdev->bus->number == 1 && PCI_SLOT(pdev->devfn) == 2) { if (!qla1280_probe_one(pdev, id)) num_hosts++; @@ -1230,7 +1230,7 @@ qla1280_detect(Scsi_Host_Template *templ pdev = NULL; /* Try and find each different type of adapter we support */ for (id = &qla1280_pci_tbl[0]; id->device; id++) { - while ((pdev = pci_find_device(id->vendor, id->device, pdev))) { + while ((pdev = pci_get_device(id->vendor, id->device, pdev))) { /* * skip QLA12160 already initialized on * PCI Bus 1 Dev 2 since we already initialized diff --git a/drivers/scsi/qlogicfc.c b/drivers/scsi/qlogicfc.c --- a/drivers/scsi/qlogicfc.c +++ b/drivers/scsi/qlogicfc.c @@ -732,7 +732,7 @@ static int isp2x00_detect(Scsi_Host_Temp for (i=0; i<2; i++){ pdev = NULL; - while ((pdev = pci_find_device(PCI_VENDOR_ID_QLOGIC, device_ids[i], pdev))) { + while ((pdev = pci_get_device(PCI_VENDOR_ID_QLOGIC, device_ids[i], pdev))) { if (pci_enable_device(pdev)) continue; diff --git a/drivers/scsi/qlogicisp.c b/drivers/scsi/qlogicisp.c --- a/drivers/scsi/qlogicisp.c +++ b/drivers/scsi/qlogicisp.c @@ -680,8 +680,7 @@ static int isp1020_detect(Scsi_Host_Temp tmpt->proc_name = "isp1020"; - while ((pdev = pci_find_device(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1020, pdev))) - { + while ((pdev = pci_get_device(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP1020, pdev))) { if (pci_enable_device(pdev)) continue; diff --git a/drivers/telephony/ixj.c b/drivers/telephony/ixj.c --- a/drivers/telephony/ixj.c +++ b/drivers/telephony/ixj.c @@ -7737,7 +7737,7 @@ static int __init ixj_probe_pci(int *cnt IXJ *j = NULL; for (i = 0; i < IXJMAX - *cnt; i++) { - pci = pci_find_device(0x15E2, 0x0500, pci); + pci = pci_get_device(0x15E2, 0x0500, pci); if (!pci) break; @@ -7756,6 +7756,7 @@ static int __init ixj_probe_pci(int *cnt printk(KERN_INFO "ixj: found Internet PhoneJACK PCI at 0x%x\n", j->DSPbase); ++*cnt; } + pci_dev_put(pci); return probe; } diff --git a/drivers/video/igafb.c b/drivers/video/igafb.c --- a/drivers/video/igafb.c +++ b/drivers/video/igafb.c @@ -388,14 +388,14 @@ int __init igafb_init(void) if (!con_is_present()) return -ENXIO; - pdev = pci_find_device(PCI_VENDOR_ID_INTERG, - PCI_DEVICE_ID_INTERG_1682, 0); + pdev = pci_get_device(PCI_VENDOR_ID_INTERG, + PCI_DEVICE_ID_INTERG_1682, 0); if (pdev == NULL) { /* * XXX We tried to use cyber2000fb.c for IGS 2000. * But it does not initialize the chip in JavaStation-E, alas. */ - pdev = pci_find_device(PCI_VENDOR_ID_INTERG, 0x2000, 0); + pdev = pci_get_device(PCI_VENDOR_ID_INTERG, 0x2000, 0); if(pdev == NULL) { return -ENXIO; } @@ -417,12 +417,14 @@ int __init igafb_init(void) if ((addr = pdev->resource[0].start) == 0) { printk("igafb_init: no memory start\n"); kfree(info); + pci_dev_put(pdev); return -ENXIO; } if ((info->screen_base = ioremap(addr, 1024*1024*2)) == 0) { printk("igafb_init: can't remap %lx[2M]\n", addr); kfree(info); + pci_dev_put(pdev); return -ENXIO; } @@ -457,6 +459,7 @@ int __init igafb_init(void) printk("igafb_init: can't remap %lx[4K]\n", igafb_fix.mmio_start); iounmap((void *)info->screen_base); kfree(info); + pci_dev_put(pdev); return -ENXIO; } @@ -474,6 +477,7 @@ int __init igafb_init(void) iounmap((void *)par->io_base); iounmap(info->screen_base); kfree(info); + pci_dev_put(pdev); return -ENOMEM; } @@ -560,6 +564,8 @@ int __init igafb_init(void) par->mmap_map[1].prot_flag = SRMMU_WRITE; #endif /* __sparc__ */ + pci_dev_put(pdev); + return 0; } diff --git a/drivers/video/pm3fb.c b/drivers/video/pm3fb.c --- a/drivers/video/pm3fb.c +++ b/drivers/video/pm3fb.c @@ -3291,7 +3291,7 @@ static void pm3fb_set_disp(const void *p static void pm3fb_detect(void) { struct pci_dev *dev_array[PM3_MAX_BOARD]; - struct pci_dev *dev = NULL; + struct pci_dev *dev; struct pm3fb_info *l_fb_info = &(fb_info[0]); unsigned long i, j, done; @@ -3302,15 +3302,13 @@ static void pm3fb_detect(void) fb_info[i].dev = NULL; } - dev = - pci_find_device(PCI_VENDOR_ID_3DLABS, - PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev); + dev = pci_get_device(PCI_VENDOR_ID_3DLABS, PCI_DEVICE_ID_3DLABS_PERMEDIA3, + NULL); for (i = 0; ((i < PM3_MAX_BOARD) && dev); i++) { dev_array[i] = dev; - dev = - pci_find_device(PCI_VENDOR_ID_3DLABS, - PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev); + dev = pci_get_device(PCI_VENDOR_ID_3DLABS, + PCI_DEVICE_ID_3DLABS_PERMEDIA3, dev); } if (dev) { /* more than PM3_MAX_BOARD */ @@ -3323,21 +3321,17 @@ static void pm3fb_detect(void) } /* allocate user-defined boards */ - for (i = 0; i < PM3_MAX_BOARD; i++) { - if ((bus[i] >= 0) && (slot[i] >= 0) && (func[i] >= 0)) { + for (i = 0; i < PM3_MAX_BOARD; i++) + if ((bus[i] >= 0) && (slot[i] >= 0) && (func[i] >= 0)) for (j = 0; j < PM3_MAX_BOARD; j++) { - if ((dev_array[j] != NULL) && - (dev_array[j]->bus->number == bus[i]) - && (PCI_SLOT(dev_array[j]->devfn) == - slot[i]) - && (PCI_FUNC(dev_array[j]->devfn) == - func[i])) { - fb_info[i].dev = dev_array[j]; - dev_array[j] = NULL; - } - } - } - } + if (dev_array[j] != NULL) + if ((dev_array[j]->bus->number == bus[i]) + && (PCI_SLOT(dev_array[j]->devfn) == slot[i]) + && (PCI_FUNC(dev_array[j]->devfn) == func[i])) { + fb_info[i].dev = dev_array[j]; + dev_array[j] = NULL; + } else pci_dev_put(dev_array[j]); + /* allocate remaining boards */ for (i = 0; i < PM3_MAX_BOARD; i++) { if (fb_info[i].dev == NULL) { @@ -3639,6 +3633,7 @@ void cleanup_module(void) unregister_framebuffer(&l_fb_info->gen. info); } + pci_dev_put(l_fb_info->dev); } } return; diff --git a/drivers/video/sis/sis_main.c b/drivers/video/sis/sis_main.c --- a/drivers/video/sis/sis_main.c +++ b/drivers/video/sis/sis_main.c @@ -2311,7 +2311,7 @@ static struct pci_dev * sisfb_get_northb default: return NULL; } for(i = 0; i < nbridgenum; i++) { - if((pdev = pci_find_device(PCI_VENDOR_ID_SI, nbridgeids[nbridgeidx+i], NULL))) break; + if ((pdev = pci_get_device(PCI_VENDOR_ID_SI, nbridgeids[nbridgeidx+i], NULL))) break; } return pdev; } @@ -4943,6 +4943,7 @@ static int __devinit sisfb_probe(struct if(pci_enable_device(pdev)) { pci_set_drvdata(pdev, NULL); kfree(sis_fb_info); + pci_dev_put(ivideo->nbridge); return -EIO; } } @@ -4995,14 +4996,16 @@ static int __devinit sisfb_probe(struct #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) #ifdef MODULE - if((reg & 0x80) && (reg != 0xff)) { - if((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) != 0xFF) { - printk(KERN_INFO "sisfb: Cannot initialize display mode, X server is active\n"); - pci_set_drvdata(pdev, NULL); - kfree(sis_fb_info); - return -EBUSY; - } - } + if((reg & 0x80) && (reg != 0xff)) + if((sisbios_mode[ivideo->sisfb_mode_idx].mode_no[ivideo->mni]) + != 0xFF) { + printk(KERN_INFO "sisfb: Cannot initialize display mode, X server " + "is active\n"); + pci_set_drvdata(pdev, NULL); + kfree(sis_fb_info); + pci_dev_put(ivideo->nbridge); + return -EBUSY; + } #endif #endif @@ -5124,6 +5127,7 @@ static int __devinit sisfb_probe(struct if(ivideo->bios_abase) vfree(ivideo->bios_abase); pci_set_drvdata(pdev, NULL); kfree(sis_fb_info); + pci_dev_put(ivideo->nbridge); return -ENODEV; } @@ -5152,6 +5156,7 @@ static int __devinit sisfb_probe(struct if(ivideo->bios_abase) vfree(ivideo->bios_abase); pci_set_drvdata(pdev, NULL); kfree(sis_fb_info); + pci_dev_put(ivideo->nbridge); return -ENODEV; } @@ -5161,6 +5166,7 @@ static int __devinit sisfb_probe(struct if(ivideo->bios_abase) vfree(ivideo->bios_abase); pci_set_drvdata(pdev, NULL); kfree(sis_fb_info); + pci_dev_put(ivideo->nbridge); return -ENODEV; } @@ -5173,6 +5179,7 @@ static int __devinit sisfb_probe(struct if(ivideo->bios_abase) vfree(ivideo->bios_abase); pci_set_drvdata(pdev, NULL); kfree(sis_fb_info); + pci_dev_put(ivideo->nbridge); return -ENODEV; } @@ -5185,6 +5192,7 @@ static int __devinit sisfb_probe(struct if(ivideo->bios_abase) vfree(ivideo->bios_abase); pci_set_drvdata(pdev, NULL); kfree(sis_fb_info); + pci_dev_put(ivideo->nbridge); return -ENODEV; } @@ -5475,6 +5483,7 @@ static int __devinit sisfb_probe(struct if(ivideo->bios_abase) vfree(ivideo->bios_abase); pci_set_drvdata(pdev, NULL); kfree(sis_fb_info); + pci_dev_put(ivideo->nbridge); return -EINVAL; } @@ -5598,6 +5607,7 @@ static int __devinit sisfb_probe(struct if(ivideo->bios_abase) vfree(ivideo->bios_abase); pci_set_drvdata(pdev, NULL); kfree(sis_fb_info); + pci_dev_put(ivideo->nbridge); return -EINVAL; } @@ -5666,6 +5676,8 @@ static void __devexit sisfb_remove(struc pci_set_drvdata(pdev, NULL); + pci_dev_put(ivideo->nbridge); + /* TODO: Restore the initial mode * This sounds easy but is as good as impossible * on many machines with SiS chip and video bridge diff --git a/include/asm-i386/ide.h b/include/asm-i386/ide.h --- a/include/asm-i386/ide.h +++ b/include/asm-i386/ide.h @@ -41,7 +41,12 @@ static __inline__ int ide_default_irq(un static __inline__ unsigned long ide_default_io_base(int index) { - if (pci_find_device(PCI_ANY_ID, PCI_ANY_ID, NULL) == NULL) { + struct pci_dev *pdev = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, NULL); + int a = !pdev; + + pci_dev_put(pdev); + + if (a) { switch(index) { case 2: return 0x1e8; case 3: return 0x168; diff --git a/include/linux/pci.h b/include/linux/pci.h --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -760,9 +760,9 @@ extern void pci_remove_bus_device(struct /* Generic PCI functions exported to card drivers */ -struct pci_dev *pci_find_device (unsigned int vendor, unsigned int device, const struct pci_dev *from); +struct pci_dev *pci_find_device (unsigned int vendor, unsigned int device, const struct pci_dev *from) __deprecated; struct pci_dev *pci_find_device_reverse (unsigned int vendor, unsigned int device, const struct pci_dev *from); -struct pci_dev *pci_find_slot (unsigned int bus, unsigned int devfn); +struct pci_dev * pci_find_slot (unsigned int bus, unsigned int devfn); int pci_find_capability (struct pci_dev *dev, int cap); int pci_find_ext_capability (struct pci_dev *dev, int cap); struct pci_bus * pci_find_next_bus(const struct pci_bus *from); diff --git a/sound/core/memalloc.c b/sound/core/memalloc.c --- a/sound/core/memalloc.c +++ b/sound/core/memalloc.c @@ -566,8 +566,8 @@ static int snd_mem_proc_write(struct fil char *endp; int vendor, device, size, buffers; long mask; - int i, alloced; - struct pci_dev *pci; + int i, alloced = 0; + struct pci_dev *pci = NULL; if ((token = gettoken(&p)) == NULL || (vendor = simple_strtol(token, NULL, 0)) <= 0 || @@ -587,13 +587,12 @@ static int snd_mem_proc_write(struct fil vendor &= 0xffff; device &= 0xffff; - alloced = 0; - pci = NULL; - while ((pci = pci_find_device(vendor, device, pci)) != NULL) { + while ((pci = pci_get_device(vendor, device, pci)) != NULL) { if (mask > 0 && mask < 0xffffffff) { if (pci_set_dma_mask(pci, mask) < 0 || pci_set_consistent_dma_mask(pci, mask) < 0) { printk(KERN_ERR "snd-page-alloc: cannot set DMA mask %lx for pci %04x:%04x\n", mask, vendor, device); + pci_dev_put(pci); return (int)count; } } @@ -603,6 +602,7 @@ static int snd_mem_proc_write(struct fil if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(pci), size, &dmab) < 0) { printk(KERN_ERR "snd-page-alloc: cannot allocate buffer pages (size = %d)\n", size); + pci_dev_put(pci); return (int)count; } snd_dma_reserve_buf(&dmab, snd_dma_pci_buf_id(pci)); diff --git a/sound/oss/cs46xx.c b/sound/oss/cs46xx.c --- a/sound/oss/cs46xx.c +++ b/sound/oss/cs46xx.c @@ -3131,12 +3131,13 @@ static void clkrun_hack(struct cs_card * card->active+=change; - acpi_dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL); + acpi_dev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL); if(acpi_dev == NULL) return; /* Not a thinkpad thats for sure */ /* Find the control port */ pci_read_config_byte(acpi_dev, 0x41, &pp); + pci_dev_put(acpi_dev); port=pp<<8; /* Read ACPI port */ diff --git a/sound/oss/esssolo1.c b/sound/oss/esssolo1.c --- a/sound/oss/esssolo1.c +++ b/sound/oss/esssolo1.c @@ -925,7 +925,7 @@ static int solo1_open_mixdev(struct inod struct solo1_state *s = NULL; struct pci_dev *pci_dev = NULL; - while ((pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL) { + for_each_pci_dev(pci_dev) { struct pci_driver *drvr; drvr = pci_dev_driver (pci_dev); if (drvr != &solo1_driver) @@ -933,8 +933,10 @@ static int solo1_open_mixdev(struct inod s = (struct solo1_state*)pci_get_drvdata(pci_dev); if (!s) continue; - if (s->dev_mixer == minor) + if (s->dev_mixer == minor) { + pci_dev_put(pci_dev); break; + } } if (!s) return -ENODEV; @@ -1607,7 +1609,7 @@ static int solo1_open(struct inode *inod struct solo1_state *s = NULL; struct pci_dev *pci_dev = NULL; - while ((pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL) { + for_each_pci_dev(pci_dev) { struct pci_driver *drvr; drvr = pci_dev_driver(pci_dev); @@ -1616,8 +1618,10 @@ static int solo1_open(struct inode *inod s = (struct solo1_state*)pci_get_drvdata(pci_dev); if (!s) continue; - if (!((s->dev_audio ^ minor) & ~0xf)) + if (!((s->dev_audio ^ minor) & ~0xf)) { + pci_dev_put(pci_dev); break; + } } if (!s) return -ENODEV; @@ -1894,7 +1898,7 @@ static int solo1_midi_open(struct inode struct solo1_state *s = NULL; struct pci_dev *pci_dev = NULL; - while ((pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL) { + for_each_pci_dev(pci_dev) { struct pci_driver *drvr; drvr = pci_dev_driver(pci_dev); @@ -1903,8 +1907,10 @@ static int solo1_midi_open(struct inode s = (struct solo1_state*)pci_get_drvdata(pci_dev); if (!s) continue; - if (s->dev_midi == minor) + if (s->dev_midi == minor) { + pci_dev_put(pci_dev); break; + } } if (!s) return -ENODEV; @@ -2115,7 +2121,7 @@ static int solo1_dmfm_open(struct inode struct solo1_state *s = NULL; struct pci_dev *pci_dev = NULL; - while ((pci_dev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pci_dev)) != NULL) { + for_each_pci_dev(pci_dev) { struct pci_driver *drvr; drvr = pci_dev_driver(pci_dev); @@ -2124,8 +2130,10 @@ static int solo1_dmfm_open(struct inode s = (struct solo1_state*)pci_get_drvdata(pci_dev); if (!s) continue; - if (s->dev_dmfm == minor) + if (s->dev_dmfm == minor) { + pci_dev_put(pci_dev); break; + } } if (!s) return -ENODEV; diff --git a/sound/oss/maestro.c b/sound/oss/maestro.c --- a/sound/oss/maestro.c +++ b/sound/oss/maestro.c @@ -2145,14 +2145,16 @@ static int ess_open_mixdev(struct inode struct pci_dev *pdev = NULL; struct pci_driver *drvr; - while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) { + for_each_pci_dev(pdev) { drvr = pci_dev_driver (pdev); if (drvr == &maestro_pci_driver) { card = (struct ess_card*)pci_get_drvdata (pdev); if (!card) continue; - if (card->dev_mixer == minor) + if (card->dev_mixer == minor) { + pci_dev_put(pdev); break; + } } } if (!card) @@ -2994,7 +2996,7 @@ ess_open(struct inode *inode, struct fil * do this at open time so it is ok */ - while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) { + for_each_pci_dev(pdev) { struct ess_card *c; struct pci_driver *drvr; diff --git a/sound/oss/skeleton.c b/sound/oss/skeleton.c --- a/sound/oss/skeleton.c +++ b/sound/oss/skeleton.c @@ -159,15 +159,18 @@ int init_mycard(void) struct pci_dev *pcidev=NULL; int count=0; - while((pcidev = pci_find_device(PCI_VENDOR_MYIDENT, PCI_DEVICE_ID_MYIDENT_MYCARD1, pcidev))!=NULL) - { + while((pcidev = pci_get_device(PCI_VENDOR_MYIDENT, PCI_DEVICE_ID_MYIDENT_MYCARD1, pcidev)) != NULL) { if (pci_enable_device(pcidev)) continue; count+=mycard_install(pcidev); - if(count) + if(count) { + pci_dev_put(pcidev); return 0; - if(count==MAX_CARDS) + } + if(count==MAX_CARDS) { + pci_dev_put(pcidev); break; + } } if(count==0) diff --git a/sound/oss/trident.c b/sound/oss/trident.c --- a/sound/oss/trident.c +++ b/sound/oss/trident.c @@ -3279,10 +3279,9 @@ ali_setup_spdif_out(struct trident_card unsigned char ch; char temp; - struct pci_dev *pci_dev = NULL; + struct pci_dev *pci_dev; - pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, - pci_dev); + pci_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); if (pci_dev == NULL) return; pci_read_config_byte(pci_dev, 0x61, &temp); @@ -3295,6 +3294,7 @@ ali_setup_spdif_out(struct trident_card temp &= (~0x20); temp |= 0x10; pci_write_config_byte(pci_dev, 0x7e, temp); + pci_dev_put(pci_dev); ch = inb(TRID_REG(card, ALI_SCTRL)); outb(ch | ALI_SPDIF_OUT_ENABLE, TRID_REG(card, ALI_SCTRL)); @@ -3500,17 +3500,16 @@ static int ali_close_multi_channels(void) { char temp = 0; - struct pci_dev *pci_dev = NULL; + struct pci_dev *pci_dev; - pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, - pci_dev); + pci_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); if (pci_dev == NULL) return -1; pci_read_config_byte(pci_dev, 0x59, &temp); temp &= ~0x80; pci_write_config_byte(pci_dev, 0x59, temp); - pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, + pci_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, pci_dev); if (pci_dev == NULL) return -1; @@ -3518,6 +3517,7 @@ ali_close_multi_channels(void) pci_read_config_byte(pci_dev, 0xB8, &temp); temp &= ~0x20; pci_write_config_byte(pci_dev, 0xB8, temp); + pci_dev_put(pci_dev); return 0; } @@ -3527,23 +3527,24 @@ ali_setup_multi_channels(struct trident_ { unsigned long dwValue; char temp = 0; - struct pci_dev *pci_dev = NULL; + struct pci_dev *pci_dev; - pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, - pci_dev); + pci_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); if (pci_dev == NULL) return -1; pci_read_config_byte(pci_dev, 0x59, &temp); temp |= 0x80; pci_write_config_byte(pci_dev, 0x59, temp); - pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, + pci_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M7101, pci_dev); if (pci_dev == NULL) return -1; pci_read_config_byte(pci_dev, (int) 0xB8, &temp); temp |= 0x20; pci_write_config_byte(pci_dev, (int) 0xB8, (u8) temp); + pci_dev_put(pci_dev); + if (chan_nums == 6) { dwValue = inl(TRID_REG(card, ALI_SCTRL)) | 0x000f0000; outl(dwValue, TRID_REG(card, ALI_SCTRL)); @@ -4102,12 +4103,11 @@ static /*const */ struct file_operations static int ali_reset_5451(struct trident_card *card) { - struct pci_dev *pci_dev = NULL; + struct pci_dev *pci_dev; unsigned int dwVal; unsigned short wCount, wReg; - pci_dev = pci_find_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, - pci_dev); + pci_dev = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, NULL); if (pci_dev == NULL) return -1; @@ -4117,6 +4117,7 @@ ali_reset_5451(struct trident_card *card pci_read_config_dword(pci_dev, 0x7c, &dwVal); pci_write_config_dword(pci_dev, 0x7c, dwVal & 0xf7ffffff); udelay(5000); + pci_dev_put(pci_dev); pci_dev = card->pci_dev; if (pci_dev == NULL) @@ -4356,7 +4357,7 @@ trident_probe(struct pci_dev *pci_dev, c u8 revision; int i = 0; u16 temp; - struct pci_dev *pci_dev_m1533 = NULL; + struct pci_dev *pci_dev_m1533; int rc = -ENODEV; u64 dma_mask; @@ -4442,9 +4443,9 @@ trident_probe(struct pci_dev *pci_dev, c /* Add H/W Volume Control By Matt Wu Jul. 06, 2001 */ card->hwvolctl = 0; - pci_dev_m1533 = pci_find_device(PCI_VENDOR_ID_AL, + pci_dev_m1533 = pci_get_device(PCI_VENDOR_ID_AL, PCI_DEVICE_ID_AL_M1533, - pci_dev_m1533); + NULL); rc = -ENODEV; if (pci_dev_m1533 == NULL) goto out_proc_fs; @@ -4458,6 +4459,7 @@ trident_probe(struct pci_dev *pci_dev, c bits &= 0xbf; /*clear bit 6 */ pci_write_config_byte(pci_dev_m1533, 0x7b, bits); } + pci_dev_put(pci_dev_m1533); } else if (card->pci_id == PCI_DEVICE_ID_INTERG_5050) { card->alloc_pcm_channel = cyber_alloc_pcm_channel; card->alloc_rec_pcm_channel = cyber_alloc_pcm_channel; diff --git a/sound/oss/via82cxxx_audio.c b/sound/oss/via82cxxx_audio.c --- a/sound/oss/via82cxxx_audio.c +++ b/sound/oss/via82cxxx_audio.c @@ -1546,7 +1546,7 @@ static int via_mixer_open (struct inode DPRINTK ("ENTER\n"); - while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) { + for_each_pci_dev(pdev) { drvr = pci_dev_driver (pdev); if (drvr == &via_driver) { assert (pci_get_drvdata (pdev) != NULL); @@ -1562,6 +1562,7 @@ static int via_mixer_open (struct inode match: file->private_data = card->ac97; + pci_dev_put(pdev); DPRINTK ("EXIT, returning 0\n"); return nonseekable_open(inode, file); @@ -3244,7 +3245,7 @@ static int via_dsp_open (struct inode *i } card = NULL; - while ((pdev = pci_find_device(PCI_ANY_ID, PCI_ANY_ID, pdev)) != NULL) { + for_each_pci_dev(pdev) { drvr = pci_dev_driver (pdev); if (drvr == &via_driver) { assert (pci_get_drvdata (pdev) != NULL); @@ -3266,11 +3267,13 @@ match: if (nonblock) { if (down_trylock (&card->open_sem)) { DPRINTK ("EXIT, returning -EAGAIN\n"); + pci_dev_put(pdev); return -EAGAIN; } } else { if (down_interruptible (&card->open_sem)) { DPRINTK ("EXIT, returning -ERESTARTSYS\n"); + pci_dev_put(pdev); return -ERESTARTSYS; } } @@ -3318,6 +3321,7 @@ match: } } + pci_dev_put(pdev); DPRINTK ("EXIT, returning 0\n"); return nonseekable_open(inode, file); } diff --git a/sound/pci/ali5451/ali5451.c b/sound/pci/ali5451/ali5451.c --- a/sound/pci/ali5451/ali5451.c +++ b/sound/pci/ali5451/ali5451.c @@ -326,13 +326,12 @@ static void ali_read_regs(ali_t *codec, static void ali_read_cfg(unsigned int vendor, unsigned deviceid) { unsigned int dwVal; - struct pci_dev *pci_dev = NULL; + struct pci_dev *pci_dev; int i,j; - - pci_dev = pci_find_device(vendor, deviceid, pci_dev); - if (pci_dev == NULL) - return ; + pci_dev = pci_get_device(vendor, deviceid, NULL); + if (pci_dev == NULL) + return ; printk("\nM%x PCI CFG\n", deviceid); printk(" "); @@ -349,6 +348,7 @@ static void ali_read_cfg(unsigned int ve } printk("\n"); } + pci_dev_put(pci_dev); } static void ali_read_ac97regs(ali_t *codec, int secondary) { @@ -2116,6 +2116,8 @@ static int snd_ali_free(ali_t * codec) #ifdef CONFIG_PM kfree(codec->image); #endif + pci_dev_put(codec->pci_m1533); + pci_dev_put(codec->pci_m7101); kfree(codec); return 0; } @@ -2305,7 +2307,7 @@ static int __devinit snd_ali_create(snd_ codec->chregs.data.ainten = 0x00; /* M1533: southbridge */ - pci_dev = pci_find_device(0x10b9, 0x1533, NULL); + pci_dev = pci_get_device(0x10b9, 0x1533, NULL); codec->pci_m1533 = pci_dev; if (! codec->pci_m1533) { snd_printk(KERN_ERR "ali5451: cannot find ALi 1533 chip.\n"); @@ -2313,7 +2315,7 @@ static int __devinit snd_ali_create(snd_ return -ENODEV; } /* M7101: power management */ - pci_dev = pci_find_device(0x10b9, 0x7101, NULL); + pci_dev = pci_get_device(0x10b9, 0x7101, NULL); codec->pci_m7101 = pci_dev; if (! codec->pci_m7101 && codec->revision == ALI_5451_V02) { snd_printk(KERN_ERR "ali5451: cannot find ALi 7101 chip.\n"); @@ -2361,6 +2363,8 @@ static int __devinit snd_ali_probe(struc ali_t *codec; int err; + codec->pci_m7101 = codec->pci_m1533 = NULL; + snd_ali_printk("probe ...\n"); if (dev >= SNDRV_CARDS) diff --git a/sound/pci/au88x0/au88x0.c b/sound/pci/au88x0/au88x0.c --- a/sound/pci/au88x0/au88x0.c +++ b/sound/pci/au88x0/au88x0.c @@ -79,19 +79,18 @@ static void vortex_fix_agp_bridge(struct static void __devinit snd_vortex_workaround(struct pci_dev *vortex, int fix) { - struct pci_dev *via; + struct pci_dev *via = NULL; /* autodetect if workarounds are required */ if (fix == 255) { /* VIA KT133 */ - via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8365_1, NULL); + via = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8365_1, NULL); /* VIA Apollo */ if (via == NULL) { - via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C598_1, NULL); - } - /* AMD Irongate */ - if (via == NULL) { - via = pci_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL); + via = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C598_1, NULL); + /* AMD Irongate */ + if (via == NULL) + via = pci_get_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL); } if (via) { printk(KERN_INFO CARD_NAME ": Activating latency workaround...\n"); @@ -101,13 +100,14 @@ static void __devinit snd_vortex_workaro } else { if (fix & 0x1) vortex_fix_latency(vortex); - if ((fix & 0x2) && (via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8365_1, NULL))) + if ((fix & 0x2) && (via = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8365_1, NULL))) vortex_fix_agp_bridge(via); - if ((fix & 0x4) && (via = pci_find_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C598_1, NULL))) + if ((fix & 0x4) && (via = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C598_1, NULL))) vortex_fix_agp_bridge(via); - if ((fix & 0x8) && (via = pci_find_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL))) + if ((fix & 0x8) && (via = pci_get_device(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_7007, NULL))) vortex_fix_agp_bridge(via); } + pci_dev_put(via); } // component-destructor diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c @@ -17,6 +17,7 @@ * - SPDIF input support for other sample rates then 48khz * - Posibility to mix the SPDIF output with analog sources. * - PCM channels for Center and LFE on secondary codec + * - handle somewhere count down acpi_dev reference count by pci_dev_put * * NOTE: with CONFIG_SND_CS46XX_NEW_DSP unset uses old DSP image (which * is default configuration), no SPDIF, no secondary codec, no @@ -3576,7 +3577,7 @@ static void clkrun_init(cs46xx_t *chip) { u8 pp; - chip->acpi_dev = pci_find_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL); + chip->acpi_dev = pci_get_device(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82371AB_3, NULL); if (chip->acpi_dev == NULL) return; /* Not a thinkpad thats for sure */ diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c @@ -1934,11 +1934,12 @@ static int snd_via82xx_chip_init(via82xx * DXS channels don't work properly with VRA if MC97 is disabled. */ struct pci_dev *pci; - pci = pci_find_device(0x1106, 0x3068, NULL); /* MC97 */ + pci = pci_get_device(0x1106, 0x3068, NULL); /* MC97 */ if (pci) { unsigned char data; pci_read_config_byte(pci, 0x44, &data); pci_write_config_byte(pci, 0x44, data | 0x40); + pci_dev_put(pci); } }