staging: comedi: dt3000: remove 'phys_addr' from the private data
PATCH 67/90 staging: comedi: dt3000: remove 'phys_addr' from the private data
The 'phys_addr' variable in the private data is simply used as a flag for the detach function to know that the pci device has been enabled. Use the 'dev->iobase' variable instead as is more typical for other comedi pci drivers.
--- drivers/staging/comedi/drivers/dt3000.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/staging/comedi/drivers/dt3000.c +3 -4
@@ -250,7 +250,6 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {struct dt3k_private {struct pci_dev *pci_dev; -resource_size_t phys_addr;void __iomem *io_addr;unsigned int lock;unsigned int ao_readback[2 ];
@@ -824,8 +823,8 @@ static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it)if (ret <0 )return ret; - devpriv->phys_addr =pci_resource_start (pcidev,0 ); - devpriv->io_addr =ioremap (devpriv->phys_addr,DT3000_SIZE ); + dev->iobase =pci_resource_start (pcidev,0 ); + devpriv->io_addr =ioremap (dev->iobase,DT3000_SIZE );if (!devpriv->io_addr)return -ENOMEM ;
@@ -905,7 +904,7 @@ static void dt3000_detach(struct comedi_device *dev)free_irq (dev->irq, dev);if (devpriv) {if (devpriv->pci_dev) { -if (devpriv->phys_addr) +if (dev->iobase)comedi_pci_disable (devpriv->pci_dev);pci_dev_put (devpriv->pci_dev); }
Signature · 1 line
1.7.11
Quoted 4 lines · H Hartley Sweeten
The '
phys_addr' variable in the private data is simply used as a flag for the detach function to know that the pci device has been enabled. Use the 'dev->iobase' variable instead as is more typical for other comedi pci drivers.
I think dev->iobase is really only meant to hold I/O port addresses, although it is wide enough to hold a 32-bit PCI memory address.
Quoted 20 lines
Signed-off-by H Hartley Sweeten <[email protected]>Cc Ian Abbott <[email protected]>Cc Greg Kroah-Hartman <[email protected]>--- drivers/staging/comedi/drivers/dt3000.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/staging/comedi/drivers/dt3000.c +0
-1@@ -250,7 +250,6 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = {struct dt3k_private {struct pci_dev *pci_dev; -resource_size_t phys_addr;void __iomem *io_addr;unsigned int lock;unsigned int ao_readback[2 ];
drivers/staging/comedi/drivers/dt3000.c static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it) · line 827
Quoted 7 lines
drivers/staging/comedi/drivers/dt3000.c +2
-2@@ -824,8 +823,8 @@ static int dt3000_attach(struct comedi_device *dev, struct comedi_devconfig *it)if (ret <0 )return ret; - devpriv->phys_addr =pci_resource_start (pcidev,0 ); - devpriv->io_addr =ioremap (devpriv->phys_addr,DT3000_SIZE ); + dev->iobase =pci_resource_start (pcidev,0 ); + devpriv->io_addr =ioremap (dev->iobase,DT3000_SIZE );
dev->iobase is an unsigned long, which may be narrower than a resource_size_t. You should really pass the full-width resource_size_t value to ioremap().
You could even set dev->iobase to some dummy non-zero value as a flag for the detach() routine to call comedi_pci_disable() as dev->iobase is not used for anything else.
Quoted 13 lines
drivers/staging/comedi/drivers/dt3000.c +1
-1if (!devpriv->io_addr)return -ENOMEM ;@@ -905,7 +904,7 @@ static void dt3000_detach(struct comedi_device *dev)free_irq (dev->irq, dev);if (devpriv) {if (devpriv->pci_dev) { -if (devpriv->phys_addr) +if (dev->iobase)comedi_pci_disable (devpriv->pci_dev);pci_dev_put (devpriv->pci_dev); }
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-