staging: comedi: ni_labpc: use the comedi_device 'mmio' member
Use the new 'mmio' member in the comedi_device for the ioremap'ed base address. Only the ni_labpc_pci module does the ioremap, its also the only module that sets the 'has_mmio' member in the boardinfo. Remove this member from the boardinfo and use dev->mmio to determine if the I/O is memory mapped. 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
adcd16a298
commit
70f7286714
@ -141,17 +141,13 @@ static void labpc_outb(struct comedi_device *dev,
|
|||||||
|
|
||||||
static unsigned int labpc_readb(struct comedi_device *dev, unsigned long reg)
|
static unsigned int labpc_readb(struct comedi_device *dev, unsigned long reg)
|
||||||
{
|
{
|
||||||
void __iomem *mmio = (void __iomem *)dev->iobase;
|
return readb(dev->mmio + reg);
|
||||||
|
|
||||||
return readb(mmio + reg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void labpc_writeb(struct comedi_device *dev,
|
static void labpc_writeb(struct comedi_device *dev,
|
||||||
unsigned int byte, unsigned long reg)
|
unsigned int byte, unsigned long reg)
|
||||||
{
|
{
|
||||||
void __iomem *mmio = (void __iomem *)dev->iobase;
|
writeb(byte, dev->mmio + reg);
|
||||||
|
|
||||||
writeb(byte, mmio + reg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if IS_ENABLED(CONFIG_COMEDI_NI_LABPC_ISA)
|
#if IS_ENABLED(CONFIG_COMEDI_NI_LABPC_ISA)
|
||||||
@ -181,13 +177,9 @@ static void labpc_counter_load(struct comedi_device *dev,
|
|||||||
unsigned int count,
|
unsigned int count,
|
||||||
unsigned int mode)
|
unsigned int mode)
|
||||||
{
|
{
|
||||||
const struct labpc_boardinfo *board = comedi_board(dev);
|
if (dev->mmio) {
|
||||||
|
i8254_mm_set_mode(dev->mmio + reg, 0, counter_number, mode);
|
||||||
if (board->has_mmio) {
|
i8254_mm_write(dev->mmio + reg, 0, counter_number, count);
|
||||||
void __iomem *mmio = (void __iomem *)dev->iobase;
|
|
||||||
|
|
||||||
i8254_mm_set_mode(mmio + reg, 0, counter_number, mode);
|
|
||||||
i8254_mm_write(mmio + reg, 0, counter_number, count);
|
|
||||||
} else {
|
} else {
|
||||||
i8254_set_mode(dev->iobase + reg, 0, counter_number, mode);
|
i8254_set_mode(dev->iobase + reg, 0, counter_number, mode);
|
||||||
i8254_write(dev->iobase + reg, 0, counter_number, count);
|
i8254_write(dev->iobase + reg, 0, counter_number, count);
|
||||||
@ -199,15 +191,10 @@ static void labpc_counter_set_mode(struct comedi_device *dev,
|
|||||||
unsigned int counter_number,
|
unsigned int counter_number,
|
||||||
unsigned int mode)
|
unsigned int mode)
|
||||||
{
|
{
|
||||||
const struct labpc_boardinfo *board = comedi_board(dev);
|
if (dev->mmio)
|
||||||
|
i8254_mm_set_mode(dev->mmio + reg, 0, counter_number, mode);
|
||||||
if (board->has_mmio) {
|
else
|
||||||
void __iomem *mmio = (void __iomem *)dev->iobase;
|
|
||||||
|
|
||||||
i8254_mm_set_mode(mmio + reg, 0, counter_number, mode);
|
|
||||||
} else {
|
|
||||||
i8254_set_mode(dev->iobase + reg, 0, counter_number, mode);
|
i8254_set_mode(dev->iobase + reg, 0, counter_number, mode);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
|
static int labpc_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
|
||||||
@ -1051,14 +1038,13 @@ static int labpc_ao_insn_read(struct comedi_device *dev,
|
|||||||
static int labpc_8255_mmio(int dir, int port, int data, unsigned long arg)
|
static int labpc_8255_mmio(int dir, int port, int data, unsigned long arg)
|
||||||
{
|
{
|
||||||
struct comedi_device *dev = (struct comedi_device *)arg;
|
struct comedi_device *dev = (struct comedi_device *)arg;
|
||||||
void __iomem *mmio = (void __iomem *)dev->iobase + DIO_BASE_REG;
|
|
||||||
|
|
||||||
if (dir) {
|
if (dir) {
|
||||||
writeb(data, mmio + port);
|
writeb(data, dev->mmio + DIO_BASE_REG + port);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return readb(mmio + port);
|
return readb(dev->mmio + DIO_BASE_REG + port);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* lowlevel write to eeprom/dac */
|
/* lowlevel write to eeprom/dac */
|
||||||
@ -1342,7 +1328,7 @@ int labpc_common_attach(struct comedi_device *dev,
|
|||||||
int ret;
|
int ret;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (board->has_mmio) {
|
if (dev->mmio) {
|
||||||
devpriv->read_byte = labpc_readb;
|
devpriv->read_byte = labpc_readb;
|
||||||
devpriv->write_byte = labpc_writeb;
|
devpriv->write_byte = labpc_writeb;
|
||||||
} else {
|
} else {
|
||||||
@ -1416,7 +1402,7 @@ int labpc_common_attach(struct comedi_device *dev,
|
|||||||
|
|
||||||
/* 8255 dio */
|
/* 8255 dio */
|
||||||
s = &dev->subdevices[2];
|
s = &dev->subdevices[2];
|
||||||
if (board->has_mmio) {
|
if (dev->mmio) {
|
||||||
ret = subdev_8255_init(dev, s, labpc_8255_mmio,
|
ret = subdev_8255_init(dev, s, labpc_8255_mmio,
|
||||||
(unsigned long)dev);
|
(unsigned long)dev);
|
||||||
} else {
|
} else {
|
||||||
|
@ -32,7 +32,6 @@ struct labpc_boardinfo {
|
|||||||
unsigned ai_scan_up:1; /* can auto scan up in ai channels */
|
unsigned ai_scan_up:1; /* can auto scan up in ai channels */
|
||||||
unsigned has_ao:1; /* has analog outputs */
|
unsigned has_ao:1; /* has analog outputs */
|
||||||
unsigned is_labpc1200:1; /* has extra regs compared to pc+ */
|
unsigned is_labpc1200:1; /* has extra regs compared to pc+ */
|
||||||
unsigned has_mmio:1; /* uses memory mapped io */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct labpc_private {
|
struct labpc_private {
|
||||||
|
@ -48,7 +48,6 @@ static const struct labpc_boardinfo labpc_pci_boards[] = {
|
|||||||
.ai_scan_up = 1,
|
.ai_scan_up = 1,
|
||||||
.has_ao = 1,
|
.has_ao = 1,
|
||||||
.is_labpc1200 = 1,
|
.is_labpc1200 = 1,
|
||||||
.has_mmio = 1,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -81,7 +80,6 @@ static int labpc_pci_auto_attach(struct comedi_device *dev,
|
|||||||
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
|
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
|
||||||
const struct labpc_boardinfo *board = NULL;
|
const struct labpc_boardinfo *board = NULL;
|
||||||
struct labpc_private *devpriv;
|
struct labpc_private *devpriv;
|
||||||
void __iomem *mmio;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (context < ARRAY_SIZE(labpc_pci_boards))
|
if (context < ARRAY_SIZE(labpc_pci_boards))
|
||||||
@ -99,10 +97,9 @@ static int labpc_pci_auto_attach(struct comedi_device *dev,
|
|||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
mmio = pci_ioremap_bar(pcidev, 1);
|
dev->mmio = pci_ioremap_bar(pcidev, 1);
|
||||||
if (!mmio)
|
if (!dev->mmio)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
dev->iobase = (unsigned long)mmio;
|
|
||||||
|
|
||||||
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
|
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
|
||||||
if (!devpriv)
|
if (!devpriv)
|
||||||
@ -113,8 +110,8 @@ static int labpc_pci_auto_attach(struct comedi_device *dev,
|
|||||||
|
|
||||||
static void labpc_pci_detach(struct comedi_device *dev)
|
static void labpc_pci_detach(struct comedi_device *dev)
|
||||||
{
|
{
|
||||||
if (dev->iobase)
|
if (dev->mmio)
|
||||||
iounmap((void __iomem *)dev->iobase);
|
iounmap(dev->mmio);
|
||||||
if (dev->irq)
|
if (dev->irq)
|
||||||
free_irq(dev->irq, dev);
|
free_irq(dev->irq, dev);
|
||||||
comedi_pci_disable(dev);
|
comedi_pci_disable(dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user