From d34b3d41cc5c333330d35d227b665b6dff9512ec Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Mon, 25 Aug 2014 16:04:44 -0700 Subject: [PATCH] staging: comedi: ni_670x: cleanup ni_670x_ao_winsn() For aesthetics, rename this function and tidy it up a bit. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/ni_670x.c | 40 +++++++++++++----------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index f5caefad0b59..7df8bb50d525 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -86,35 +86,37 @@ struct ni_670x_private { unsigned int ao_readback[32]; }; -static int ni_670x_ao_winsn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) +static int ni_670x_ao_insn_write(struct comedi_device *dev, + struct comedi_subdevice *s, + struct comedi_insn *insn, + unsigned int *data) { struct ni_670x_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); + unsigned int val = devpriv->ao_readback[chan]; int i; - int chan = CR_CHAN(insn->chanspec); - - /* Channel number mapping : - - NI 6703/ NI 6704 | NI 6704 Only - ---------------------------------------------------- - vch(0) : 0 | ich(16) : 1 - vch(1) : 2 | ich(17) : 3 - . : . | . . - . : . | . . - . : . | . . - vch(15) : 30 | ich(31) : 31 */ + /* + * Channel number mapping: + * + * NI 6703/ NI 6704 | NI 6704 Only + * ------------------------------- + * vch(0) : 0 | ich(16) : 1 + * vch(1) : 2 | ich(17) : 3 + * ... | ... + * vch(15) : 30 | ich(31) : 31 + */ for (i = 0; i < insn->n; i++) { + val = data[i]; /* First write in channel register which channel to use */ writel(((chan & 15) << 1) | ((chan & 16) >> 4), dev->mmio + AO_CHAN_OFFSET); /* write channel value */ - writel(data[i], dev->mmio + AO_VALUE_OFFSET); - devpriv->ao_readback[chan] = data[i]; + writel(val, dev->mmio + AO_VALUE_OFFSET); } + devpriv->ao_readback[chan] = val; - return i; + return insn->n; } static int ni_670x_ao_rinsn(struct comedi_device *dev, @@ -241,7 +243,7 @@ static int ni_670x_auto_attach(struct comedi_device *dev, } else { s->range_table = &range_bipolar10; } - s->insn_write = &ni_670x_ao_winsn; + s->insn_write = ni_670x_ao_insn_write; s->insn_read = &ni_670x_ao_rinsn; s = &dev->subdevices[1]; -- 2.30.2