From: H Hartley Sweeten Date: Mon, 25 Aug 2014 23:04:31 +0000 (-0700) Subject: staging: comedi: ii_pci20kc: use comedi_subdevice 'readback' X-Git-Tag: v3.18-rc1~130^2~1021 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=1fd142ce3d23ea5168b2c0eebca5c9fbdce632ef;p=karo-tx-linux.git staging: comedi: ii_pci20kc: 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. Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/ii_pci20kc.c b/drivers/staging/comedi/drivers/ii_pci20kc.c index 10e8073dd919..cc5fd75b8bc0 100644 --- a/drivers/staging/comedi/drivers/ii_pci20kc.c +++ b/drivers/staging/comedi/drivers/ii_pci20kc.c @@ -132,46 +132,25 @@ static const struct comedi_lrange ii20k_ai_ranges = { }, }; -struct ii20k_ao_private { - unsigned int last_data[2]; -}; - static void __iomem *ii20k_module_iobase(struct comedi_device *dev, struct comedi_subdevice *s) { return dev->mmio + (s->index + 1) * II20K_MOD_OFFSET; } -static int ii20k_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct ii20k_ao_private *ao_spriv = s->private; - unsigned int chan = CR_CHAN(insn->chanspec); - int i; - - for (i = 0; i < insn->n; i++) - data[i] = ao_spriv->last_data[chan]; - - return insn->n; -} - static int ii20k_ao_insn_write(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, unsigned int *data) { - struct ii20k_ao_private *ao_spriv = s->private; void __iomem *iobase = ii20k_module_iobase(dev, s); unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int val; int i; for (i = 0; i < insn->n; i++) { - val = data[i]; + unsigned int val = data[i]; - ao_spriv->last_data[chan] = val; + s->readback[chan] = val; /* munge data */ val += ((s->maxdata + 1) >> 1); @@ -398,26 +377,26 @@ static int ii20k_dio_insn_bits(struct comedi_device *dev, static int ii20k_init_module(struct comedi_device *dev, struct comedi_subdevice *s) { - struct ii20k_ao_private *ao_spriv; void __iomem *iobase = ii20k_module_iobase(dev, s); unsigned char id; + int ret; id = readb(iobase + II20K_ID_REG); switch (id) { case II20K_ID_PCI20006M_1: case II20K_ID_PCI20006M_2: - ao_spriv = comedi_alloc_spriv(s, sizeof(*ao_spriv)); - if (!ao_spriv) - return -ENOMEM; - /* Analog Output subdevice */ s->type = COMEDI_SUBD_AO; s->subdev_flags = SDF_WRITABLE; s->n_chan = (id == II20K_ID_PCI20006M_2) ? 2 : 1; s->maxdata = 0xffff; s->range_table = &ii20k_ao_ranges; - s->insn_read = ii20k_ao_insn_read; s->insn_write = ii20k_ao_insn_write; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; break; case II20K_ID_PCI20341M_1: /* Analog Input subdevice */