aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/zoran_card.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/zoran_card.c')
-rw-r--r--drivers/media/video/zoran_card.c42
1 files changed, 29 insertions, 13 deletions
diff --git a/drivers/media/video/zoran_card.c b/drivers/media/video/zoran_card.c
index 0929edb2d4f..d842a7cb99d 100644
--- a/drivers/media/video/zoran_card.c
+++ b/drivers/media/video/zoran_card.c
@@ -161,7 +161,7 @@ static struct pci_device_id zr36067_pci_tbl[] = {
161MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl); 161MODULE_DEVICE_TABLE(pci, zr36067_pci_tbl);
162 162
163int zoran_num; /* number of Buzs in use */ 163int zoran_num; /* number of Buzs in use */
164struct zoran zoran[BUZ_MAX]; 164struct zoran *zoran[BUZ_MAX];
165 165
166/* videocodec bus functions ZR36060 */ 166/* videocodec bus functions ZR36060 */
167static u32 167static u32
@@ -355,9 +355,15 @@ i2cid_to_modulename (u16 i2c_id)
355 case I2C_DRIVERID_BT856: 355 case I2C_DRIVERID_BT856:
356 name = "bt856"; 356 name = "bt856";
357 break; 357 break;
358 case I2C_DRIVERID_BT866:
359 name = "bt866";
360 break;
358 case I2C_DRIVERID_VPX3220: 361 case I2C_DRIVERID_VPX3220:
359 name = "vpx3220"; 362 name = "vpx3220";
360 break; 363 break;
364 case I2C_DRIVERID_KS0127:
365 name = "ks0127";
366 break;
361 } 367 }
362 368
363 return name; 369 return name;
@@ -1164,7 +1170,7 @@ static void
1164zoran_release (struct zoran *zr) 1170zoran_release (struct zoran *zr)
1165{ 1171{
1166 if (!zr->initialized) 1172 if (!zr->initialized)
1167 return; 1173 goto exit_free;
1168 /* unregister videocodec bus */ 1174 /* unregister videocodec bus */
1169 if (zr->codec) { 1175 if (zr->codec) {
1170 struct videocodec_master *master = zr->codec->master_data; 1176 struct videocodec_master *master = zr->codec->master_data;
@@ -1192,6 +1198,8 @@ zoran_release (struct zoran *zr)
1192 iounmap(zr->zr36057_mem); 1198 iounmap(zr->zr36057_mem);
1193 pci_disable_device(zr->pci_dev); 1199 pci_disable_device(zr->pci_dev);
1194 video_unregister_device(zr->video_dev); 1200 video_unregister_device(zr->video_dev);
1201exit_free:
1202 kfree(zr);
1195} 1203}
1196 1204
1197void 1205void
@@ -1269,8 +1277,14 @@ find_zr36057 (void)
1269 while (zoran_num < BUZ_MAX && 1277 while (zoran_num < BUZ_MAX &&
1270 (dev = pci_get_device(PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36057, dev)) != NULL) { 1278 (dev = pci_get_device(PCI_VENDOR_ID_ZORAN, PCI_DEVICE_ID_ZORAN_36057, dev)) != NULL) {
1271 card_num = card[zoran_num]; 1279 card_num = card[zoran_num];
1272 zr = &zoran[zoran_num]; 1280 zr = kzalloc(sizeof(struct zoran), GFP_KERNEL);
1273 memset(zr, 0, sizeof(struct zoran)); // Just in case if previous cycle failed 1281 if (!zr) {
1282 dprintk(1,
1283 KERN_ERR
1284 "%s: find_zr36057() - kzalloc failed\n",
1285 ZORAN_NAME);
1286 continue;
1287 }
1274 zr->pci_dev = dev; 1288 zr->pci_dev = dev;
1275 //zr->zr36057_mem = NULL; 1289 //zr->zr36057_mem = NULL;
1276 zr->id = zoran_num; 1290 zr->id = zoran_num;
@@ -1278,7 +1292,7 @@ find_zr36057 (void)
1278 spin_lock_init(&zr->spinlock); 1292 spin_lock_init(&zr->spinlock);
1279 mutex_init(&zr->resource_lock); 1293 mutex_init(&zr->resource_lock);
1280 if (pci_enable_device(dev)) 1294 if (pci_enable_device(dev))
1281 continue; 1295 goto zr_free_mem;
1282 zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0); 1296 zr->zr36057_adr = pci_resource_start(zr->pci_dev, 0);
1283 pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION, 1297 pci_read_config_byte(zr->pci_dev, PCI_CLASS_REVISION,
1284 &zr->revision); 1298 &zr->revision);
@@ -1294,7 +1308,7 @@ find_zr36057 (void)
1294 KERN_ERR 1308 KERN_ERR
1295 "%s: find_zr36057() - no card specified, please use the card=X insmod option\n", 1309 "%s: find_zr36057() - no card specified, please use the card=X insmod option\n",
1296 ZR_DEVNAME(zr)); 1310 ZR_DEVNAME(zr));
1297 continue; 1311 goto zr_free_mem;
1298 } 1312 }
1299 } else { 1313 } else {
1300 int i; 1314 int i;
@@ -1333,7 +1347,7 @@ find_zr36057 (void)
1333 KERN_ERR 1347 KERN_ERR
1334 "%s: find_zr36057() - unknown card\n", 1348 "%s: find_zr36057() - unknown card\n",
1335 ZR_DEVNAME(zr)); 1349 ZR_DEVNAME(zr));
1336 continue; 1350 goto zr_free_mem;
1337 } 1351 }
1338 } 1352 }
1339 } 1353 }
@@ -1343,7 +1357,7 @@ find_zr36057 (void)
1343 KERN_ERR 1357 KERN_ERR
1344 "%s: find_zr36057() - invalid cardnum %d\n", 1358 "%s: find_zr36057() - invalid cardnum %d\n",
1345 ZR_DEVNAME(zr), card_num); 1359 ZR_DEVNAME(zr), card_num);
1346 continue; 1360 goto zr_free_mem;
1347 } 1361 }
1348 1362
1349 /* even though we make this a non pointer and thus 1363 /* even though we make this a non pointer and thus
@@ -1361,7 +1375,7 @@ find_zr36057 (void)
1361 KERN_ERR 1375 KERN_ERR
1362 "%s: find_zr36057() - ioremap failed\n", 1376 "%s: find_zr36057() - ioremap failed\n",
1363 ZR_DEVNAME(zr)); 1377 ZR_DEVNAME(zr));
1364 continue; 1378 goto zr_free_mem;
1365 } 1379 }
1366 1380
1367 result = request_irq(zr->pci_dev->irq, 1381 result = request_irq(zr->pci_dev->irq,
@@ -1530,7 +1544,7 @@ find_zr36057 (void)
1530 } 1544 }
1531 /* Success so keep the pci_dev referenced */ 1545 /* Success so keep the pci_dev referenced */
1532 pci_dev_get(zr->pci_dev); 1546 pci_dev_get(zr->pci_dev);
1533 zoran_num++; 1547 zoran[zoran_num++] = zr;
1534 continue; 1548 continue;
1535 1549
1536 // Init errors 1550 // Init errors
@@ -1549,6 +1563,8 @@ find_zr36057 (void)
1549 free_irq(zr->pci_dev->irq, zr); 1563 free_irq(zr->pci_dev->irq, zr);
1550 zr_unmap: 1564 zr_unmap:
1551 iounmap(zr->zr36057_mem); 1565 iounmap(zr->zr36057_mem);
1566 zr_free_mem:
1567 kfree(zr);
1552 continue; 1568 continue;
1553 } 1569 }
1554 if (dev) /* Clean up ref count on early exit */ 1570 if (dev) /* Clean up ref count on early exit */
@@ -1620,7 +1636,7 @@ init_dc10_cards (void)
1620 1636
1621 /* take care of Natoma chipset and a revision 1 zr36057 */ 1637 /* take care of Natoma chipset and a revision 1 zr36057 */
1622 for (i = 0; i < zoran_num; i++) { 1638 for (i = 0; i < zoran_num; i++) {
1623 struct zoran *zr = &zoran[i]; 1639 struct zoran *zr = zoran[i];
1624 1640
1625 if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) { 1641 if ((pci_pci_problems & PCIPCI_NATOMA) && zr->revision <= 1) {
1626 zr->jpg_buffers.need_contiguous = 1; 1642 zr->jpg_buffers.need_contiguous = 1;
@@ -1632,7 +1648,7 @@ init_dc10_cards (void)
1632 1648
1633 if (zr36057_init(zr) < 0) { 1649 if (zr36057_init(zr) < 0) {
1634 for (i = 0; i < zoran_num; i++) 1650 for (i = 0; i < zoran_num; i++)
1635 zoran_release(&zoran[i]); 1651 zoran_release(zoran[i]);
1636 return -EIO; 1652 return -EIO;
1637 } 1653 }
1638 zoran_proc_init(zr); 1654 zoran_proc_init(zr);
@@ -1647,7 +1663,7 @@ unload_dc10_cards (void)
1647 int i; 1663 int i;
1648 1664
1649 for (i = 0; i < zoran_num; i++) 1665 for (i = 0; i < zoran_num; i++)
1650 zoran_release(&zoran[i]); 1666 zoran_release(zoran[i]);
1651} 1667}
1652 1668
1653module_init(init_dc10_cards); 1669module_init(init_dc10_cards);