Commit b6d446b5 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: amplc_pc236: store the pci_dev in the comedi_device

Use the hw_dev pointer in the comedi_device struct to hold the
pci_dev instead of carrying it in the private data.

Since the pci_dev is no longer held in the provate data, we can
also cleanup the detach a bit. Remove the IS_ENABLED() tests in
the detach. If the pci_dev is non NULL it's a PCI device otherwise
it's an ISA device. Using IS_ENABLED() to omit the code paths
makes the code a bit confusing and doesn't save much.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ed7fd225
...@@ -131,8 +131,6 @@ static const struct pc236_board pc236_boards[] = { ...@@ -131,8 +131,6 @@ static const struct pc236_board pc236_boards[] = {
feel free to suggest moving the variable to the struct comedi_device struct. feel free to suggest moving the variable to the struct comedi_device struct.
*/ */
struct pc236_private { struct pc236_private {
/* PCI device */
struct pci_dev *pci_dev;
unsigned long lcr_iobase; /* PLX PCI9052 config registers in PCIBAR1 */ unsigned long lcr_iobase; /* PLX PCI9052 config registers in PCIBAR1 */
int enable_irq; int enable_irq;
}; };
...@@ -412,6 +410,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d) ...@@ -412,6 +410,7 @@ static irqreturn_t pc236_interrupt(int irq, void *d)
static void pc236_report_attach(struct comedi_device *dev, unsigned int irq) static void pc236_report_attach(struct comedi_device *dev, unsigned int irq)
{ {
const struct pc236_board *thisboard = comedi_board(dev); const struct pc236_board *thisboard = comedi_board(dev);
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
char tmpbuf[60]; char tmpbuf[60];
int tmplen; int tmplen;
...@@ -421,10 +420,8 @@ static void pc236_report_attach(struct comedi_device *dev, unsigned int irq) ...@@ -421,10 +420,8 @@ static void pc236_report_attach(struct comedi_device *dev, unsigned int irq)
"(base %#lx) ", dev->iobase); "(base %#lx) ", dev->iobase);
else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) &&
thisboard->bustype == pci_bustype) { thisboard->bustype == pci_bustype) {
struct pc236_private *devpriv = dev->private;
struct pci_dev *pci_dev = devpriv->pci_dev;
tmplen = scnprintf(tmpbuf, sizeof(tmpbuf), tmplen = scnprintf(tmpbuf, sizeof(tmpbuf),
"(pci %s) ", pci_name(pci_dev)); "(pci %s) ", pci_name(pcidev));
} else } else
tmplen = 0; tmplen = 0;
if (irq) if (irq)
...@@ -489,7 +486,8 @@ static int pc236_pci_common_attach(struct comedi_device *dev, ...@@ -489,7 +486,8 @@ static int pc236_pci_common_attach(struct comedi_device *dev,
unsigned long iobase; unsigned long iobase;
int ret; int ret;
devpriv->pci_dev = pci_dev; comedi_set_hw_dev(dev, &pci_dev->dev);
ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME); ret = comedi_pci_enable(pci_dev, PC236_DRIVER_NAME);
if (ret < 0) { if (ret < 0) {
dev_err(dev->class_dev, dev_err(dev->class_dev,
...@@ -573,6 +571,7 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev, ...@@ -573,6 +571,7 @@ static int __devinit pc236_attach_pci(struct comedi_device *dev,
static void pc236_detach(struct comedi_device *dev) static void pc236_detach(struct comedi_device *dev)
{ {
struct pc236_private *devpriv = dev->private; struct pc236_private *devpriv = dev->private;
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
if (devpriv) if (devpriv)
pc236_intr_disable(dev); pc236_intr_disable(dev);
...@@ -580,16 +579,13 @@ static void pc236_detach(struct comedi_device *dev) ...@@ -580,16 +579,13 @@ static void pc236_detach(struct comedi_device *dev)
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
if (dev->subdevices) if (dev->subdevices)
subdev_8255_cleanup(dev, dev->subdevices + 0); subdev_8255_cleanup(dev, dev->subdevices + 0);
if (devpriv) { if (pcidev) {
if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_PCI) && if (dev->iobase)
devpriv->pci_dev) { comedi_pci_disable(pcidev);
if (dev->iobase) pci_dev_put(pcidev);
comedi_pci_disable(devpriv->pci_dev); } else {
pci_dev_put(devpriv->pci_dev); if (dev->iobase)
} else if (IS_ENABLED(CONFIG_COMEDI_AMPLC_PC236_ISA)) { release_region(dev->iobase, PC236_IO_SIZE);
if (dev->iobase)
release_region(dev->iobase, PC236_IO_SIZE);
}
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment