[PATCH 32/38] staging: comedi: amplc_pci230: chanlist is valid after Step 1 of (*do_cmdtest)
Ian Abbott
abbotti at mev.co.uk
Wed May 28 10:22:04 UTC 2014
On 2014-05-27 18:31, H Hartley Sweeten wrote:
> THe comedi core ensures that the chanlist will be valid for any async operation
> other than Step 1 of the (*do_cmdtest) to get the trigger source masks.
>
> Remove the unnecessary checks.
>
> Signed-off-by: H Hartley Sweeten <hsweeten at visionengravers.com>
> Cc: Ian Abbott <abbotti at mev.co.uk>
> Cc: Greg Kroah-Hartman <gregkh at linuxfoundation.org>
NAK. It only ensures chanlist_len is non-zero for the COMEDI_CMD ioctl,
not for the COMEDI_CMDTEST ioctl. So both chanlist_len checks are
necessary below.
> ---
> drivers/staging/comedi/drivers/amplc_pci230.c | 33 +++++++++++----------------
> 1 file changed, 13 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/staging/comedi/drivers/amplc_pci230.c b/drivers/staging/comedi/drivers/amplc_pci230.c
> index 3895bc7..c87260c 100644
> --- a/drivers/staging/comedi/drivers/amplc_pci230.c
> +++ b/drivers/staging/comedi/drivers/amplc_pci230.c
> @@ -1511,16 +1511,12 @@ static int pci230_ao_cancel(struct comedi_device *dev,
>
> static int pci230_ai_check_scan_period(struct comedi_cmd *cmd)
> {
> - unsigned int min_scan_period, chanlist_len;
> + unsigned int min_scan_period;
> int err = 0;
>
> - chanlist_len = cmd->chanlist_len;
> - if (cmd->chanlist_len == 0)
> - chanlist_len = 1;
> -
> - min_scan_period = chanlist_len * cmd->convert_arg;
> - if ((min_scan_period < chanlist_len)
> - || (min_scan_period < cmd->convert_arg)) {
> + min_scan_period = cmd->chanlist_len * cmd->convert_arg;
> + if ((min_scan_period < cmd->chanlist_len) ||
> + (min_scan_period < cmd->convert_arg)) {
> /* Arithmetic overflow. */
> min_scan_period = UINT_MAX;
> err++;
> @@ -1703,19 +1699,16 @@ static int pci230_ai_cmdtest(struct comedi_device *dev,
> unsigned int max_speed_ai;
>
> if (devpriv->hwver == 0) {
> - /* PCI230 or PCI260. Max speed depends whether
> - * single-ended or pseudo-differential. */
> - if (cmd->chanlist && (cmd->chanlist_len > 0)) {
> - /* Peek analogue reference of first channel. */
> - if (CR_AREF(cmd->chanlist[0]) == AREF_DIFF)
> - max_speed_ai = MAX_SPEED_AI_DIFF;
> - else
> - max_speed_ai = MAX_SPEED_AI_SE;
> -
> - } else {
> - /* No channel list. Assume single-ended. */
> + /*
> + * PCI230 or PCI260. Max speed depends whether
> + * single-ended or pseudo-differential.
> + *
> + * Peek analogue reference of first channel.
> + */
> + if (CR_AREF(cmd->chanlist[0]) == AREF_DIFF)
> + max_speed_ai = MAX_SPEED_AI_DIFF;
> + else
> max_speed_ai = MAX_SPEED_AI_SE;
> - }
> } else {
> /* PCI230+ or PCI260+. */
> max_speed_ai = MAX_SPEED_AI_PLUS;
>
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti at mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
More information about the devel
mailing list