From: H Hartley Sweeten Date: Mon, 25 Aug 2014 23:03:56 +0000 (-0700) Subject: staging: comedi: adl_pci6208: use comedi_subdevice 'readback' X-Git-Tag: v3.18-rc1~130^2~1056 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=da1eed1824e5c7f231a0d256044bb0aa730f45f5;p=karo-tx-linux.git staging: comedi: adl_pci6208: 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. The loop used to write the values could timeout. Move the saving of the readback value so that the last value written is always saved. 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/adl_pci6208.c b/drivers/staging/comedi/drivers/adl_pci6208.c index 921f6942dfce..1e8b0905a845 100644 --- a/drivers/staging/comedi/drivers/adl_pci6208.c +++ b/drivers/staging/comedi/drivers/adl_pci6208.c @@ -46,8 +46,6 @@ #define PCI6208_DIO_DI_MASK (0xf0) #define PCI6208_DIO_DI_SHIFT (4) -#define PCI6208_MAX_AO_CHANNELS 16 - enum pci6208_boardid { BOARD_PCI6208, BOARD_PCI6216, @@ -69,10 +67,6 @@ static const struct pci6208_board pci6208_boards[] = { }, }; -struct pci6208_private { - unsigned int ao_readback[PCI6208_MAX_AO_CHANNELS]; -}; - static int pci6208_ao_eoc(struct comedi_device *dev, struct comedi_subdevice *s, struct comedi_insn *insn, @@ -91,9 +85,8 @@ static int pci6208_ao_insn_write(struct comedi_device *dev, struct comedi_insn *insn, unsigned int *data) { - struct pci6208_private *devpriv = dev->private; unsigned int chan = CR_CHAN(insn->chanspec); - unsigned int val = devpriv->ao_readback[chan]; + unsigned int val = s->readback[chan]; int ret; int i; @@ -108,23 +101,9 @@ static int pci6208_ao_insn_write(struct comedi_device *dev, /* the hardware expects two's complement values */ outw(comedi_offset_munge(s, val), dev->iobase + PCI6208_AO_CONTROL(chan)); - } - devpriv->ao_readback[chan] = val; - - return insn->n; -} -static int pci6208_ao_insn_read(struct comedi_device *dev, - struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) -{ - struct pci6208_private *devpriv = dev->private; - unsigned int chan = CR_CHAN(insn->chanspec); - int i; - - for (i = 0; i < insn->n; i++) - data[i] = devpriv->ao_readback[chan]; + s->readback[chan] = val; + } return insn->n; } @@ -162,7 +141,6 @@ static int pci6208_auto_attach(struct comedi_device *dev, { struct pci_dev *pcidev = comedi_to_pci_dev(dev); const struct pci6208_board *boardinfo = NULL; - struct pci6208_private *devpriv; struct comedi_subdevice *s; unsigned int val; int ret; @@ -174,10 +152,6 @@ static int pci6208_auto_attach(struct comedi_device *dev, dev->board_ptr = boardinfo; dev->board_name = boardinfo->name; - devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv)); - if (!devpriv) - return -ENOMEM; - ret = comedi_pci_enable(dev); if (ret) return ret; @@ -195,7 +169,11 @@ static int pci6208_auto_attach(struct comedi_device *dev, s->maxdata = 0xffff; s->range_table = &range_bipolar10; s->insn_write = pci6208_ao_insn_write; - s->insn_read = pci6208_ao_insn_read; + s->insn_read = comedi_readback_insn_read; + + ret = comedi_alloc_subdev_readback(s); + if (ret) + return ret; s = &dev->subdevices[1]; /* digital input subdevice */