mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-04 18:19:28 +09:00
staging: comedi: icp_multi: 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. For aesthetics, rename the (*insn_write) function and tidy it up a bit. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
559975c175
commit
bba804d9a3
@@ -116,7 +116,6 @@ struct icp_multi_private {
|
||||
unsigned char act_chanlist_len; /* len of scanlist */
|
||||
unsigned char act_chanlist_pos; /* actual position in MUX list */
|
||||
unsigned int *ai_chanlist; /* actaul chanlist */
|
||||
unsigned short ao_data[4]; /* data output buffer */
|
||||
unsigned int do_data; /* Remember digital output data */
|
||||
};
|
||||
|
||||
@@ -240,14 +239,15 @@ static int icp_multi_ao_eoc(struct comedi_device *dev,
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
static int icp_multi_insn_write_ao(struct comedi_device *dev,
|
||||
static int icp_multi_ao_insn_write(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
struct comedi_insn *insn,
|
||||
unsigned int *data)
|
||||
{
|
||||
struct icp_multi_private *devpriv = dev->private;
|
||||
int n, chan, range;
|
||||
int ret;
|
||||
unsigned int chan = CR_CHAN(insn->chanspec);
|
||||
unsigned int range = CR_RANGE(insn->chanspec);
|
||||
int i;
|
||||
|
||||
/* Disable D/A conversion ready interrupt */
|
||||
devpriv->IntEnable &= ~DAC_READY;
|
||||
@@ -257,10 +257,6 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev,
|
||||
devpriv->IntStatus |= DAC_READY;
|
||||
writew(devpriv->IntStatus, dev->mmio + ICP_MULTI_INT_STAT);
|
||||
|
||||
/* Get channel number and range */
|
||||
chan = CR_CHAN(insn->chanspec);
|
||||
range = CR_RANGE(insn->chanspec);
|
||||
|
||||
/* Set up range and channel data */
|
||||
/* Bit 4 = 1 : Bipolar */
|
||||
/* Bit 5 = 0 : 5V */
|
||||
@@ -272,7 +268,10 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev,
|
||||
|
||||
writew(devpriv->DacCmdStatus, dev->mmio + ICP_MULTI_DAC_CSR);
|
||||
|
||||
for (n = 0; n < insn->n; n++) {
|
||||
for (i = 0; i < insn->n; i++) {
|
||||
unsigned int val = data[i];
|
||||
int ret;
|
||||
|
||||
/* Wait for analogue output data register to be
|
||||
* ready for new data, or get fed up waiting */
|
||||
ret = comedi_timeout(dev, s, insn, icp_multi_ao_eoc, 0);
|
||||
@@ -287,42 +286,20 @@ static int icp_multi_insn_write_ao(struct comedi_device *dev,
|
||||
writew(devpriv->IntStatus,
|
||||
dev->mmio + ICP_MULTI_INT_STAT);
|
||||
|
||||
/* Clear data received */
|
||||
devpriv->ao_data[chan] = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Write data to analogue output data register */
|
||||
writew(data[n], dev->mmio + ICP_MULTI_AO);
|
||||
writew(val, dev->mmio + ICP_MULTI_AO);
|
||||
|
||||
/* Set DAC_ST bit to write the data to selected channel */
|
||||
devpriv->DacCmdStatus |= DAC_ST;
|
||||
writew(devpriv->DacCmdStatus, dev->mmio + ICP_MULTI_DAC_CSR);
|
||||
devpriv->DacCmdStatus &= ~DAC_ST;
|
||||
|
||||
/* Save analogue output data */
|
||||
devpriv->ao_data[chan] = data[n];
|
||||
s->readback[chan] = val;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
static int icp_multi_insn_read_ao(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
struct comedi_insn *insn, unsigned int *data)
|
||||
{
|
||||
struct icp_multi_private *devpriv = dev->private;
|
||||
int n, chan;
|
||||
|
||||
/* Get channel number */
|
||||
chan = CR_CHAN(insn->chanspec);
|
||||
|
||||
/* Read analogue outputs */
|
||||
for (n = 0; n < insn->n; n++)
|
||||
data[n] = devpriv->ao_data[chan];
|
||||
|
||||
return n;
|
||||
return insn->n;
|
||||
}
|
||||
|
||||
static int icp_multi_insn_bits_di(struct comedi_device *dev,
|
||||
@@ -518,8 +495,12 @@ static int icp_multi_auto_attach(struct comedi_device *dev,
|
||||
s->maxdata = 0x0fff;
|
||||
s->len_chanlist = 4;
|
||||
s->range_table = &range_analog;
|
||||
s->insn_write = icp_multi_insn_write_ao;
|
||||
s->insn_read = icp_multi_insn_read_ao;
|
||||
s->insn_write = icp_multi_ao_insn_write;
|
||||
s->insn_read = comedi_readback_insn_read;
|
||||
|
||||
ret = comedi_alloc_subdev_readback(s);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
s = &dev->subdevices[2];
|
||||
s->type = COMEDI_SUBD_DI;
|
||||
|
||||
Reference in New Issue
Block a user