[PATCH 2/2] staging: comedi: das08: Use struct comedi_device hw_dev for PCI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 drivers/staging/comedi/drivers/das08.c | 10 ++++------
 drivers/staging/comedi/drivers/das08.h |  1 -
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/comedi/drivers/das08.c b/drivers/staging/comedi/drivers/das08.c
index 2614961..0c69b05 100644
--- a/drivers/staging/comedi/drivers/das08.c
+++ b/drivers/staging/comedi/drivers/das08.c
@@ -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);
 		}
 	}
 }
diff --git a/drivers/staging/comedi/drivers/das08.h b/drivers/staging/comedi/drivers/das08.h
index 4231be5..0314bae 100644
--- a/drivers/staging/comedi/drivers/das08.h
+++ b/drivers/staging/comedi/drivers/das08.h
@@ -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 */
 };
 
-- 
1.7.12

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux