Commit fd67ad44 authored by Ian Abbott's avatar Ian Abbott Committed by Greg Kroah-Hartman

staging: comedi: gsc_hpdi: remove devpriv->hw_dev

The `hw_dev` member of `struct hpdi_private` is used to point to the
`struct pci_dev`.  This is redundant as the `struct comedi_device`
already has a pointer to the `struct device` within the `struct pci_dev`
and there is a convenient inline function, `comedi_to_pci_dev(dev)` that
returns a pointer to the `struct pci_dev`.

Remove the redundant `hw_dev` member and use alternate ways to get at
the `struct pci_dev`.
Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4e95df1f
...@@ -213,8 +213,6 @@ static inline struct hpdi_board *board(const struct comedi_device *dev) ...@@ -213,8 +213,6 @@ static inline struct hpdi_board *board(const struct comedi_device *dev)
} }
struct hpdi_private { struct hpdi_private {
struct pci_dev *hw_dev; /* pointer to board's pci_dev struct */
/* base addresses (physical) */ /* base addresses (physical) */
resource_size_t plx9080_phys_iobase; resource_size_t plx9080_phys_iobase;
resource_size_t hpdi_phys_iobase; resource_size_t hpdi_phys_iobase;
...@@ -502,7 +500,6 @@ static int __devinit hpdi_auto_attach(struct comedi_device *dev, ...@@ -502,7 +500,6 @@ static int __devinit hpdi_auto_attach(struct comedi_device *dev,
if (!devpriv) if (!devpriv)
return -ENOMEM; return -ENOMEM;
dev->private = devpriv; dev->private = devpriv;
devpriv->hw_dev = pcidev;
if (comedi_pci_enable(pcidev, dev->driver->driver_name)) { if (comedi_pci_enable(pcidev, dev->driver->driver_name)) {
dev_warn(dev->class_dev, dev_warn(dev->class_dev,
...@@ -550,18 +547,17 @@ static int __devinit hpdi_auto_attach(struct comedi_device *dev, ...@@ -550,18 +547,17 @@ static int __devinit hpdi_auto_attach(struct comedi_device *dev,
/* allocate pci dma buffers */ /* allocate pci dma buffers */
for (i = 0; i < NUM_DMA_BUFFERS; i++) { for (i = 0; i < NUM_DMA_BUFFERS; i++) {
devpriv->dio_buffer[i] = devpriv->dio_buffer[i] =
pci_alloc_consistent(devpriv->hw_dev, DMA_BUFFER_SIZE, pci_alloc_consistent(pcidev, DMA_BUFFER_SIZE,
&devpriv->dio_buffer_phys_addr[i]); &devpriv->dio_buffer_phys_addr[i]);
DEBUG_PRINT("dio_buffer at virt 0x%p, phys 0x%lx\n", DEBUG_PRINT("dio_buffer at virt 0x%p, phys 0x%lx\n",
devpriv->dio_buffer[i], devpriv->dio_buffer[i],
(unsigned long)devpriv->dio_buffer_phys_addr[i]); (unsigned long)devpriv->dio_buffer_phys_addr[i]);
} }
/* allocate dma descriptors */ /* allocate dma descriptors */
devpriv->dma_desc = pci_alloc_consistent(devpriv->hw_dev, devpriv->dma_desc = pci_alloc_consistent(pcidev,
sizeof(struct plx_dma_desc) * sizeof(struct plx_dma_desc) *
NUM_DMA_DESCRIPTORS, NUM_DMA_DESCRIPTORS,
&devpriv-> &devpriv->dma_desc_phys_addr);
dma_desc_phys_addr);
if (devpriv->dma_desc_phys_addr & 0xf) { if (devpriv->dma_desc_phys_addr & 0xf) {
dev_warn(dev->class_dev, dev_warn(dev->class_dev,
" dma descriptors not quad-word aligned (bug)\n"); " dma descriptors not quad-word aligned (bug)\n");
...@@ -581,12 +577,13 @@ static int __devinit hpdi_auto_attach(struct comedi_device *dev, ...@@ -581,12 +577,13 @@ static int __devinit hpdi_auto_attach(struct comedi_device *dev,
static void hpdi_detach(struct comedi_device *dev) static void hpdi_detach(struct comedi_device *dev)
{ {
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
struct hpdi_private *devpriv = dev->private; struct hpdi_private *devpriv = dev->private;
unsigned int i; unsigned int i;
if (dev->irq) if (dev->irq)
free_irq(dev->irq, dev); free_irq(dev->irq, dev);
if (devpriv && devpriv->hw_dev) { if (devpriv) {
if (devpriv->plx9080_iobase) { if (devpriv->plx9080_iobase) {
disable_plx_interrupts(dev); disable_plx_interrupts(dev);
iounmap(devpriv->plx9080_iobase); iounmap(devpriv->plx9080_iobase);
...@@ -596,20 +593,21 @@ static void hpdi_detach(struct comedi_device *dev) ...@@ -596,20 +593,21 @@ static void hpdi_detach(struct comedi_device *dev)
/* free pci dma buffers */ /* free pci dma buffers */
for (i = 0; i < NUM_DMA_BUFFERS; i++) { for (i = 0; i < NUM_DMA_BUFFERS; i++) {
if (devpriv->dio_buffer[i]) if (devpriv->dio_buffer[i])
pci_free_consistent(devpriv->hw_dev, pci_free_consistent(pcidev,
DMA_BUFFER_SIZE, DMA_BUFFER_SIZE,
devpriv->dio_buffer[i], devpriv->dio_buffer[i],
devpriv->dio_buffer_phys_addr[i]); devpriv->
dio_buffer_phys_addr[i]);
} }
/* free dma descriptors */ /* free dma descriptors */
if (devpriv->dma_desc) if (devpriv->dma_desc)
pci_free_consistent(devpriv->hw_dev, pci_free_consistent(pcidev,
sizeof(struct plx_dma_desc) * sizeof(struct plx_dma_desc) *
NUM_DMA_DESCRIPTORS, NUM_DMA_DESCRIPTORS,
devpriv->dma_desc, devpriv->dma_desc,
devpriv-> dma_desc_phys_addr); devpriv->dma_desc_phys_addr);
if (devpriv->hpdi_phys_iobase) if (devpriv->hpdi_phys_iobase)
comedi_pci_disable(devpriv->hw_dev); comedi_pci_disable(pcidev);
} }
} }
......
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