aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-02-07 18:42:33 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-03-30 11:42:42 -0400
commit230b65f9945b468c23188572144b4f066af8f98c (patch)
treea5d7da48908defc6e602a80c932fd06b9f8b7abd /drivers
parenteae4d69b6a337d29060dcad3a4e19e3e8ace3e70 (diff)
V4L/DVB (10502): saa7146: move v4l2 device registration to saa7146_vv.
Doing the v4l2_device registration in the saa7146 core will make it dependent on v4l2, even for DVB-only boards. This registration and unregistration belongs in saa7146_vv instead. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/common/saa7146_core.c14
-rw-r--r--drivers/media/common/saa7146_fops.c11
2 files changed, 16 insertions, 9 deletions
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c
index a123844eb656..982f000a57ff 100644
--- a/drivers/media/common/saa7146_core.c
+++ b/drivers/media/common/saa7146_core.c
@@ -363,16 +363,13 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
363 ERR(("out of memory.\n")); 363 ERR(("out of memory.\n"));
364 goto out; 364 goto out;
365 } 365 }
366 err = v4l2_device_register(&pci->dev, &dev->v4l2_dev);
367 if (err)
368 goto err_free;
369 366
370 DEB_EE(("pci:%p\n",pci)); 367 DEB_EE(("pci:%p\n",pci));
371 368
372 err = pci_enable_device(pci); 369 err = pci_enable_device(pci);
373 if (err < 0) { 370 if (err < 0) {
374 ERR(("pci_enable_device() failed.\n")); 371 ERR(("pci_enable_device() failed.\n"));
375 goto err_unreg; 372 goto err_free;
376 } 373 }
377 374
378 /* enable bus-mastering */ 375 /* enable bus-mastering */
@@ -480,6 +477,10 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
480 DEB_D(("ext->attach() failed for %p. skipping device.\n",dev)); 477 DEB_D(("ext->attach() failed for %p. skipping device.\n",dev));
481 goto err_free_i2c; 478 goto err_free_i2c;
482 } 479 }
480 /* V4L extensions will set the pci drvdata to the v4l2_device in the
481 attach() above. So for those cards that do not use V4L we have to
482 set it explicitly. */
483 pci_set_drvdata(pci, &dev->v4l2_dev);
483 484
484 INIT_LIST_HEAD(&dev->item); 485 INIT_LIST_HEAD(&dev->item);
485 list_add_tail(&dev->item,&saa7146_devices); 486 list_add_tail(&dev->item,&saa7146_devices);
@@ -506,8 +507,6 @@ err_release:
506 pci_release_region(pci, 0); 507 pci_release_region(pci, 0);
507err_disable: 508err_disable:
508 pci_disable_device(pci); 509 pci_disable_device(pci);
509err_unreg:
510 v4l2_device_unregister(&dev->v4l2_dev);
511err_free: 510err_free:
512 kfree(dev); 511 kfree(dev);
513 goto out; 512 goto out;
@@ -530,7 +529,8 @@ static void saa7146_remove_one(struct pci_dev *pdev)
530 DEB_EE(("dev:%p\n",dev)); 529 DEB_EE(("dev:%p\n",dev));
531 530
532 dev->ext->detach(dev); 531 dev->ext->detach(dev);
533 v4l2_device_unregister(&dev->v4l2_dev); 532 /* Zero the PCI drvdata after use. */
533 pci_set_drvdata(pdev, NULL);
534 534
535 /* shut down all video dma transfers */ 535 /* shut down all video dma transfers */
536 saa7146_write(dev, MC1, 0x00ff0000); 536 saa7146_write(dev, MC1, 0x00ff0000);
diff --git a/drivers/media/common/saa7146_fops.c b/drivers/media/common/saa7146_fops.c
index fec799d2600f..620f655fa9c5 100644
--- a/drivers/media/common/saa7146_fops.c
+++ b/drivers/media/common/saa7146_fops.c
@@ -446,11 +446,17 @@ static void vv_callback(struct saa7146_dev *dev, unsigned long status)
446 446
447int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv) 447int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)
448{ 448{
449 struct saa7146_vv *vv = kzalloc(sizeof(struct saa7146_vv), GFP_KERNEL); 449 struct saa7146_vv *vv;
450 int err;
451
452 err = v4l2_device_register(&dev->pci->dev, &dev->v4l2_dev);
453 if (err)
454 return err;
450 455
456 vv = kzalloc(sizeof(struct saa7146_vv), GFP_KERNEL);
451 if (vv == NULL) { 457 if (vv == NULL) {
452 ERR(("out of memory. aborting.\n")); 458 ERR(("out of memory. aborting.\n"));
453 return -1; 459 return -ENOMEM;
454 } 460 }
455 ext_vv->ops = saa7146_video_ioctl_ops; 461 ext_vv->ops = saa7146_video_ioctl_ops;
456 ext_vv->core_ops = &saa7146_video_ioctl_ops; 462 ext_vv->core_ops = &saa7146_video_ioctl_ops;
@@ -496,6 +502,7 @@ int saa7146_vv_release(struct saa7146_dev* dev)
496 502
497 DEB_EE(("dev:%p\n",dev)); 503 DEB_EE(("dev:%p\n",dev));
498 504
505 v4l2_device_unregister(&dev->v4l2_dev);
499 pci_free_consistent(dev->pci, SAA7146_CLIPPING_MEM, vv->d_clipping.cpu_addr, vv->d_clipping.dma_handle); 506 pci_free_consistent(dev->pci, SAA7146_CLIPPING_MEM, vv->d_clipping.cpu_addr, vv->d_clipping.dma_handle);
500 kfree(vv); 507 kfree(vv);
501 dev->vv_data = NULL; 508 dev->vv_data = NULL;