mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-04 18:19:28 +09:00
staging: comedi: aio_aio12_8: 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. Remove the unused private data and its allocation. For aesthetics, rename the (*insn_write) function and tidy it up. 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
da1eed1824
commit
9ac581336a
@@ -97,10 +97,6 @@ static const struct aio12_8_boardtype board_types[] = {
|
||||
},
|
||||
};
|
||||
|
||||
struct aio12_8_private {
|
||||
unsigned int ao_readback[4];
|
||||
};
|
||||
|
||||
static int aio_aio12_8_ai_eoc(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
struct comedi_insn *insn,
|
||||
@@ -149,28 +145,13 @@ static int aio_aio12_8_ai_read(struct comedi_device *dev,
|
||||
return insn->n;
|
||||
}
|
||||
|
||||
static int aio_aio12_8_ao_read(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
struct comedi_insn *insn, unsigned int *data)
|
||||
static int aio_aio12_8_ao_insn_write(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
struct comedi_insn *insn,
|
||||
unsigned int *data)
|
||||
{
|
||||
struct aio12_8_private *devpriv = dev->private;
|
||||
unsigned int chan = CR_CHAN(insn->chanspec);
|
||||
int val = devpriv->ao_readback[chan];
|
||||
int i;
|
||||
|
||||
for (i = 0; i < insn->n; i++)
|
||||
data[i] = val;
|
||||
return insn->n;
|
||||
}
|
||||
|
||||
static int aio_aio12_8_ao_write(struct comedi_device *dev,
|
||||
struct comedi_subdevice *s,
|
||||
struct comedi_insn *insn, unsigned int *data)
|
||||
{
|
||||
struct aio12_8_private *devpriv = dev->private;
|
||||
unsigned int chan = CR_CHAN(insn->chanspec);
|
||||
unsigned long port = dev->iobase + AIO12_8_DAC_REG(chan);
|
||||
unsigned int val = 0;
|
||||
unsigned int val = s->readback[chan];
|
||||
int i;
|
||||
|
||||
/* enable DACs */
|
||||
@@ -178,10 +159,9 @@ static int aio_aio12_8_ao_write(struct comedi_device *dev,
|
||||
|
||||
for (i = 0; i < insn->n; i++) {
|
||||
val = data[i];
|
||||
outw(val, port);
|
||||
outw(val, dev->iobase + AIO12_8_DAC_REG(chan));
|
||||
}
|
||||
|
||||
devpriv->ao_readback[chan] = val;
|
||||
s->readback[chan] = val;
|
||||
|
||||
return insn->n;
|
||||
}
|
||||
@@ -199,7 +179,6 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
|
||||
struct comedi_devconfig *it)
|
||||
{
|
||||
const struct aio12_8_boardtype *board = comedi_board(dev);
|
||||
struct aio12_8_private *devpriv;
|
||||
struct comedi_subdevice *s;
|
||||
int ret;
|
||||
|
||||
@@ -207,10 +186,6 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
|
||||
if (!devpriv)
|
||||
return -ENOMEM;
|
||||
|
||||
ret = comedi_alloc_subdevices(dev, 4);
|
||||
if (ret)
|
||||
return ret;
|
||||
@@ -236,8 +211,12 @@ static int aio_aio12_8_attach(struct comedi_device *dev,
|
||||
s->n_chan = 4;
|
||||
s->maxdata = 0x0fff;
|
||||
s->range_table = &range_aio_aio12_8;
|
||||
s->insn_read = aio_aio12_8_ao_read;
|
||||
s->insn_write = aio_aio12_8_ao_write;
|
||||
s->insn_write = aio_aio12_8_ao_insn_write;
|
||||
s->insn_read = comedi_readback_insn_read;
|
||||
|
||||
ret = comedi_alloc_subdev_readback(s);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else {
|
||||
s->type = COMEDI_SUBD_UNUSED;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user