static unsigned int labpc_readb(struct comedi_device *dev, unsigned long reg)
{
- void __iomem *mmio = (void __iomem *)dev->iobase;
-
- return readb(mmio + reg);
+ return readb(dev->mmio + reg);
}
static void labpc_writeb(struct comedi_device *dev,
unsigned int byte, unsigned long reg)
{
- void __iomem *mmio = (void __iomem *)dev->iobase;
-
- writeb(byte, mmio + reg);
+ writeb(byte, dev->mmio + reg);
}
#if IS_ENABLED(CONFIG_COMEDI_NI_LABPC_ISA)
unsigned int count,
unsigned int mode)
{
- const struct labpc_boardinfo *board = comedi_board(dev);
-
- if (board->has_mmio) {
- 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);
+ if (dev->mmio) {
+ i8254_mm_set_mode(dev->mmio + reg, 0, counter_number, mode);
+ i8254_mm_write(dev->mmio + reg, 0, counter_number, count);
} else {
i8254_set_mode(dev->iobase + reg, 0, counter_number, mode);
i8254_write(dev->iobase + reg, 0, counter_number, count);
unsigned int counter_number,
unsigned int mode)
{
- const struct labpc_boardinfo *board = comedi_board(dev);
-
- if (board->has_mmio) {
- void __iomem *mmio = (void __iomem *)dev->iobase;
-
- i8254_mm_set_mode(mmio + reg, 0, counter_number, mode);
- } else {
+ if (dev->mmio)
+ i8254_mm_set_mode(dev->mmio + reg, 0, counter_number, mode);
+ else
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_8255_mmio(int dir, int port, int data, unsigned long arg)
{
struct comedi_device *dev = (struct comedi_device *)arg;
- void __iomem *mmio = (void __iomem *)dev->iobase + DIO_BASE_REG;
if (dir) {
- writeb(data, mmio + port);
+ writeb(data, dev->mmio + DIO_BASE_REG + port);
return 0;
}
- return readb(mmio + port);
+ return readb(dev->mmio + DIO_BASE_REG + port);
}
/* lowlevel write to eeprom/dac */
int ret;
int i;
- if (board->has_mmio) {
+ if (dev->mmio) {
devpriv->read_byte = labpc_readb;
devpriv->write_byte = labpc_writeb;
} else {
/* 8255 dio */
s = &dev->subdevices[2];
- if (board->has_mmio) {
+ if (dev->mmio) {
ret = subdev_8255_init(dev, s, labpc_8255_mmio,
(unsigned long)dev);
} else {
.ai_scan_up = 1,
.has_ao = 1,
.is_labpc1200 = 1,
- .has_mmio = 1,
},
};
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
const struct labpc_boardinfo *board = NULL;
struct labpc_private *devpriv;
- void __iomem *mmio;
int ret;
if (context < ARRAY_SIZE(labpc_pci_boards))
if (ret)
return ret;
- mmio = pci_ioremap_bar(pcidev, 1);
- if (!mmio)
+ dev->mmio = pci_ioremap_bar(pcidev, 1);
+ if (!dev->mmio)
return -ENOMEM;
- dev->iobase = (unsigned long)mmio;
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
static void labpc_pci_detach(struct comedi_device *dev)
{
- if (dev->iobase)
- iounmap((void __iomem *)dev->iobase);
+ if (dev->mmio)
+ iounmap(dev->mmio);
if (dev->irq)
free_irq(dev->irq, dev);
comedi_pci_disable(dev);