staging: comedi: amplc_dio200: use the comedi_device 'mmio' member
The amplc_dio200_common module currently uses a union in the private data to determine if the hardware uses port or memory mapped I/O. Use the new 'mmio' member in the comedi_device for the ioremap'ed base address and remove all the union code. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
d6e497b92f
commit
0c3dfdc2d9
@ -278,8 +278,7 @@ static int dio200_attach(struct comedi_device *dev, struct comedi_devconfig *it)
|
||||
ret = comedi_request_region(dev, it->options[0], thisboard->mainsize);
|
||||
if (ret)
|
||||
return ret;
|
||||
devpriv->io.u.iobase = dev->iobase;
|
||||
devpriv->io.regtype = io_regtype;
|
||||
|
||||
return amplc_dio200_common_attach(dev, irq, 0);
|
||||
}
|
||||
|
||||
|
@ -27,18 +27,6 @@
|
||||
#define DIO200_IO_SIZE 0x20
|
||||
#define DIO200_PCIE_IO_SIZE 0x4000
|
||||
|
||||
/*
|
||||
* Register region.
|
||||
*/
|
||||
enum dio200_regtype { no_regtype = 0, io_regtype, mmio_regtype };
|
||||
struct dio200_region {
|
||||
union {
|
||||
unsigned long iobase; /* I/O base address */
|
||||
unsigned char __iomem *membase; /* mapped MMIO base address */
|
||||
} u;
|
||||
enum dio200_regtype regtype;
|
||||
};
|
||||
|
||||
/*
|
||||
* Subdevice types.
|
||||
*/
|
||||
@ -75,7 +63,6 @@ struct dio200_board {
|
||||
* Comedi device private data.
|
||||
*/
|
||||
struct dio200_private {
|
||||
struct dio200_region io; /* Register region */
|
||||
int intr_sd;
|
||||
};
|
||||
|
||||
|
@ -151,13 +151,12 @@ static unsigned char dio200_read8(struct comedi_device *dev,
|
||||
unsigned int offset)
|
||||
{
|
||||
const struct dio200_board *thisboard = comedi_board(dev);
|
||||
struct dio200_private *devpriv = dev->private;
|
||||
|
||||
offset <<= thisboard->mainshift;
|
||||
if (devpriv->io.regtype == io_regtype)
|
||||
return inb(devpriv->io.u.iobase + offset);
|
||||
|
||||
return readb(devpriv->io.u.membase + offset);
|
||||
if (dev->mmio)
|
||||
return readb(dev->mmio + offset);
|
||||
return inb(dev->iobase + offset);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -167,13 +166,13 @@ static void dio200_write8(struct comedi_device *dev, unsigned int offset,
|
||||
unsigned char val)
|
||||
{
|
||||
const struct dio200_board *thisboard = comedi_board(dev);
|
||||
struct dio200_private *devpriv = dev->private;
|
||||
|
||||
offset <<= thisboard->mainshift;
|
||||
if (devpriv->io.regtype == io_regtype)
|
||||
outb(val, devpriv->io.u.iobase + offset);
|
||||
|
||||
if (dev->mmio)
|
||||
writeb(val, dev->mmio + offset);
|
||||
else
|
||||
writeb(val, devpriv->io.u.membase + offset);
|
||||
outb(val, dev->iobase + offset);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -183,13 +182,12 @@ static unsigned int dio200_read32(struct comedi_device *dev,
|
||||
unsigned int offset)
|
||||
{
|
||||
const struct dio200_board *thisboard = comedi_board(dev);
|
||||
struct dio200_private *devpriv = dev->private;
|
||||
|
||||
offset <<= thisboard->mainshift;
|
||||
if (devpriv->io.regtype == io_regtype)
|
||||
return inl(devpriv->io.u.iobase + offset);
|
||||
|
||||
return readl(devpriv->io.u.membase + offset);
|
||||
if (dev->mmio)
|
||||
return readl(dev->mmio + offset);
|
||||
return inl(dev->iobase + offset);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -199,13 +197,13 @@ static void dio200_write32(struct comedi_device *dev, unsigned int offset,
|
||||
unsigned int val)
|
||||
{
|
||||
const struct dio200_board *thisboard = comedi_board(dev);
|
||||
struct dio200_private *devpriv = dev->private;
|
||||
|
||||
offset <<= thisboard->mainshift;
|
||||
if (devpriv->io.regtype == io_regtype)
|
||||
outl(val, devpriv->io.u.iobase + offset);
|
||||
|
||||
if (dev->mmio)
|
||||
writel(val, dev->mmio + offset);
|
||||
else
|
||||
writel(val, devpriv->io.u.membase + offset);
|
||||
outl(val, dev->iobase + offset);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -387,16 +387,14 @@ static int dio200_pci_auto_attach(struct comedi_device *dev,
|
||||
return -EINVAL;
|
||||
}
|
||||
if (pci_resource_flags(pci_dev, bar) & IORESOURCE_MEM) {
|
||||
devpriv->io.u.membase = pci_ioremap_bar(pci_dev, bar);
|
||||
if (!devpriv->io.u.membase) {
|
||||
dev->mmio = pci_ioremap_bar(pci_dev, bar);
|
||||
if (!dev->mmio) {
|
||||
dev_err(dev->class_dev,
|
||||
"error! cannot remap registers\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
devpriv->io.regtype = mmio_regtype;
|
||||
} else {
|
||||
devpriv->io.u.iobase = pci_resource_start(pci_dev, bar);
|
||||
devpriv->io.regtype = io_regtype;
|
||||
dev->iobase = pci_resource_start(pci_dev, bar);
|
||||
}
|
||||
switch (context_model) {
|
||||
case pcie215_model:
|
||||
@ -414,11 +412,9 @@ static int dio200_pci_auto_attach(struct comedi_device *dev,
|
||||
|
||||
static void dio200_pci_detach(struct comedi_device *dev)
|
||||
{
|
||||
struct dio200_private *devpriv = dev->private;
|
||||
|
||||
amplc_dio200_common_detach(dev);
|
||||
if (devpriv && devpriv->io.regtype == mmio_regtype)
|
||||
iounmap(devpriv->io.u.membase);
|
||||
if (dev->mmio)
|
||||
iounmap(dev->mmio);
|
||||
comedi_pci_disable(dev);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user