]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/media/common/saa7146_core.c
nilfs2: mark minor flag for checkpoint created by internal operation
[linux-2.6-omap-h63xx.git] / drivers / media / common / saa7146_core.c
index d599d360da3fafcbcd26d72c19419683f1f2c4cb..982f000a57ffc896eeeda4c8295db20fdb6ff8c6 100644 (file)
@@ -452,8 +452,6 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
        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));
        dev->ext = ext;
 
-       pci_set_drvdata(pci, dev);
-
        mutex_init(&dev->lock);
        spin_lock_init(&dev->int_slock);
        spin_lock_init(&dev->slock);
@@ -477,8 +475,12 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
 
        if (ext->attach(dev, pci_ext)) {
                DEB_D(("ext->attach() failed for %p. skipping device.\n",dev));
-               goto err_unprobe;
+               goto err_free_i2c;
        }
+       /* V4L extensions will set the pci drvdata to the v4l2_device in the
+          attach() above. So for those cards that do not use V4L we have to
+          set it explicitly. */
+       pci_set_drvdata(pci, &dev->v4l2_dev);
 
        INIT_LIST_HEAD(&dev->item);
        list_add_tail(&dev->item,&saa7146_devices);
@@ -488,8 +490,6 @@ static int saa7146_init_one(struct pci_dev *pci, const struct pci_device_id *ent
 out:
        return err;
 
-err_unprobe:
-       pci_set_drvdata(pci, NULL);
 err_free_i2c:
        pci_free_consistent(pci, SAA7146_RPS_MEM, dev->d_i2c.cpu_addr,
                            dev->d_i2c.dma_handle);
@@ -514,7 +514,8 @@ err_free:
 
 static void saa7146_remove_one(struct pci_dev *pdev)
 {
-       struct saa7146_dev* dev = pci_get_drvdata(pdev);
+       struct v4l2_device *v4l2_dev = pci_get_drvdata(pdev);
+       struct saa7146_dev *dev = to_saa7146_dev(v4l2_dev);
        struct {
                void *addr;
                dma_addr_t dma;
@@ -528,6 +529,8 @@ static void saa7146_remove_one(struct pci_dev *pdev)
        DEB_EE(("dev:%p\n",dev));
 
        dev->ext->detach(dev);
+       /* Zero the PCI drvdata after use. */
+       pci_set_drvdata(pdev, NULL);
 
        /* shut down all video dma transfers */
        saa7146_write(dev, MC1, 0x00ff0000);