staging: comedi: comedi_fc: introduce cfc_check_trigger_src
authorH Hartley Sweeten <hartleys@visionengravers.com>
Tue, 11 Sep 2012 17:47:08 +0000 (10:47 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Sep 2012 19:11:04 +0000 (12:11 -0700)
commit43b9778eeb789fbfad3ce66da3bbb3440440fbb8
treeaabffb058bfbff6eaca7d6ad010af2503ed62de9
parent13b2663c95f6f30f835ef92ef51c9aff0b3f09d6
staging: comedi: comedi_fc: introduce cfc_check_trigger_src

All of the comedi drivers that support the 'cmd' callback also
require a 'do_cmdtest' callback. The do_cmdtest validates the
comedi_cmd before it is executed.

"Step 1" of each do_cmdtest does a trivial validation of the
trigger sources by doing something like this for each trigger:

int err = 0;
unsigned int tmp;

tmp = cmd->start_src;
src &= TRIG_NOW;
if (!src || tmp != src)
err++;
/* Test the remaining triggers similarly */

if (err)
return 1;

Introduce a helper function in comedi_fc to handle this boilerplate.
The drivers can then just do:

err |= cfc_check_trigger_src(&cmd->start_src, TRIG_NOW);
/* Test the remaining triggers similarly */

if (err)
return 1;

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/drivers/comedi_fc.h