From: H Hartley Sweeten Date: Mon, 25 Aug 2014 23:04:45 +0000 (-0700) Subject: staging: comedi: ni_670x: use comedi_subdevice 'readback' X-Git-Tag: v3.18-rc1~130^2~1007 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=1d0750cec59b15187e4778d8da8268b00f0db30b;p=karo-tx-linux.git staging: comedi: ni_670x: use comedi_subdevice 'readback' Use the new comedi_subdevice 'readback' member and the core provided (*insn_read) for the readback of the analog output subdevice channels. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/ni_670x.c b/drivers/staging/comedi/drivers/ni_670x.c index 7df8bb50d525..092e2b17a5d3 100644 --- a/drivers/staging/comedi/drivers/ni_670x.c +++ b/drivers/staging/comedi/drivers/ni_670x.c @@ -83,7 +83,6 @@ static const struct ni_670x_board ni_670x_boards[] = { struct ni_670x_private { int boardtype; int dio; - unsigned int ao_readback[32]; }; static int ni_670x_ao_insn_write(struct comedi_device *dev, @@ -91,9 +90,8 @@ static int ni_670x_ao_insn_write(struct comedi_device *dev, 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]; + unsigned int val = s->readback[chan]; int i; /* @@ -114,25 +112,11 @@ static int ni_670x_ao_insn_write(struct comedi_device *dev, /* write channel value */ writel(val, dev->mmio + AO_VALUE_OFFSET); } - devpriv->ao_readback[chan] = val; + s->readback[chan] = val; return insn->n; } -static int ni_670x_ao_rinsn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct ni_670x_private *devpriv = dev->private; - int i; - int chan = CR_CHAN(insn->chanspec); - - for (i = 0; i < insn->n; i++) - data[i] = devpriv->ao_readback[chan]; - - return i; -} - static int ni_670x_dio_insn_bits(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -244,7 +228,11 @@ static int ni_670x_auto_attach(struct comedi_device *dev, s->range_table = &range_bipolar10; } s->insn_write = ni_670x_ao_insn_write; - s->insn_read = &ni_670x_ao_rinsn; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; s = &dev->subdevices[1]; /* digital i/o subdevice */