From: H Hartley Sweeten Date: Mon, 25 Aug 2014 23:04:18 +0000 (-0700) Subject: staging: comedi: das6402: use comedi_subdevice 'readback' X-Git-Tag: firefly_0821_release~176^2~3121^2~1034 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=3dd0b514d95b2063c211d5b00940202921cce3ea;p=firefly-linux-kernel-4.4.55.git staging: comedi: das6402: 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/das6402.c b/drivers/staging/comedi/drivers/das6402.c index d18eea6c01aa..7d9f26a6e460 100644 --- a/drivers/staging/comedi/drivers/das6402.c +++ b/drivers/staging/comedi/drivers/das6402.c @@ -143,7 +143,6 @@ struct das6402_private { unsigned int divider2; unsigned int ao_range; - unsigned int ao_readback[2]; }; static void das6402_set_mode(struct comedi_device *dev, @@ -328,7 +327,7 @@ static int das6402_ao_insn_write(struct comedi_device *dev, for (i = 0; i < insn->n; i++) { val = data[i]; - devpriv->ao_readback[chan] = val; + s->readback[chan] = val; if (s->maxdata == 0x0fff) { /* @@ -358,9 +357,7 @@ static int das6402_ao_insn_read(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct das6402_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); - int i; /* * If XFER mode is enabled, reading any DAC register @@ -368,10 +365,7 @@ static int das6402_ao_insn_read(struct comedi_device *dev, */ inw(dev->iobase + DAS6402_AO_LSB_REG(chan)); - for (i = 0; i < insn->n; i++) - data[i] = devpriv->ao_readback[chan]; - - return insn->n; + return comedi_readback_insn_read(dev, s, insn, data); } static int das6402_di_insn_bits(struct comedi_device *dev, @@ -510,6 +504,10 @@ static int das6402_attach(struct comedi_device *dev, s->insn_write = das6402_ao_insn_write; s->insn_read = das6402_ao_insn_read; + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + /* Digital Input subdevice */ s = &dev->subdevices[2]; s->type = COMEDI_SUBD_DI;