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