On 2014-05-05 17:59, H Hartley Sweeten wrote:
Use the comedi_fc helper cfc_check_trigger_arg_is() to validate the scan_begin_arg when the scan_begin_src is TRIG_TIMER. For aesthetics reasons, rename the local variable 'tmp' to 'arg'. Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbotti@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/drivers/amplc_pci224.c | 29 +++++++++++++-------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/drivers/staging/comedi/drivers/amplc_pci224.c b/drivers/staging/comedi/drivers/amplc_pci224.c index c2b352c..ec65a34 100644 --- a/drivers/staging/comedi/drivers/amplc_pci224.c +++ b/drivers/staging/comedi/drivers/amplc_pci224.c @@ -719,7 +719,7 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, { struct pci224_private *devpriv = dev->private; int err = 0; - unsigned int tmp; + unsigned int arg; /* Step 1 : check if triggers are trivially valid */ @@ -746,14 +746,14 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, * There's only one external trigger signal (which makes these * tests easier). Only one thing can use it. */ - tmp = 0; + err = 0; if (cmd->start_src & TRIG_EXT) - tmp++; + err++; if (cmd->scan_begin_src & TRIG_EXT) - tmp++; + err++; if (cmd->stop_src & TRIG_EXT) - tmp++; - if (tmp > 1) + err++; + if (err > 1) err |= -EINVAL; if (err)
That's wrong and breaks when any of the _src are set to TRIG_EXT. It also disregards any errors from step 2a. It would have worked if you had just replaced 'tmp' with 'arg' in the original version.
@@ -761,6 +761,7 @@ pci224_ao_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s, /* Step 3: check if arguments are trivially valid */ + err = 0;
And then clearing 'err' would have been unnecessary here. -- -=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@xxxxxxxxx> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=- _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel