From: H Hartley Sweeten Date: Tue, 29 Jul 2014 22:01:28 +0000 (-0700) Subject: staging: comedi: daqboard2000: use the comedi_device 'mmio' member X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1d14999509569b1aef8c839211f690f2b67f60ff;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git staging: comedi: daqboard2000: 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/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c index ceab88b62a20..cd369cd40114 100644 --- a/drivers/staging/comedi/drivers/daqboard2000.c +++ b/drivers/staging/comedi/drivers/daqboard2000.c @@ -274,19 +274,16 @@ struct daqboard2000_private { enum { card_daqboard_2000 } card; - void __iomem *daq; void __iomem *plx; unsigned int ao_readback[2]; }; static void writeAcqScanListEntry(struct comedi_device *dev, u16 entry) { - struct daqboard2000_private *devpriv = dev->private; - /* udelay(4); */ - writew(entry & 0x00ff, devpriv->daq + acqScanListFIFO); + writew(entry & 0x00ff, dev->mmio + acqScanListFIFO); /* udelay(4); */ - writew((entry >> 8) & 0x00ff, devpriv->daq + acqScanListFIFO); + writew((entry >> 8) & 0x00ff, dev->mmio + acqScanListFIFO); } static void setup_sampling(struct comedi_device *dev, int chan, int gain) @@ -338,10 +335,9 @@ static int daqboard2000_ai_status(struct comedi_device *dev, struct comedi_insn *insn, unsigned long context) { - struct daqboard2000_private *devpriv = dev->private; unsigned int status; - status = readw(devpriv->daq + acqControl); + status = readw(dev->mmio + acqControl); if (status & context) return 0; return -EBUSY; @@ -352,22 +348,21 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct daqboard2000_private *devpriv = dev->private; int gain, chan; int ret; int i; writew(DAQBOARD2000_AcqResetScanListFifo | DAQBOARD2000_AcqResetResultsFifo | - DAQBOARD2000_AcqResetConfigPipe, devpriv->daq + acqControl); + DAQBOARD2000_AcqResetConfigPipe, dev->mmio + acqControl); /* * If pacer clock is not set to some high value (> 10 us), we * risk multiple samples to be put into the result FIFO. */ /* 1 second, should be long enough */ - writel(1000000, devpriv->daq + acqPacerClockDivLow); - writew(0, devpriv->daq + acqPacerClockDivHigh); + writel(1000000, dev->mmio + acqPacerClockDivLow); + writew(0, dev->mmio + acqPacerClockDivHigh); gain = CR_RANGE(insn->chanspec); chan = CR_CHAN(insn->chanspec); @@ -379,15 +374,14 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { setup_sampling(dev, chan, gain); /* Enable reading from the scanlist FIFO */ - writew(DAQBOARD2000_SeqStartScanList, - devpriv->daq + acqControl); + writew(DAQBOARD2000_SeqStartScanList, dev->mmio + acqControl); ret = comedi_timeout(dev, s, insn, daqboard2000_ai_status, DAQBOARD2000_AcqConfigPipeFull); if (ret) return ret; - writew(DAQBOARD2000_AdcPacerEnable, devpriv->daq + acqControl); + writew(DAQBOARD2000_AdcPacerEnable, dev->mmio + acqControl); ret = comedi_timeout(dev, s, insn, daqboard2000_ai_status, DAQBOARD2000_AcqLogicScanning); @@ -399,9 +393,9 @@ static int daqboard2000_ai_insn_read(struct comedi_device *dev, if (ret) return ret; - data[i] = readw(devpriv->daq + acqResultsFIFO); - writew(DAQBOARD2000_AdcPacerDisable, devpriv->daq + acqControl); - writew(DAQBOARD2000_SeqStopScanList, devpriv->daq + acqControl); + data[i] = readw(dev->mmio + acqResultsFIFO); + writew(DAQBOARD2000_AdcPacerDisable, dev->mmio + acqControl); + writew(DAQBOARD2000_SeqStopScanList, dev->mmio + acqControl); } return i; @@ -427,11 +421,10 @@ static int daqboard2000_ao_eoc(struct comedi_device *dev, struct comedi_insn *insn, unsigned long context) { - struct daqboard2000_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); unsigned int status; - status = readw(devpriv->daq + dacControl); + status = readw(dev->mmio + dacControl); if ((status & ((chan + 1) * 0x0010)) == 0) return 0; return -EBUSY; @@ -453,11 +446,10 @@ static int daqboard2000_ao_insn_write(struct comedi_device *dev, * OK, since it works OK without enabling the DAC's, * let's keep it as simple as possible... */ - writew((chan + 2) * 0x0010 | 0x0001, - devpriv->daq + dacControl); + writew((chan + 2) * 0x0010 | 0x0001, dev->mmio + dacControl); udelay(1000); #endif - writew(data[i], devpriv->daq + dacSetting(chan)); + writew(data[i], dev->mmio + dacSetting(chan)); ret = comedi_timeout(dev, s, insn, daqboard2000_ao_eoc, 0); if (ret) @@ -469,8 +461,7 @@ static int daqboard2000_ao_insn_write(struct comedi_device *dev, * Since we never enabled the DAC's, we don't need * to disable it... */ - writew((chan + 2) * 0x0010 | 0x0000, - devpriv->daq + dacControl); + writew((chan + 2) * 0x0010 | 0x0000, dev->mmio + dacControl); udelay(1000); #endif } @@ -512,14 +503,13 @@ static void daqboard2000_pulseProgPin(struct comedi_device *dev) static int daqboard2000_pollCPLD(struct comedi_device *dev, int mask) { - struct daqboard2000_private *devpriv = dev->private; int result = 0; int i; int cpld; /* timeout after 50 tries -> 5ms */ for (i = 0; i < 50; i++) { - cpld = readw(devpriv->daq + 0x1000); + cpld = readw(dev->mmio + 0x1000); if ((cpld & mask) == mask) { result = 1; break; @@ -532,12 +522,11 @@ static int daqboard2000_pollCPLD(struct comedi_device *dev, int mask) static int daqboard2000_writeCPLD(struct comedi_device *dev, int data) { - struct daqboard2000_private *devpriv = dev->private; int result = 0; udelay(10); - writew(data, devpriv->daq + 0x1000); - if ((readw(devpriv->daq + 0x1000) & DAQBOARD2000_CPLD_INIT) == + writew(data, dev->mmio + 0x1000); + if ((readw(dev->mmio + 0x1000) & DAQBOARD2000_CPLD_INIT) == DAQBOARD2000_CPLD_INIT) { result = 1; } @@ -593,23 +582,21 @@ static void daqboard2000_adcStopDmaTransfer(struct comedi_device *dev) static void daqboard2000_adcDisarm(struct comedi_device *dev) { - struct daqboard2000_private *devpriv = dev->private; - /* Disable hardware triggers */ udelay(2); writew(DAQBOARD2000_TrigAnalog | DAQBOARD2000_TrigDisable, - devpriv->daq + trigControl); + dev->mmio + trigControl); udelay(2); writew(DAQBOARD2000_TrigTTL | DAQBOARD2000_TrigDisable, - devpriv->daq + trigControl); + dev->mmio + trigControl); /* Stop the scan list FIFO from loading the configuration pipe */ udelay(2); - writew(DAQBOARD2000_SeqStopScanList, devpriv->daq + acqControl); + writew(DAQBOARD2000_SeqStopScanList, dev->mmio + acqControl); /* Stop the pacer clock */ udelay(2); - writew(DAQBOARD2000_AdcPacerDisable, devpriv->daq + acqControl); + writew(DAQBOARD2000_AdcPacerDisable, dev->mmio + acqControl); /* Stop the input dma (abort channel 1) */ daqboard2000_adcStopDmaTransfer(dev); @@ -617,23 +604,22 @@ static void daqboard2000_adcDisarm(struct comedi_device *dev) static void daqboard2000_activateReferenceDacs(struct comedi_device *dev) { - struct daqboard2000_private *devpriv = dev->private; unsigned int val; int timeout; /* Set the + reference dac value in the FPGA */ - writew(0x80 | DAQBOARD2000_PosRefDacSelect, devpriv->daq + refDacs); + writew(0x80 | DAQBOARD2000_PosRefDacSelect, dev->mmio + refDacs); for (timeout = 0; timeout < 20; timeout++) { - val = readw(devpriv->daq + dacControl); + val = readw(dev->mmio + dacControl); if ((val & DAQBOARD2000_RefBusy) == 0) break; udelay(2); } /* Set the - reference dac value in the FPGA */ - writew(0x80 | DAQBOARD2000_NegRefDacSelect, devpriv->daq + refDacs); + writew(0x80 | DAQBOARD2000_NegRefDacSelect, dev->mmio + refDacs); for (timeout = 0; timeout < 20; timeout++) { - val = readw(devpriv->daq + dacControl); + val = readw(dev->mmio + dacControl); if ((val & DAQBOARD2000_RefBusy) == 0) break; udelay(2); @@ -718,8 +704,8 @@ static int daqboard2000_auto_attach(struct comedi_device *dev, return result; devpriv->plx = pci_ioremap_bar(pcidev, 0); - devpriv->daq = pci_ioremap_bar(pcidev, 2); - if (!devpriv->plx || !devpriv->daq) + dev->mmio = pci_ioremap_bar(pcidev, 2); + if (!devpriv->plx || !dev->mmio) return -ENOMEM; result = comedi_alloc_subdevices(dev, 3); @@ -758,7 +744,7 @@ static int daqboard2000_auto_attach(struct comedi_device *dev, s = &dev->subdevices[2]; result = subdev_8255_init(dev, s, daqboard2000_8255_cb, - (unsigned long)(devpriv->daq + dioP2ExpansionIO8Bit)); + (unsigned long)(dev->mmio + dioP2ExpansionIO8Bit)); if (result) return result; @@ -772,8 +758,8 @@ static void daqboard2000_detach(struct comedi_device *dev) if (dev->irq) free_irq(dev->irq, dev); if (devpriv) { - if (devpriv->daq) - iounmap(devpriv->daq); + if (dev->mmio) + iounmap(dev->mmio); if (devpriv->plx) iounmap(devpriv->plx); }