]> git.baikalelectronics.ru Git - kernel.git/commit
staging: comedi: adl_pci9118: tidy up pci9118_ai_setup_dma()
authorH Hartley Sweeten <hsweeten@visionengravers.com>
Mon, 19 Oct 2015 20:13:05 +0000 (13:13 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 25 Oct 2015 02:17:13 +0000 (19:17 -0700)
commit7b310f47a0be02cc297bc8f0451ed9530cb39988
tree405279629145bafad8b318a6832e6a52aa214bc6
parent9ea3473b5289112e36debf1b9d655d465c5e9ff6
staging: comedi: adl_pci9118: tidy up pci9118_ai_setup_dma()

For aesthetics, init the dmalen[01] local variables when they are declared.

Use a local variable, 'scan_bytes', for the (devpriv->ai_n_realscanlen << 1)
calculation. For aesthetics and clarification, use comedi_bytes_per_sample()
instead of the '<< 1' shift to calculate the value.

The local variable 'i' is badly named. Remove it and use a local variable
'tmp' where it is used.

When checking the DMA buffer lengths for non-neverending commands the
scan length calculation, (devpriv->ai_n_realscanlen << 1) * cmd->stop_arg,
could overflow. Use and unsigned long long local variable to hold the
calculation and avoid the overflow.

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>
drivers/staging/comedi/drivers/adl_pci9118.c