From: H Hartley Sweeten Date: Mon, 25 Aug 2014 23:04:50 +0000 (-0700) Subject: staging: comedi: cb_pcidas: use comedi_subdevice 'readback' X-Git-Tag: v5.15~17125^2~1002 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=46da1c8fe35026756154a11909dcc4e3fd4bcf00;p=platform%2Fkernel%2Flinux-starfive.git staging: comedi: cb_pcidas: 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/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c index f372b03..b2be8f3 100644 --- a/drivers/staging/comedi/drivers/cb_pcidas.c +++ b/drivers/staging/comedi/drivers/cb_pcidas.c @@ -360,8 +360,6 @@ struct cb_pcidas_private { unsigned int ao_divisor2; /* number of analog output samples remaining */ unsigned int ao_count; - /* cached values for readback */ - unsigned short ao_value[2]; unsigned int caldac_value[NUM_CHANNELS_8800]; unsigned int trimpot_value[NUM_CHANNELS_8402]; unsigned int dac08_value; @@ -484,7 +482,7 @@ static int cb_pcidas_ao_nofifo_winsn(struct comedi_device *dev, spin_unlock_irqrestore(&dev->spinlock, flags); /* remember value for readback */ - devpriv->ao_value[chan] = data[0]; + s->readback[chan] = data[0]; /* send data */ outw(data[0], devpriv->ao_registers + DAC_DATA_REG(chan)); @@ -515,7 +513,7 @@ static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev, spin_unlock_irqrestore(&dev->spinlock, flags); /* remember value for readback */ - devpriv->ao_value[chan] = data[0]; + s->readback[chan] = data[0]; /* send data */ outw(data[0], devpriv->ao_registers + DACDATA); @@ -523,18 +521,6 @@ static int cb_pcidas_ao_fifo_winsn(struct comedi_device *dev, return insn->n; } -static int cb_pcidas_ao_readback_insn(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct cb_pcidas_private *devpriv = dev->private; - - data[0] = devpriv->ao_value[CR_CHAN(insn->chanspec)]; - - return 1; -} - static int wait_for_nvram_ready(unsigned long s5933_base_addr) { static const int timeout = 1000; @@ -1511,16 +1497,22 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, */ s->maxdata = (1 << thisboard->ai_bits) - 1; s->range_table = &cb_pcidas_ao_ranges; - s->insn_read = cb_pcidas_ao_readback_insn; + /* default to no fifo (*insn_write) */ + s->insn_write = cb_pcidas_ao_nofifo_winsn; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; + if (thisboard->has_ao_fifo) { dev->write_subdev = s; s->subdev_flags |= SDF_CMD_WRITE; + /* use fifo (*insn_write) instead */ s->insn_write = cb_pcidas_ao_fifo_winsn; s->do_cmdtest = cb_pcidas_ao_cmdtest; s->do_cmd = cb_pcidas_ao_cmd; s->cancel = cb_pcidas_ao_cancel; - } else { - s->insn_write = cb_pcidas_ao_nofifo_winsn; } } else { s->type = COMEDI_SUBD_UNUSED;