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

staging: comedi: adl_pci9118: 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.
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 6a7b1b0c
......@@ -250,7 +250,6 @@ struct boardtype {
struct pci9118_private {
unsigned long iobase_a; /* base+size for AMCC chip */
unsigned int master; /* master capable */
struct pci_dev *pcidev; /* ptr to actual pcidev */
unsigned int usemux; /* we want to use external multiplexor! */
#ifdef PCI9118_PARANOIDCHECK
unsigned short chanlist[PCI9118_CHANLEN + 1]; /*
......@@ -2151,6 +2150,7 @@ static struct pci_dev *pci9118_find_pci(struct comedi_device *dev,
static int pci9118_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
struct pci_dev *pcidev;
struct comedi_subdevice *s;
int ret, pages, i;
unsigned short master;
......@@ -2170,16 +2170,17 @@ static int pci9118_attach(struct comedi_device *dev,
return -ENOMEM;
}
devpriv->pcidev = pci9118_find_pci(dev, it);
if (!devpriv->pcidev)
pcidev = pci9118_find_pci(dev, it);
if (!pcidev)
return -EIO;
comedi_set_hw_dev(dev, &pcidev->dev);
if (master)
pci_set_master(devpriv->pcidev);
pci_set_master(pcidev);
irq = devpriv->pcidev->irq;
devpriv->iobase_a = pci_resource_start(devpriv->pcidev, 0);
dev->iobase = pci_resource_start(devpriv->pcidev, 2);
irq = pcidev->irq;
devpriv->iobase_a = pci_resource_start(pcidev, 0);
dev->iobase = pci_resource_start(pcidev, 2);
dev->board_name = this_board->name;
......@@ -2264,8 +2265,8 @@ static int pci9118_attach(struct comedi_device *dev,
printk(".\n");
pci_read_config_word(devpriv->pcidev, PCI_COMMAND, &u16w);
pci_write_config_word(devpriv->pcidev, PCI_COMMAND, u16w | 64);
pci_read_config_word(pcidev, PCI_COMMAND, &u16w);
pci_write_config_word(pcidev, PCI_COMMAND, u16w | 64);
/* Enable parity check for parity error */
ret = comedi_alloc_subdevices(dev, 4);
......@@ -2343,17 +2344,13 @@ static int pci9118_attach(struct comedi_device *dev,
static void pci9118_detach(struct comedi_device *dev)
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
if (dev->private) {
if (devpriv->valid)
pci9118_reset(dev);
if (dev->irq)
free_irq(dev->irq, dev);
if (devpriv->pcidev) {
if (dev->iobase)
comedi_pci_disable(devpriv->pcidev);
pci_dev_put(devpriv->pcidev);
}
if (devpriv->dmabuf_virt[0])
free_pages((unsigned long)devpriv->dmabuf_virt[0],
devpriv->dmabuf_pages[0]);
......@@ -2361,6 +2358,12 @@ static void pci9118_detach(struct comedi_device *dev)
free_pages((unsigned long)devpriv->dmabuf_virt[1],
devpriv->dmabuf_pages[1]);
}
if (pcidev) {
if (dev->iobase)
comedi_pci_disable(pcidev);
pci_dev_put(pcidev);
}
}
static const struct boardtype boardtypes[] = {
......
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