V4L/DVB (4707): 4linux: complete conversion to hotplug safe PCI API

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

authored by Alan Cox and committed by Mauro Carvalho Chehab e491cbc8 a868b45d

+18 -13
+6 -4
drivers/media/video/zoran_card.c
··· 1278 1278 1279 1279 zoran_num = 0; 1280 1280 while (zoran_num < BUZ_MAX && 1281 - (dev = 1282 - pci_find_device(PCI_VENDOR_ID_ZORAN, 1283 - PCI_DEVICE_ID_ZORAN_36057, dev)) != NULL) { 1281 + (dev = pci_get_device(PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36057, dev)) != NULL) { 1284 1282 card_num = card[zoran_num]; 1285 1283 zr = &zoran[zoran_num]; 1286 1284 memset(zr, 0, sizeof(struct zoran)); // Just in case if previous cycle failed ··· 1539 1541 goto zr_detach_vfe; 1540 1542 } 1541 1543 } 1542 - 1544 + /* Success so keep the pci_dev referenced */ 1545 + pci_dev_get(zr->pci_dev); 1543 1546 zoran_num++; 1544 1547 continue; 1545 1548 ··· 1562 1563 iounmap(zr->zr36057_mem); 1563 1564 continue; 1564 1565 } 1566 + if (dev) /* Clean up ref count on early exit */ 1567 + pci_dev_put(dev); 1568 + 1565 1569 if (zoran_num == 0) { 1566 1570 dprintk(1, KERN_INFO "No known MJPEG cards found.\n"); 1567 1571 }
+12 -9
drivers/media/video/zr36120.c
··· 1840 1840 struct zoran *ztv; 1841 1841 struct pci_dev *dev = NULL; 1842 1842 unsigned char revision; 1843 - int zoran_num=0; 1843 + int zoran_num = 0; 1844 1844 1845 - while ((dev = pci_find_device(PCI_VENDOR_ID_ZORAN,PCI_DEVICE_ID_ZORAN_36120, dev))) 1845 + while ((dev = pci_get_device(PCI_VENDOR_ID_ZORAN,PCI_DEVICE_ID_ZORAN_36120, dev))) 1846 1846 { 1847 1847 /* Ok, a ZR36120/ZR36125 found! */ 1848 1848 ztv = &zorans[zoran_num]; 1849 1849 ztv->dev = dev; 1850 1850 1851 1851 if (pci_enable_device(dev)) 1852 - return -EIO; 1852 + continue; 1853 1853 1854 1854 pci_read_config_byte(dev, PCI_CLASS_REVISION, &revision); 1855 1855 printk(KERN_INFO "zoran: Zoran %x (rev %d) ", ··· 1867 1867 { 1868 1868 iounmap(ztv->zoran_mem); 1869 1869 printk(KERN_ERR "zoran: Bad irq number or handler\n"); 1870 - return -EINVAL; 1870 + continue; 1871 1871 } 1872 1872 if (result==-EBUSY) 1873 1873 printk(KERN_ERR "zoran: IRQ %d busy, change your PnP config in BIOS\n",dev->irq); 1874 1874 if (result < 0) { 1875 1875 iounmap(ztv->zoran_mem); 1876 - return result; 1876 + continue; 1877 1877 } 1878 1878 /* Enable bus-mastering */ 1879 1879 pci_set_master(dev); 1880 - 1880 + /* Keep a reference */ 1881 + pci_dev_get(dev); 1881 1882 zoran_num++; 1882 1883 } 1883 1884 if(zoran_num) ··· 2042 2041 if (ztv->zoran_mem) 2043 2042 iounmap(ztv->zoran_mem); 2044 2043 2044 + /* Drop PCI device */ 2045 + pci_dev_put(ztv->dev); 2046 + 2045 2047 video_unregister_device(&ztv->video_dev); 2046 2048 video_unregister_device(&ztv->vbi_dev); 2047 2049 } ··· 2061 2057 2062 2058 handle_chipset(); 2063 2059 zoran_cards = find_zoran(); 2064 - if (zoran_cards<0) 2065 - /* no cards found, no need for a driver */ 2060 + if (zoran_cards <= 0) 2066 2061 return -EIO; 2067 2062 2068 2063 /* initialize Zorans */ 2069 2064 for (card=0; card<zoran_cards; card++) { 2070 - if (init_zoran(card)<0) { 2065 + if (init_zoran(card) < 0) { 2071 2066 /* only release the zorans we have registered */ 2072 2067 release_zoran(card); 2073 2068 return -EIO;