diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-02-07 05:23:40 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:42:41 -0400 |
commit | ef77a26be1883366bb78741d1808e5c86a14ec76 (patch) | |
tree | c2230ea68d7615fc47894bbd15ec1403e5b8fd56 /drivers/media | |
parent | 80b36e0fcfe7520ee92f648148d091ad880ae711 (diff) |
V4L/DVB (10496): saa7146: implement v4l2_device support.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/common/saa7146_core.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/media/common/saa7146_core.c b/drivers/media/common/saa7146_core.c index d599d360da3f..961ad16e1d6f 100644 --- a/drivers/media/common/saa7146_core.c +++ b/drivers/media/common/saa7146_core.c | |||
@@ -363,13 +363,16 @@ 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; | ||
366 | 369 | ||
367 | DEB_EE(("pci:%p\n",pci)); | 370 | DEB_EE(("pci:%p\n",pci)); |
368 | 371 | ||
369 | err = pci_enable_device(pci); | 372 | err = pci_enable_device(pci); |
370 | if (err < 0) { | 373 | if (err < 0) { |
371 | ERR(("pci_enable_device() failed.\n")); | 374 | ERR(("pci_enable_device() failed.\n")); |
372 | goto err_free; | 375 | goto err_unreg; |
373 | } | 376 | } |
374 | 377 | ||
375 | /* enable bus-mastering */ | 378 | /* enable bus-mastering */ |
@@ -452,8 +455,6 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent | |||
452 | INFO(("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x).\n", dev->mem, dev->revision, pci->irq, pci->subsystem_vendor, pci->subsystem_device)); | 455 | INFO(("found saa7146 @ mem %p (revision %d, irq %d) (0x%04x,0x%04x).\n", dev->mem, dev->revision, pci->irq, pci->subsystem_vendor, pci->subsystem_device)); |
453 | dev->ext = ext; | 456 | dev->ext = ext; |
454 | 457 | ||
455 | pci_set_drvdata(pci, dev); | ||
456 | |||
457 | mutex_init(&dev->lock); | 458 | mutex_init(&dev->lock); |
458 | spin_lock_init(&dev->int_slock); | 459 | spin_lock_init(&dev->int_slock); |
459 | spin_lock_init(&dev->slock); | 460 | spin_lock_init(&dev->slock); |
@@ -477,7 +478,7 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent | |||
477 | 478 | ||
478 | if (ext->attach(dev, pci_ext)) { | 479 | if (ext->attach(dev, pci_ext)) { |
479 | DEB_D(("ext->attach() failed for %p. skipping device.\n",dev)); | 480 | DEB_D(("ext->attach() failed for %p. skipping device.\n",dev)); |
480 | goto err_unprobe; | 481 | goto err_free_i2c; |
481 | } | 482 | } |
482 | 483 | ||
483 | INIT_LIST_HEAD(&dev->item); | 484 | INIT_LIST_HEAD(&dev->item); |
@@ -488,8 +489,6 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent | |||
488 | out: | 489 | out: |
489 | return err; | 490 | return err; |
490 | 491 | ||
491 | err_unprobe: | ||
492 | pci_set_drvdata(pci, NULL); | ||
493 | err_free_i2c: | 492 | err_free_i2c: |
494 | pci_free_consistent(pci, SAA7146_RPS_MEM, dev->d_i2c.cpu_addr, | 493 | pci_free_consistent(pci, SAA7146_RPS_MEM, dev->d_i2c.cpu_addr, |
495 | dev->d_i2c.dma_handle); | 494 | dev->d_i2c.dma_handle); |
@@ -507,6 +506,8 @@ err_release: | |||
507 | pci_release_region(pci, 0); | 506 | pci_release_region(pci, 0); |
508 | err_disable: | 507 | err_disable: |
509 | pci_disable_device(pci); | 508 | pci_disable_device(pci); |
509 | err_unreg: | ||
510 | v4l2_device_unregister(&dev->v4l2_dev); | ||
510 | err_free: | 511 | err_free: |
511 | kfree(dev); | 512 | kfree(dev); |
512 | goto out; | 513 | goto out; |
@@ -514,7 +515,8 @@ err_free: | |||
514 | 515 | ||
515 | static void saa7146_remove_one(struct pci_dev *pdev) | 516 | static void saa7146_remove_one(struct pci_dev *pdev) |
516 | { | 517 | { |
517 | struct saa7146_dev* dev = pci_get_drvdata(pdev); | 518 | struct v4l2_device *v4l2_dev = pci_get_drvdata(pdev); |
519 | struct saa7146_dev *dev = container_of(v4l2_dev, struct saa7146_dev, v4l2_dev); | ||
518 | struct { | 520 | struct { |
519 | void *addr; | 521 | void *addr; |
520 | dma_addr_t dma; | 522 | dma_addr_t dma; |
@@ -528,6 +530,7 @@ static void saa7146_remove_one(struct pci_dev *pdev) | |||
528 | DEB_EE(("dev:%p\n",dev)); | 530 | DEB_EE(("dev:%p\n",dev)); |
529 | 531 | ||
530 | dev->ext->detach(dev); | 532 | dev->ext->detach(dev); |
533 | v4l2_device_unregister(&dev->v4l2_dev); | ||
531 | 534 | ||
532 | /* shut down all video dma transfers */ | 535 | /* shut down all video dma transfers */ |
533 | saa7146_write(dev, MC1, 0x00ff0000); | 536 | saa7146_write(dev, MC1, 0x00ff0000); |