From: H Hartley Sweeten Date: Tue, 29 Jul 2014 22:01:26 +0000 (-0700) Subject: staging: comedi: icp_multi: use the comedi_device 'mmio' member X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=a3e63288103ccdda45f741a4dad22cb7f12ea105;p=linux-beck.git staging: comedi: icp_multi: use the comedi_device 'mmio' member Use the new 'mmio' member in the comedi_device for the ioremap'ed base address. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/icp_multi.c b/drivers/staging/comedi/drivers/icp_multi.c index e646958980f3..a98cef2106a9 100644 --- a/drivers/staging/comedi/drivers/icp_multi.c +++ b/drivers/staging/comedi/drivers/icp_multi.c @@ -108,7 +108,6 @@ static const char range_codes_analog[] = { 0x00, 0x20, 0x10, 0x30 }; struct icp_multi_private { char valid; /* card is usable */ - void __iomem *io_addr; /* Pointer to mapped io address */ unsigned int AdcCmdStatus; /* ADC Command/Status register */ unsigned int DacCmdStatus; /* DAC Command/Status register */ unsigned int IntEnable; /* Interrupt Enable register */ @@ -164,8 +163,7 @@ static void setup_channel_list(struct comedi_device *dev, devpriv->AdcCmdStatus |= range; /* Output channel, range, mode to ICP Multi */ - writew(devpriv->AdcCmdStatus, - devpriv->io_addr + ICP_MULTI_ADC_CSR); + writew(devpriv->AdcCmdStatus, dev->mmio + ICP_MULTI_ADC_CSR); } } @@ -174,10 +172,9 @@ static int icp_multi_ai_eoc(struct comedi_device *dev, struct comedi_insn *insn, unsigned long context) { - struct icp_multi_private *devpriv = dev->private; unsigned int status; - status = readw(devpriv->io_addr + ICP_MULTI_ADC_CSR); + status = readw(dev->mmio + ICP_MULTI_ADC_CSR); if ((status & ADC_BSY) == 0) return 0; return -EBUSY; @@ -185,7 +182,8 @@ static int icp_multi_ai_eoc(struct comedi_device *dev, static int icp_multi_insn_read_ai(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { struct icp_multi_private *devpriv = dev->private; int ret = 0; @@ -193,11 +191,11 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, /* Disable A/D conversion ready interrupt */ devpriv->IntEnable &= ~ADC_READY; - writew(devpriv->IntEnable, devpriv->io_addr + ICP_MULTI_INT_EN); + writew(devpriv->IntEnable, dev->mmio + ICP_MULTI_INT_EN); /* Clear interrupt status */ devpriv->IntStatus |= ADC_READY; - writew(devpriv->IntStatus, devpriv->io_addr + ICP_MULTI_INT_STAT); + writew(devpriv->IntStatus, dev->mmio + ICP_MULTI_INT_STAT); /* Set up appropriate channel, mode and range data, for specified ch */ setup_channel_list(dev, s, &insn->chanspec, 1); @@ -205,8 +203,7 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, for (n = 0; n < insn->n; n++) { /* Set start ADC bit */ devpriv->AdcCmdStatus |= ADC_ST; - writew(devpriv->AdcCmdStatus, - devpriv->io_addr + ICP_MULTI_ADC_CSR); + writew(devpriv->AdcCmdStatus, dev->mmio + ICP_MULTI_ADC_CSR); devpriv->AdcCmdStatus &= ~ADC_ST; udelay(1); @@ -216,17 +213,16 @@ static int icp_multi_insn_read_ai(struct comedi_device *dev, if (ret) break; - data[n] = - (readw(devpriv->io_addr + ICP_MULTI_AI) >> 4) & 0x0fff; + data[n] = (readw(dev->mmio + ICP_MULTI_AI) >> 4) & 0x0fff; } /* Disable interrupt */ devpriv->IntEnable &= ~ADC_READY; - writew(devpriv->IntEnable, devpriv->io_addr + ICP_MULTI_INT_EN); + writew(devpriv->IntEnable, dev->mmio + ICP_MULTI_INT_EN); /* Clear interrupt status */ devpriv->IntStatus |= ADC_READY; - writew(devpriv->IntStatus, devpriv->io_addr + ICP_MULTI_INT_STAT); + writew(devpriv->IntStatus, dev->mmio + ICP_MULTI_INT_STAT); return ret ? ret : n; } @@ -236,10 +232,9 @@ static int icp_multi_ao_eoc(struct comedi_device *dev, struct comedi_insn *insn, unsigned long context) { - struct icp_multi_private *devpriv = dev->private; unsigned int status; - status = readw(devpriv->io_addr + ICP_MULTI_DAC_CSR); + status = readw(dev->mmio + ICP_MULTI_DAC_CSR); if ((status & DAC_BSY) == 0) return 0; return -EBUSY; @@ -247,7 +242,8 @@ static int icp_multi_ao_eoc(struct comedi_device *dev, static int icp_multi_insn_write_ao(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { struct icp_multi_private *devpriv = dev->private; int n, chan, range; @@ -255,11 +251,11 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, /* Disable D/A conversion ready interrupt */ devpriv->IntEnable &= ~DAC_READY; - writew(devpriv->IntEnable, devpriv->io_addr + ICP_MULTI_INT_EN); + writew(devpriv->IntEnable, dev->mmio + ICP_MULTI_INT_EN); /* Clear interrupt status */ devpriv->IntStatus |= DAC_READY; - writew(devpriv->IntStatus, devpriv->io_addr + ICP_MULTI_INT_STAT); + writew(devpriv->IntStatus, dev->mmio + ICP_MULTI_INT_STAT); /* Get channel number and range */ chan = CR_CHAN(insn->chanspec); @@ -274,7 +270,7 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, devpriv->DacCmdStatus |= range_codes_analog[range]; devpriv->DacCmdStatus |= (chan << 8); - writew(devpriv->DacCmdStatus, devpriv->io_addr + ICP_MULTI_DAC_CSR); + writew(devpriv->DacCmdStatus, dev->mmio + ICP_MULTI_DAC_CSR); for (n = 0; n < insn->n; n++) { /* Wait for analogue output data register to be @@ -284,12 +280,12 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, /* Disable interrupt */ devpriv->IntEnable &= ~DAC_READY; writew(devpriv->IntEnable, - devpriv->io_addr + ICP_MULTI_INT_EN); + dev->mmio + ICP_MULTI_INT_EN); /* Clear interrupt status */ devpriv->IntStatus |= DAC_READY; writew(devpriv->IntStatus, - devpriv->io_addr + ICP_MULTI_INT_STAT); + dev->mmio + ICP_MULTI_INT_STAT); /* Clear data received */ devpriv->ao_data[chan] = 0; @@ -298,12 +294,11 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev, } /* Write data to analogue output data register */ - writew(data[n], devpriv->io_addr + ICP_MULTI_AO); + writew(data[n], dev->mmio + ICP_MULTI_AO); /* Set DAC_ST bit to write the data to selected channel */ devpriv->DacCmdStatus |= DAC_ST; - writew(devpriv->DacCmdStatus, - devpriv->io_addr + ICP_MULTI_DAC_CSR); + writew(devpriv->DacCmdStatus, dev->mmio + ICP_MULTI_DAC_CSR); devpriv->DacCmdStatus &= ~DAC_ST; /* Save analogue output data */ @@ -332,11 +327,10 @@ static int icp_multi_insn_read_ao(struct comedi_device *dev, static int icp_multi_insn_bits_di(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - struct icp_multi_private *devpriv = dev->private; - - data[1] = readw(devpriv->io_addr + ICP_MULTI_DI); + data[1] = readw(dev->mmio + ICP_MULTI_DI); return insn->n; } @@ -346,12 +340,10 @@ static int icp_multi_insn_bits_do(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct icp_multi_private *devpriv = dev->private; - if (comedi_dio_update_state(s, data)) - writew(s->state, devpriv->io_addr + ICP_MULTI_DO); + writew(s->state, dev->mmio + ICP_MULTI_DO); - data[1] = readw(devpriv->io_addr + ICP_MULTI_DI); + data[1] = readw(dev->mmio + ICP_MULTI_DI); return insn->n; } @@ -374,11 +366,10 @@ static int icp_multi_insn_write_ctr(struct comedi_device *dev, static irqreturn_t interrupt_service_icp_multi(int irq, void *d) { struct comedi_device *dev = d; - struct icp_multi_private *devpriv = dev->private; int int_no; /* Is this interrupt from our board? */ - int_no = readw(devpriv->io_addr + ICP_MULTI_INT_STAT) & Status_IRQ; + int_no = readw(dev->mmio + ICP_MULTI_INT_STAT) & Status_IRQ; if (!int_no) /* No, exit */ return IRQ_NONE; @@ -448,8 +439,8 @@ static int icp_multi_reset(struct comedi_device *dev) unsigned int i; /* Clear INT enables and requests */ - writew(0, devpriv->io_addr + ICP_MULTI_INT_EN); - writew(0x00ff, devpriv->io_addr + ICP_MULTI_INT_STAT); + writew(0, dev->mmio + ICP_MULTI_INT_EN); + writew(0x00ff, dev->mmio + ICP_MULTI_INT_STAT); /* Set DACs to 0..5V range and 0V output */ for (i = 0; i < 4; i++) { @@ -459,21 +450,20 @@ static int icp_multi_reset(struct comedi_device *dev) devpriv->DacCmdStatus |= (i << 8); /* Output 0V */ - writew(0, devpriv->io_addr + ICP_MULTI_AO); + writew(0, dev->mmio + ICP_MULTI_AO); /* Set start conversion bit */ devpriv->DacCmdStatus |= DAC_ST; /* Output to command / status register */ - writew(devpriv->DacCmdStatus, - devpriv->io_addr + ICP_MULTI_DAC_CSR); + writew(devpriv->DacCmdStatus, dev->mmio + ICP_MULTI_DAC_CSR); /* Delay to allow DAC time to recover */ udelay(1); } /* Digital outputs to 0 */ - writew(0, devpriv->io_addr + ICP_MULTI_DO); + writew(0, dev->mmio + ICP_MULTI_DO); return 0; } @@ -494,8 +484,8 @@ static int icp_multi_auto_attach(struct comedi_device *dev, if (ret) return ret; - devpriv->io_addr = pci_ioremap_bar(pcidev, 2); - if (!devpriv->io_addr) + dev->mmio = pci_ioremap_bar(pcidev, 2); + if (!dev->mmio) return -ENOMEM; ret = comedi_alloc_subdevices(dev, 5); @@ -573,8 +563,8 @@ static void icp_multi_detach(struct comedi_device *dev) icp_multi_reset(dev); if (dev->irq) free_irq(dev->irq, dev); - if (devpriv && devpriv->io_addr) - iounmap(devpriv->io_addr); + if (dev->mmio) + iounmap(dev->mmio); comedi_pci_disable(dev); }