From: H Hartley Sweeten Date: Mon, 25 Aug 2014 23:04:52 +0000 (-0700) Subject: staging: comedi: dt2801: use comedi_subdevice 'readback' X-Git-Tag: firefly_0821_release~176^2~3121^2~1000 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b858206ae96d6a8484c8306bb8149f12206ce026;p=firefly-linux-kernel-4.4.55.git staging: comedi: dt2801: 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/dt2801.c b/drivers/staging/comedi/drivers/dt2801.c index c16d468625ab..d28d41c978d7 100644 --- a/drivers/staging/comedi/drivers/dt2801.c +++ b/drivers/staging/comedi/drivers/dt2801.c @@ -207,9 +207,7 @@ static const struct dt2801_board boardtypes[] = { }; struct dt2801_private { - const struct comedi_lrange *dac_range_types[2]; - unsigned int ao_readback[2]; }; /* These are the low-level routines: @@ -463,28 +461,18 @@ static int dt2801_ai_insn_read(struct comedi_device *dev, return i; } -static int dt2801_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) -{ - struct dt2801_private *devpriv = dev->private; - - data[0] = devpriv->ao_readback[CR_CHAN(insn->chanspec)]; - - return 1; -} - static int dt2801_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, unsigned int *data) + struct comedi_insn *insn, + unsigned int *data) { - struct dt2801_private *devpriv = dev->private; + unsigned int chan = CR_CHAN(insn->chanspec); dt2801_writecmd(dev, DT_C_WRITE_DAIM); - dt2801_writedata(dev, CR_CHAN(insn->chanspec)); + dt2801_writedata(dev, chan); dt2801_writedata2(dev, data[0]); - devpriv->ao_readback[CR_CHAN(insn->chanspec)] = data[0]; + s->readback[chan] = data[0]; return 1; } @@ -608,8 +596,12 @@ havetype: s->range_table_list = devpriv->dac_range_types; devpriv->dac_range_types[0] = dac_range_lkup(it->options[4]); devpriv->dac_range_types[1] = dac_range_lkup(it->options[5]); - s->insn_read = dt2801_ao_insn_read; s->insn_write = dt2801_ao_insn_write; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; s = &dev->subdevices[2]; /* 1st digital subdevice */