staging: comedi: daqboard2000: store the pci_dev in the comedi_device
authorH Hartley Sweeten <hartleys@visionengravers.com>
Thu, 19 Jul 2012 01:57:08 +0000 (18:57 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jul 2012 23:32:57 +0000 (16:32 -0700)
Use the hw_dev pointer in the comedi_device struct to hold the
pci_dev instead of carrying it in the private data.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/daqboard2000.c

index 1d94b58..ba61e32 100644 (file)
@@ -317,7 +317,6 @@ struct daqboard2000_private {
        enum {
                card_daqboard_2000
        } card;
-       struct pci_dev *pci_dev;
        void *daq;
        void *plx;
        unsigned int ao_readback[2];
@@ -751,7 +750,7 @@ static int daqboard2000_attach(struct comedi_device *dev,
        pcidev = daqboard2000_find_pci_dev(dev, it);
        if (!pcidev)
                return -EIO;
-       devpriv->pci_dev = pcidev;
+       comedi_set_hw_dev(dev, &pcidev->dev);
 
        result = comedi_pci_enable(pcidev, "daqboard2000");
        if (result < 0) {
@@ -833,6 +832,8 @@ out:
 
 static void daqboard2000_detach(struct comedi_device *dev)
 {
+       struct pci_dev *pcidev = comedi_to_pci_dev(dev);
+
        if (dev->subdevices)
                subdev_8255_cleanup(dev, dev->subdevices + 2);
        if (dev->irq)
@@ -842,11 +843,11 @@ static void daqboard2000_detach(struct comedi_device *dev)
                        iounmap(devpriv->daq);
                if (devpriv->plx)
                        iounmap(devpriv->plx);
-               if (devpriv->pci_dev) {
-                       if (dev->iobase)
-                               comedi_pci_disable(devpriv->pci_dev);
-                       pci_dev_put(devpriv->pci_dev);
-               }
+       }
+       if (pcidev) {
+               if (dev->iobase)
+                       comedi_pci_disable(pcidev);
+               pci_dev_put(pcidev);
        }
 }