From fee3b2455c849b8ab60634300bbbd848be943264 Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Tue, 29 Jul 2014 15:01:29 -0700 Subject: staging: comedi: dt3000: 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 --- drivers/staging/comedi/drivers/dt3000.c | 104 ++++++++++++++------------------ 1 file changed, 44 insertions(+), 60 deletions(-) diff --git a/drivers/staging/comedi/drivers/dt3000.c b/drivers/staging/comedi/drivers/dt3000.c index bf5a05c64fe2..56e21cc2dcfe 100644 --- a/drivers/staging/comedi/drivers/dt3000.c +++ b/drivers/staging/comedi/drivers/dt3000.c @@ -244,7 +244,6 @@ static const struct dt3k_boardtype dt3k_boardtypes[] = { #define DT3000_CHANNEL_MODE_DI 1 struct dt3k_private { - void __iomem *io_addr; unsigned int lock; unsigned int ao_readback[2]; unsigned int ai_front; @@ -255,14 +254,13 @@ struct dt3k_private { static void dt3k_send_cmd(struct comedi_device *dev, unsigned int cmd) { - struct dt3k_private *devpriv = dev->private; int i; unsigned int status = 0; - writew(cmd, devpriv->io_addr + DPR_Command_Mbx); + writew(cmd, dev->mmio + DPR_Command_Mbx); for (i = 0; i < TIMEOUT; i++) { - status = readw(devpriv->io_addr + DPR_Command_Mbx); + status = readw(dev->mmio + DPR_Command_Mbx); if ((status & DT3000_COMPLETION_MASK) != DT3000_NOTPROCESSED) break; udelay(1); @@ -277,28 +275,24 @@ static unsigned int dt3k_readsingle(struct comedi_device *dev, unsigned int subsys, unsigned int chan, unsigned int gain) { - struct dt3k_private *devpriv = dev->private; - - writew(subsys, devpriv->io_addr + DPR_SubSys); + writew(subsys, dev->mmio + DPR_SubSys); - writew(chan, devpriv->io_addr + DPR_Params(0)); - writew(gain, devpriv->io_addr + DPR_Params(1)); + writew(chan, dev->mmio + DPR_Params(0)); + writew(gain, dev->mmio + DPR_Params(1)); dt3k_send_cmd(dev, CMD_READSINGLE); - return readw(devpriv->io_addr + DPR_Params(2)); + return readw(dev->mmio + DPR_Params(2)); } static void dt3k_writesingle(struct comedi_device *dev, unsigned int subsys, unsigned int chan, unsigned int data) { - struct dt3k_private *devpriv = dev->private; - - writew(subsys, devpriv->io_addr + DPR_SubSys); + writew(subsys, dev->mmio + DPR_SubSys); - writew(chan, devpriv->io_addr + DPR_Params(0)); - writew(0, devpriv->io_addr + DPR_Params(1)); - writew(data, devpriv->io_addr + DPR_Params(2)); + writew(chan, dev->mmio + DPR_Params(0)); + writew(0, dev->mmio + DPR_Params(1)); + writew(data, dev->mmio + DPR_Params(2)); dt3k_send_cmd(dev, CMD_WRITESINGLE); } @@ -313,7 +307,7 @@ static void dt3k_ai_empty_fifo(struct comedi_device *dev, int i; unsigned short data; - front = readw(devpriv->io_addr + DPR_AD_Buf_Front); + front = readw(dev->mmio + DPR_AD_Buf_Front); count = front - devpriv->ai_front; if (count < 0) count += AI_FIFO_DEPTH; @@ -321,7 +315,7 @@ static void dt3k_ai_empty_fifo(struct comedi_device *dev, rear = devpriv->ai_rear; for (i = 0; i < count; i++) { - data = readw(devpriv->io_addr + DPR_ADC_buffer + rear); + data = readw(dev->mmio + DPR_ADC_buffer + rear); comedi_buf_put(s, data); rear++; if (rear >= AI_FIFO_DEPTH) @@ -329,17 +323,16 @@ static void dt3k_ai_empty_fifo(struct comedi_device *dev, } devpriv->ai_rear = rear; - writew(rear, devpriv->io_addr + DPR_AD_Buf_Rear); + writew(rear, dev->mmio + DPR_AD_Buf_Rear); } -static int dt3k_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) +static int dt3k_ai_cancel(struct comedi_device *dev, + struct comedi_subdevice *s) { - struct dt3k_private *devpriv = dev->private; - - writew(SUBS_AI, devpriv->io_addr + DPR_SubSys); + writew(SUBS_AI, dev->mmio + DPR_SubSys); dt3k_send_cmd(dev, CMD_STOP); - writew(0, devpriv->io_addr + DPR_Int_Mask); + writew(0, dev->mmio + DPR_Int_Mask); return 0; } @@ -351,14 +344,13 @@ static int debug_n_ints; static irqreturn_t dt3k_interrupt(int irq, void *d) { struct comedi_device *dev = d; - struct dt3k_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; unsigned int status; if (!dev->attached) return IRQ_NONE; - status = readw(devpriv->io_addr + DPR_Intr_Flag); + status = readw(dev->mmio + DPR_Intr_Flag); if (status & DT3000_ADFULL) { dt3k_ai_empty_fifo(dev, s); @@ -491,7 +483,6 @@ static int dt3k_ai_cmdtest(struct comedi_device *dev, static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) { - struct dt3k_private *devpriv = dev->private; struct comedi_cmd *cmd = &s->async->cmd; int i; unsigned int chan, range, aref; @@ -503,41 +494,40 @@ static int dt3k_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) chan = CR_CHAN(cmd->chanlist[i]); range = CR_RANGE(cmd->chanlist[i]); - writew((range << 6) | chan, - devpriv->io_addr + DPR_ADC_buffer + i); + writew((range << 6) | chan, dev->mmio + DPR_ADC_buffer + i); } aref = CR_AREF(cmd->chanlist[0]); - writew(cmd->scan_end_arg, devpriv->io_addr + DPR_Params(0)); + writew(cmd->scan_end_arg, dev->mmio + DPR_Params(0)); if (cmd->convert_src == TRIG_TIMER) { divider = dt3k_ns_to_timer(50, &cmd->convert_arg, cmd->flags); - writew((divider >> 16), devpriv->io_addr + DPR_Params(1)); - writew((divider & 0xffff), devpriv->io_addr + DPR_Params(2)); + writew((divider >> 16), dev->mmio + DPR_Params(1)); + writew((divider & 0xffff), dev->mmio + DPR_Params(2)); } if (cmd->scan_begin_src == TRIG_TIMER) { tscandiv = dt3k_ns_to_timer(100, &cmd->scan_begin_arg, cmd->flags); - writew((tscandiv >> 16), devpriv->io_addr + DPR_Params(3)); - writew((tscandiv & 0xffff), devpriv->io_addr + DPR_Params(4)); + writew((tscandiv >> 16), dev->mmio + DPR_Params(3)); + writew((tscandiv & 0xffff), dev->mmio + DPR_Params(4)); } mode = DT3000_AD_RETRIG_INTERNAL | 0 | 0; - writew(mode, devpriv->io_addr + DPR_Params(5)); - writew(aref == AREF_DIFF, devpriv->io_addr + DPR_Params(6)); + writew(mode, dev->mmio + DPR_Params(5)); + writew(aref == AREF_DIFF, dev->mmio + DPR_Params(6)); - writew(AI_FIFO_DEPTH / 2, devpriv->io_addr + DPR_Params(7)); + writew(AI_FIFO_DEPTH / 2, dev->mmio + DPR_Params(7)); - writew(SUBS_AI, devpriv->io_addr + DPR_SubSys); + writew(SUBS_AI, dev->mmio + DPR_SubSys); dt3k_send_cmd(dev, CMD_CONFIG); writew(DT3000_ADFULL | DT3000_ADSWERR | DT3000_ADHWERR, - devpriv->io_addr + DPR_Int_Mask); + dev->mmio + DPR_Int_Mask); debug_n_ints = 0; - writew(SUBS_AI, devpriv->io_addr + DPR_SubSys); + writew(SUBS_AI, dev->mmio + DPR_SubSys); dt3k_send_cmd(dev, CMD_START); return 0; @@ -593,16 +583,14 @@ static int dt3k_ao_insn_read(struct comedi_device *dev, static void dt3k_dio_config(struct comedi_device *dev, int bits) { - struct dt3k_private *devpriv = dev->private; - /* XXX */ - writew(SUBS_DOUT, devpriv->io_addr + DPR_SubSys); + writew(SUBS_DOUT, dev->mmio + DPR_SubSys); - writew(bits, devpriv->io_addr + DPR_Params(0)); + writew(bits, dev->mmio + DPR_Params(0)); #if 0 /* don't know */ - writew(0, devpriv->io_addr + DPR_Params(1)); - writew(0, devpriv->io_addr + DPR_Params(2)); + writew(0, dev->mmio + DPR_Params(1)); + writew(0, dev->mmio + DPR_Params(2)); #endif dt3k_send_cmd(dev, CMD_CONFIG); @@ -646,20 +634,20 @@ static int dt3k_dio_insn_bits(struct comedi_device *dev, static int dt3k_mem_insn_read(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - struct dt3k_private *devpriv = dev->private; unsigned int addr = CR_CHAN(insn->chanspec); int i; for (i = 0; i < insn->n; i++) { - writew(SUBS_MEM, devpriv->io_addr + DPR_SubSys); - writew(addr, devpriv->io_addr + DPR_Params(0)); - writew(1, devpriv->io_addr + DPR_Params(1)); + writew(SUBS_MEM, dev->mmio + DPR_SubSys); + writew(addr, dev->mmio + DPR_Params(0)); + writew(1, dev->mmio + DPR_Params(1)); dt3k_send_cmd(dev, CMD_READCODE); - data[i] = readw(devpriv->io_addr + DPR_Params(2)); + data[i] = readw(dev->mmio + DPR_Params(2)); } return i; @@ -689,8 +677,8 @@ static int dt3000_auto_attach(struct comedi_device *dev, if (ret < 0) return ret; - devpriv->io_addr = pci_ioremap_bar(pcidev, 0); - if (!devpriv->io_addr) + dev->mmio = pci_ioremap_bar(pcidev, 0); + if (!dev->mmio) return -ENOMEM; if (pcidev->irq) { @@ -764,14 +752,10 @@ static int dt3000_auto_attach(struct comedi_device *dev, static void dt3000_detach(struct comedi_device *dev) { - struct dt3k_private *devpriv = dev->private; - if (dev->irq) free_irq(dev->irq, dev); - if (devpriv) { - if (devpriv->io_addr) - iounmap(devpriv->io_addr); - } + if (dev->mmio) + iounmap(dev->mmio); comedi_pci_disable(dev); } -- cgit v1.2.3