staging: comedi: das08: Use struct comedi_device hw_dev for PCI
authorIan Abbott <abbotti@mev.co.uk>
Wed, 5 Sep 2012 10:02:40 +0000 (11:02 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Sep 2012 18:58:24 +0000 (11:58 -0700)
Remove the pointer to the PCI device from the private data `struct
das08_private_struct`.  Use `comedi_set_hw_dev()` to save a pointer to
the PCI device (actually, its embedded `struct device`) and
`comedi_to_pci_dev()` to retrieve it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/das08.c
drivers/staging/comedi/drivers/das08.h

index 2614961bb14fda21733486701acc599dd87c9499..0c69b05fceb7013ac157efb34278994e70ea5bac 100644 (file)
@@ -778,7 +778,6 @@ das08_find_pci_board(struct pci_dev *pdev)
 static int __devinit __maybe_unused
 das08_attach_pci(struct comedi_device *dev, struct pci_dev *pdev)
 {
-       struct das08_private_struct *devpriv;
        unsigned long iobase;
        int ret;
 
@@ -793,8 +792,7 @@ das08_attach_pci(struct comedi_device *dev, struct pci_dev *pdev)
                dev_err(dev->class_dev, "BUG! cannot determine board type!\n");
                return -EINVAL;
        }
-       devpriv = dev->private;
-       devpriv->pdev = pdev;
+       comedi_set_hw_dev(dev, &pdev->dev);
        /*  enable PCI device and reserve I/O spaces */
        if (comedi_pci_enable(pdev, dev->driver->driver_name)) {
                dev_err(dev->class_dev,
@@ -847,16 +845,16 @@ EXPORT_SYMBOL_GPL(das08_common_detach);
 static void __maybe_unused das08_detach(struct comedi_device *dev)
 {
        const struct das08_board_struct *thisboard = comedi_board(dev);
-       struct das08_private_struct *devpriv = dev->private;
 
        das08_common_detach(dev);
        if (is_isa_board(thisboard)) {
                if (dev->iobase)
                        release_region(dev->iobase, thisboard->iosize);
        } else if (is_pci_board(thisboard)) {
-               if (devpriv && devpriv->pdev) {
+               struct pci_dev *pdev = comedi_to_pci_dev(dev);
+               if (pdev) {
                        if (dev->iobase)
-                               comedi_pci_disable(devpriv->pdev);
+                               comedi_pci_disable(pdev);
                }
        }
 }
index 4231be553c0d5110605d4500db47345b797d88e0..0314baebae393d0f2f682fdcb6979be9b20415b0 100644 (file)
@@ -51,7 +51,6 @@ struct das08_private_struct {
        unsigned int do_mux_bits;       /*  bits for do/mux register on boards without separate do register */
        unsigned int do_bits;   /*  bits for do register on boards with register dedicated to digital out only */
        const unsigned int *pg_gainlist;
-       struct pci_dev *pdev;   /*  struct for pci-das08 */
        unsigned int ao_readback[2];    /* assume 2 AO channels */
 };