Skip to content

Commit 42ef678

Browse files
bigguinessgregkh
authored andcommitted
staging: comedi: skel: use comedi_dio_insn_config()
Convert this driver to use the comedi_dio_insn_config() helper function. Tidy up the comments to reflect the new code. 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>
1 parent 4f76463 commit 42ef678

File tree

1 file changed

+19
-23
lines changed
  • drivers/staging/comedi/drivers

1 file changed

+19
-23
lines changed

drivers/staging/comedi/drivers/skel.c

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -362,31 +362,27 @@ static int skel_dio_insn_bits(struct comedi_device *dev,
362362

363363
static int skel_dio_insn_config(struct comedi_device *dev,
364364
struct comedi_subdevice *s,
365-
struct comedi_insn *insn, unsigned int *data)
365+
struct comedi_insn *insn,
366+
unsigned int *data)
366367
{
367-
int chan = CR_CHAN(insn->chanspec);
368+
int ret;
368369

369-
/* The input or output configuration of each digital line is
370-
* configured by a special insn_config instruction. chanspec
371-
* contains the channel to be changed, and data[0] contains the
372-
* value COMEDI_INPUT or COMEDI_OUTPUT. */
373-
switch (data[0]) {
374-
case INSN_CONFIG_DIO_OUTPUT:
375-
s->io_bits |= 1 << chan;
376-
break;
377-
case INSN_CONFIG_DIO_INPUT:
378-
s->io_bits &= ~(1 << chan);
379-
break;
380-
case INSN_CONFIG_DIO_QUERY:
381-
data[1] =
382-
(s->io_bits & (1 << chan)) ? COMEDI_OUTPUT : COMEDI_INPUT;
383-
return insn->n;
384-
break;
385-
default:
386-
return -EINVAL;
387-
break;
388-
}
389-
/* outw(s->io_bits,dev->iobase + SKEL_DIO_CONFIG); */
370+
/*
371+
* The input or output configuration of each digital line is
372+
* configured by special insn_config instructions.
373+
*
374+
* chanspec contains the channel to be changed
375+
* data[0] contains the instruction to perform on the channel
376+
*
377+
* Normally the core provided comedi_dio_insn_config() function
378+
* can be used to handle the boilerplpate.
379+
*/
380+
ret = comedi_dio_insn_config(dev, s, insn, data, 0);
381+
if (ret)
382+
return ret;
383+
384+
/* Update the hardware to the new configuration */
385+
/* outw(s->io_bits, dev->iobase + SKEL_DIO_CONFIG); */
390386

391387
return insn->n;
392388
}

0 commit comments

Comments
 (0)