From 987f3c86a14a67d16bcc648d062bfa46cbd2e552 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 12 Aug 2013 15:17:17 -0700 Subject: [PATCH] Revert "staging: comedi: skel: use comedi_dio_insn_config()" This reverts commit 42ef678bef336a83fd0ae0b03a56c0a93665a18b. It's incorrect as well... time for more coffee... Cc: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- drivers/staging/comedi/drivers/skel.c | 42 +++++++++++++++------------ 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/staging/comedi/drivers/skel.c b/drivers/staging/comedi/drivers/skel.c index 9e964950a560..f76fd09e7bd3 100644 --- a/drivers/staging/comedi/drivers/skel.c +++ b/drivers/staging/comedi/drivers/skel.c @@ -362,27 +362,31 @@ static int skel_dio_insn_bits(struct comedi_device *dev, static int skel_dio_insn_config(struct comedi_device *dev, struct comedi_subdevice *s, - struct comedi_insn *insn, - unsigned int *data) + struct comedi_insn *insn, unsigned int *data) { - int ret; - - /* - * The input or output configuration of each digital line is - * configured by special insn_config instructions. - * - * chanspec contains the channel to be changed - * data[0] contains the instruction to perform on the channel - * - * Normally the core provided comedi_dio_insn_config() function - * can be used to handle the boilerplpate. - */ - ret = comedi_dio_insn_config(dev, s, insn, data, 0); - if (ret) - return ret; + int chan = CR_CHAN(insn->chanspec); - /* Update the hardware to the new configuration */ - /* outw(s->io_bits, dev->iobase + SKEL_DIO_CONFIG); */ + /* The input or output configuration of each digital line is + * configured by a special insn_config instruction. chanspec + * contains the channel to be changed, and data[0] contains the + * value COMEDI_INPUT or COMEDI_OUTPUT. */ + switch (data[0]) { + case INSN_CONFIG_DIO_OUTPUT: + s->io_bits |= 1 << chan; + break; + case INSN_CONFIG_DIO_INPUT: + s->io_bits &= ~(1 << chan); + break; + case INSN_CONFIG_DIO_QUERY: + data[1] = + (s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT; + return insn->n; + break; + default: + return -EINVAL; + break; + } + /* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */ return insn->n; } -- 2.20.1