Commit Graph

6331 Commits

Author SHA1 Message Date
Ian Abbott
238b5ad855 staging: comedi: fix memory leak / bad pointer freeing for chanlist
As a follow-up to commit 6cab7a37f5 ("staging: comedi: (regression)
channel list must be set for COMEDI_CMD ioctl"), Hartley Sweeten pointed
out another couple of bugs stemming from commit 6cab7a37f5 ("staging:
comedi: comedi_fops: introduce __comedi_get_user_chanlist()").

Firstly, `do_cmdtest_ioctl()` never frees the kernel copy of the user
chanlist allocated by `__comedi_get_user_chanlist()`, so that memory is
leaked.  Fix it by freeing the allocated kernel memory pointed to by
`cmd.chanlist` before that pointer is overwritten with its original
pointer to user memory before `cmd` is copied back to user-space.

Secondly, if `__comedi_get_user_chanlist()` returns an error,
`cmd->chanlist` is left unchanged and in fact will be a pointer to user
memory.  This causes `do_cmd_ioctl()` to `goto cleanup` and call
`do_become_nonbusy()` which would attempt to free the memory pointed to
by the user-space pointer.  Fix it by setting `cmd->chanlist` to NULL at
the start of `__comedi_get_user_chanlist()`.

Fixes: c6cd0eefb2 ("staging: comedi: comedi_fops: introduce __comedi_get_user_chanlist()")
Reported-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: <stable@vger.kernel.org> # 3.15.y 3.16.y 3.17.y: 6cab7a37f5
Cc: <stable@vger.kernel.org> # 3.15.y 3.16.y 3.17.y

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 16:18:31 +08:00
Ian Abbott
0ea6fa037e staging: comedi: Kconfig: fix config COMEDI_ADDI_APCI_3120 dependants
A merge conflict between commits
fbfd9c8a17 ("staging: comedi:
addi_apci_3120: use dma_alloc_coherent()") and
aff5b1f8eb ("staging: comedi: remove
comedi_fc module") left the COMEDI_ADDI_APCI_3120 config option
depending on VIRT_TO_BUS when it no longer needs to do so.  The
dependency was removed by the first commit and accidentally reinstated
by the second commit.  Remove the dependency again.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 16:18:31 +08:00
Ian Abbott
c1a6eac169 staging: comedi: widen subdevice number argument in ioctl handlers
For the `COMEDI_LOCK`, `COMEDI_UNLOCK`, `COMEDI_CANCEL`, and
`COMEDI_POLL` ioctls the third argument is a comedi subdevice number.
This is passed as an `unsigned long`, but when it is passed down to the
ioctl command-specific handler functions `do_lock_ioctl()`,
`do_unlock_ioctl()`, `do_cancel_ioctl()`, and `do_poll_ioctl()`, the
value has been narrowed to an `unsigned int`.  Pass through the argument
as an `unsigned long` to avoid truncating the value on 64-bit
architectures.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-29 16:18:31 +08:00
Chen Gang
ab608c2478 drivers/staging/comedi/Kconfig: Let COMEDI_II_PCI20KC depend on HAS_IOMEM
COMEDI_II_PCI20KC needs HAS_IOMEM, so depend on it. The related error (
with allmodconfig under um):

    CC [M]  drivers/staging/comedi/drivers/ii_pci20kc.o
  drivers/staging/comedi/drivers/ii_pci20kc.c: In function ‘ii20k_attach’:
  drivers/staging/comedi/drivers/ii_pci20kc.c:442:2: error: implicit declaration of function ‘ioremap’ [-Werror=implicit-function-declaration]
    dev->mmio = ioremap(membase, II20K_SIZE);
    ^
  drivers/staging/comedi/drivers/ii_pci20kc.c:442:12: warning: assignment makes pointer from integer without a cast [enabled by default]
    dev->mmio = ioremap(membase, II20K_SIZE);
              ^
  drivers/staging/comedi/drivers/ii_pci20kc.c: In function ‘ii20k_detach’:
  drivers/staging/comedi/drivers/ii_pci20kc.c:512:3: error: implicit declaration of function ‘iounmap’ [-Werror=implicit-function-declaration]
     iounmap(dev->mmio);
     ^

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-20 10:56:17 +08:00
Ian Abbott
6cab7a37f5 staging: comedi: (regression) channel list must be set for COMEDI_CMD ioctl
`do_cmd_ioctl()`, the handler for the `COMEDI_CMD` ioctl can incorrectly
call the Comedi subdevice's `do_cmd()` handler with a NULL channel list
pointer.  This is a regression as the `do_cmd()` handler has never been
expected to deal with that, leading to a kernel OOPS when it tries to
dereference it.

A NULL channel list pointer is allowed for the `COMEDI_CMDTEST` ioctl,
handled by `do_cmdtest_ioctl()` and the subdevice's `do_cmdtest()`
handler, but not for the `COMEDI_CMD` ioctl and its handlers.

Both `do_cmd_ioctl()` and `do_cmdtest_ioctl()` call
`__comedi_get_user_chanlist()` to copy the channel list from user memory
into dynamically allocated kernel memory and check it for consistency.
That function currently returns 0 if the `user_chanlist` parameter
(pointing to the channel list in user memory) is NULL.  That's fine for
`do_cmdtest_ioctl()`, but `do_cmd_ioctl()` incorrectly assumes the
kernel copy of the channel list has been set-up correctly.

Fix it by not allowing the `user_chanlist` parameter to be NULL in
`__comedi_get_user_chanlist()`, and only calling it from
`do_cmdtest_ioctl()` if the parameter is non-NULL.

Thanks to Bernd Porr for reporting the bug via an initial patch sent
privately.

Fixes: c6cd0eefb2 ("staging: comedi: comedi_fops: introduce __comedi_get_user_chanlist()")
Reported-by: Bernd Porr <mail@berndporr.me.uk>
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Bernd Porr <mail@berndporr.me.uk>
Cc: <stable@vger.kernel.org> # 3.15.y 3.16.y 3.17.y
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-10-20 10:56:17 +08:00
Luca Ellero
7baf929491 staging: comedi: ni_usb6501: add counter subdevice
Add counter support for NI USB-6501.

The following functions are introduced:
- ni6501_counter_command()
- ni6501_cnt_insn_config()
- ni6501_cnt_insn_read()
- ni6501_cnt_insn_write()

Signed-off-by: Luca Ellero <luca.ellero@brickedbrain.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:58:18 -07:00
Luca Ellero
5116a48c1b staging: comedi: ni_usb6501: rename ni6501_send_command()
Rename ni6501_send_command to ni6501_port_command

Signed-off-by: Luca Ellero <luca.ellero@brickedbrain.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:58:18 -07:00
Luca Ellero
d6669ba21b staging: comedi: ni_usb6501: remove empty lines
ni6501_send_command(): remove empty lines in case statements

Signed-off-by: Luca Ellero <luca.ellero@brickedbrain.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:58:18 -07:00
Luca Ellero
78d8135608 staging: comedi: ni_usb6501: remove useless check
Remove useless test in ni6501_send_command. The check is useless since this
function is called only in this driver.

Signed-off-by: Luca Ellero <luca.ellero@brickedbrain.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:58:18 -07:00
Luca Ellero
e9826c0c8a staging: comedi: ni_usb6501: replace spaces with tabs
ni6501_auto_attach(): replace spaces with tabs to get proper alignment

Signed-off-by: Luca Ellero <luca.ellero@brickedbrain.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:58:18 -07:00
Luca Ellero
88367bd588 staging: comedi: ni_usb6501: cleanup response_size
Cleanup response_size in ni6501_send_command (READ_PORT command).
No logical/functional change is introduced by this patch.

Signed-off-by: Luca Ellero <luca.ellero@brickedbrain.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:58:18 -07:00
Luca Ellero
ddf9b6a4a0 staging: comedi: ni_usb6501: update comments
Signed-off-by: Luca Ellero <luca.ellero@brickedbrain.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:58:18 -07:00
Luca Ellero
aa66cd164b staging: comedi: ni_usb6501: add counter commands
Signed-off-by: Luca Ellero <luca.ellero@brickedbrain.com>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:58:18 -07:00
Ian Abbott
aff5b1f8eb staging: comedi: remove comedi_fc module
All the exported functions in the "comedi_fc" module have been migrated
to the core "comedi" module and renamed, so it is now just a dummy
module.  Remove it.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:56:49 -07:00
Ian Abbott
b8d57655fd staging: comedi: migrate copyrights from "comedi_fc.c"
The "comedi_fc" module was originally written and copyrighted by Frank
Mori Hess, but the functionality has been migrated into the core
"comedi" module.  Move the copyright notices over to the affected .c
files in the core comedi module.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:55:32 -07:00
Ian Abbott
bfa9facdb1 staging: comedi: add comedi_read_array_from_buffer()
The "comedi_fc" module contains a few functions useful to Comedi
drivers.  Their functionality is being migrated to the core "comedi"
module and renamed to start with the prefix `comedi_`.  As part of this
migration, move `cfc_read_array_from_buffer()` into the core comedi
module and rename it to `comedi_read_array_from_buffer()`.  Change the
external declaration of `cfc_read_array_from_buffer()` into an inline
function that calls `comedi_read_array_from_buffer()`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:55:32 -07:00
Ian Abbott
af2c6a8a24 staging: comedi: comedi_fc.h: use comedi_write_array_to_buffer()
Since `cfc_write_array_to_buffer()` is just an inline function that
calls `comedi_write_array_to_buffer()`, replace calls to the former to
the latter in the "comedi_fc.h" header.  This is part of the migration
of functionality from the "comedi_fc" module to the core "comedi"
module.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:55:31 -07:00
Ian Abbott
ea29c1d563 staging: comedi: add comedi_write_array_to_buffer()
The "comedi_fc" module contains a few functions useful to Comedi
drivers.  Their functionality is being migrated to the core "comedi"
module and renamed to start with the prefix `comedi_`.  As part of this
migration, move `cfc_write_array_to_buffer()` into the core comedi
module and rename it to `comedi_write_array_to_buffer()`.  Change the
external declaration of `cfc_write_array_to_buffer()` into an inline
function that calls `comedi_write_array_to_buffer()`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:55:31 -07:00
Ian Abbott
5c520aafa0 staging: comedi: comedi_fc: cfc_write_array_to_buffer() data is const
The `data` pointer of `cfc_write_array_to_buffer()` ought to point to
`const` data.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:55:31 -07:00
Ian Abbott
5a78035924 staging: comedi: add comedi_handle_events()
The "comedi_fc" module contains a few functions useful to Comedi
drivers.  Their functionality is being migrated to the core "comedi"
module and renamed to start with the prefix `comedi_`.  As part of this
migration, move `cfc_handle_events()` into the core comedi module and
rename it to `comedi_handle_events()`.  Change the external declaration
of `cfc_handle_events()` into an inline function that calls
`comedi_handle_events()`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:55:31 -07:00
Ian Abbott
1c38d6f22a staging: comedi: comedi_fc: use comedi_inc_scan_progress()
Since `cfc_inc_scan_progress()` is just an inline function that calls
`comedi_inc_scan_progress()`, replace calls to the former to the latter
in the "comedi_fc" module.  This is part of the migration of
functionality from the "comedi_fc" module to the core "comedi" module.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:55:31 -07:00
Ian Abbott
2b4e1f6324 staging: comedi: add comedi_inc_scan_progress()
The "comedi_fc" module contains a few functions useful to Comedi
drivers.  Their functionality is being migrated to the core "comedi"
module and renamed to start with the prefix `comedi_`.  As part of this
migration, move `cfc_inc_scan_progress()` into the core comedi module
and rename it to `comedi_inc_scan_progress()`.  Change the external
declaration of `cfc_inc_scan_progress()` into an inline function that
calls `comedi_inc_scan_progress()`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:55:31 -07:00
Ian Abbott
55deb39b12 staging: comedi: comedi_fc: use comedi_bytes_per_scan()
Since `cfc_bytes_per_scan()` is just an inline function that calls
`comedi_bytes_per_scan()`, replace calls to the former to the latter in
the "comedi_fc" module.  This is part of the migration of functionality
from the "comedi_fc" module to the core "comedi" module.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:55:31 -07:00
Ian Abbott
f146fe6341 staging: comedi: add comedi_bytes_per_scan()
The "comedi_fc" module contains a few functions useful to Comedi
drivers.  Their functionality is being migrated to the core "comedi"
module and renamed to start with the prefix `comedi_`.  As part of this
migration, move `cfc_bytes_per_scan()` into the core comedi module and
rename it to `comedi_bytes_per_scan()`.  Change the external declaration
of `cfc_bytes_per_scan()` into an inline function that calls
`comedi_bytes_per_scan()`.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:55:31 -07:00
Ian Abbott
062fdcada9 staging: comedi: addi_apci_3120: simplify setting of devpriv->us_UseDma
`apci3120_auto_attach()` first sets `devpriv->us_UseDma` to 1, then sets
it back to 0 if it fails to allocate the DMA buffer.  Since `*devpriv`
is initially zeroed out by `comedi_alloc_devpriv()`, change it to only
set `devpriv->us_UseDma` to 1 if the allocation succeeds.  Also, don't
bother explicitly initializing `devpriv->b_DmaDoubleBuffer` to 0 as it
is already zeroed out.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:39:39 -07:00
Ian Abbott
fbfd9c8a17 staging: comedi: addi_apci_3120: use dma_alloc_coherent()
Use `dma_alloc_coherent()` to allocate the DMA buffers instead of
using `__get_free_pages()` to allocate and `virt_to_bus()` to get the
hardware address.  The coherent buffers are fairly small - at most 4
pages (although there are two of them).  Use of `virt_to_bus()` is
discouraged.

Note: `struct addi_private` is used by some other ADDI-DATA drivers as
well, but this is the only one using the affected members.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:39:39 -07:00
Ian Abbott
9c97e588d8 staging: comedi: addi_apci_3120: don't overallocate DMA buffer
The last parameter of `__get_free_pages()` is log2 (the 'order') of the
number of pages to be allocated.  This driver seems to think it is the
linear number of pages, so `apci3120_auto_attach()` first tries to allocate
16 pages, but only uses 4 of them, setting the buffer size to PAGE_SIZE
multiplied by the 'order'.  If the allocation fails, it tries
progressively smaller orders, down to 0.  If the allocation at order 0
succeeds, the buffer size is set to 0, which is likely to cause
problems.

Set the buffer size to `PAGE_SIZE` shifted left by the allocation order.
Since the maximum buffer size previously used was 4, start with an
allocation order of 2 instead of 4.  Rename the `ui_DmaBufferPages` member of
`struct addi_private` to `ui_DmaBufferPageOrder` and rename the `pages`
local variable to `order` to make it clearer what it is.

Note: `struct addi_private` is used by some other ADDI-DATA drivers as
well, but this is the only one using the affected members.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:39:39 -07:00
Ian Abbott
df567feb00 staging: comedi: addi_apci_3120: don't allocate 2nd DMA buffer on failure
`apci3120_auto_attach()` tries to allocate two DMA buffers but may
allocate a single buffer or none at all.  If it fails to allocate the
first buffer, it still tries to allocate the second buffer, even though
it won't be used.  Change it to not bother trying to allocate the second
buffer if the first one fails.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:39:39 -07:00
Ian Abbott
aee447566d staging: comedi: remove comedi_board()
All calls to the inline function `comedi_board()` in "comedidev.h" have
been removed, so remove the function.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:36:25 -07:00
Ian Abbott
75fbdbf61d staging: comedi: adl_pci9118: use dma_alloc_coherent()
Use `dma_alloc_coherent()` to allocate the DMA buffers instead of
using `__get_free_pages()` to allocate and `virt_to_bus()` to get the
hardware address.  The coherent buffers are fairly small - at most 4
pages (although there are two of them).  Use of `virt_to_bus()` is
discouraged.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:36:25 -07:00
Ian Abbott
f39f87e9ea staging: comedi: adl_pci9118: don't overallocate DMA buffer
The last parameter of `__get_free_pages()` is log2 (the 'order') of the
number of pages to be allocated.  This driver seems to think it is the
linear number of pages, so `pci9118_alloc_dma()` first tries to allocate
16 pages, but only uses 4 of them, setting the buffer size to PAGE_SIZE
multiplied by the 'order'.  If the allocation fails, it tries
progressively smaller orders, down to 0.  If the allocation at order 0
succeeds, the buffer size is set to 0, which is likely to cause
problems.

Set the buffer size to `PAGE_SIZE` shifted left by the allocation order.
Since the maximum buffer size previously used was 4, start with an
allocation order of 2 instead of 4.  Rename the `pages` member of
`struct pci9118_dmabuf` (and the local variable in
`pci9118_alloc_dma()`) to `order` to make it clearer what it is.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:36:25 -07:00
Ian Abbott
d5733baf23 staging: comedi: adl_pci9118: don't allocate 2nd DMA buffer on failure
`pci9118_alloc_dma()` tries to allocate two DMA buffers but may allocate
a single buffer or none at all.  If it fails to allocate the first
buffer, it still tries to allocate the second buffer, even though it
won't be used.  Change it to not bother trying to allocate the second
buffer if the first one fails.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-19 15:36:24 -07:00
Ian Abbott
0220d472df staging: comedi: adl_pci9118: replace comedi_board() calls
The `comedi_board(dev)` inline function calls just return
`dev->board_ptr`.  Expand the inline function calls.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-11 14:36:45 -07:00
Ian Abbott
058543b77f staging: comedi: amplc_dio200_common: replace comedi_board() calls
The `comedi_board(dev)` inline function calls just return
`dev->board_ptr`.  Expand the inline function calls.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-11 14:36:45 -07:00
Chase Southwood
d699f10766 staging: comedi: hwdrv_apci3120: remove void function return statement
Returns at the end of void functions are useless.  Remove this one.

Signed-off-by: Chase Southwood <chase.southwood@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-11 14:36:06 -07:00
Chase Southwood
bfc81c4a22 staging: comedi: hwdrv_apci3120: else is not useful after return
The statement nested in an else after a return may be brought out one
indent level, the else is useless.

Signed-off-by: Chase Southwood <chase.southwood@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-11 14:36:06 -07:00
Chase Southwood
8aeec82ffd staging: comedi: hwdrv_apci3120: add a blank line after declarations
Signed-off-by: Chase Southwood <chase.southwood@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-11 14:36:06 -07:00
Chase Southwood
93093cad2a staging: comedi: hwdrv_apci3120: clean up comments
This patch fixes improper comment indentation, removes dead code and
obsolete comments, and conforms remaining comments to a consistent kernel
commenting style.

Signed-off-by: Chase Southwood <chase.southwood@gmail.com>
Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
Cc: H Hartley Sweeten <hsweeten@visionengravers.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2014-09-11 14:36:06 -07:00
H Hartley Sweeten
aaa0c2f77b staging: comedi: usbduxsigma: prevent "empty acquisition" async commands
This driver currently allows a cmd->stop_src == TRIG_COUNT with a cmd->stop_arg
of 0 for both the analog input and output async commands. The (*do_cmd) for
both subdevices sets up and starts the command without handling the "empty
acquisition". This results in the interrupt functions trying to transfer 0 data
samples.

Validate that the cmd->stop_arg is >= 1 in the (*do_cmdtest) to prevent the
"empty acquisition".

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>
2014-09-11 14:35:22 -07:00
H Hartley Sweeten
e98348e0cb staging: comedi: usbdux: prevent "empty acquisition" async commands
This driver currently allows a cmd->stop_src == TRIG_COUNT with a cmd->stop_arg
of 0 for both the analog input and output async commands. The (*do_cmd) for
both subdevices sets up and starts the command without handling the "empty
acquisition". This results in the interrupt functions trying to transfer 0 data
samples.

Validate that the cmd->stop_arg is >= 1 in the (*do_cmdtest) to prevent the
"empty acquisition".

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>
2014-09-11 14:35:22 -07:00
H Hartley Sweeten
32f9ff7039 staging: comedi: s626: fix cmd->stop_arg validation for stop_src == TRIG_COUNT
The only limit for the stop_arg with a stop_src == TRIG_COUNT is that there is at
least 1 scan in order to prevent an empty acquisition. The max test is bogus.

Fix the validation.

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>
2014-09-11 14:35:22 -07:00
H Hartley Sweeten
8b9505527e staging: comedi: s626: 'ai_sample_count' is always 'stop_arg'
When the cmd->stop_src == TRIG_COUNT, the 'ai_sample_count' is the cmd->stop_arg.
For a stop_src == TRIG_NONE the 'ai_sample_count' is currently set to 1 but the
driver never actually uses the value.

Simplify the 'stop_count' initialization by just setting it to the cmd->stop_arg.

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>
2014-09-11 14:35:22 -07:00
H Hartley Sweeten
27cb98142f staging: comedi: s626: clarify COMEDI_CB_EOA code
The end-of-acquisition only applies when the cmd->stop_src == TRIG_COUNT.

Refactor the code in s626_handle_eos_interrupt() that detects the end-of-
acquisition to clarify this.

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>
2014-09-11 14:35:22 -07:00
H Hartley Sweeten
e37b20aa58 staging: comedi: s626: remove 'ai_continuous' from private data
This member of the private data is set based on the cmd->stop_src. Just use the
cmd->stop_src directly and remove the member.

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>
2014-09-11 14:35:21 -07:00
H Hartley Sweeten
8c602c498c staging: comedi: rtd520: prevent "empty acquisition" async command
This driver currently allows a cmd->stop_src == TRIG_COUNT with a cmd->stop_arg
of 0. The (*do_cmd) then sets up and starts the command without handling the "empty
acquisition". This results in the interrupt function trying to transfer 0 data
samples.

Validate that the cmd->stop_arg is >= 1 in the (*do_cmdtest) to prevent the
"empty acquisition".

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>
2014-09-11 14:35:21 -07:00
H Hartley Sweeten
1e2e39effd staging: comedi: pcmuio: return void from pcmuio_start_intr()
This function always returns '0' so the comedi_event() is never done by the
callers.

Change the return type to void and remove the comedi_event() dead 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>
2014-09-11 14:35:21 -07:00
H Hartley Sweeten
8e7fed7ed7 staging: comedi: pcmuio: 'stop_count' is always 'stop_arg'
When the cmd->stop_src == TRIG_COUNT, the 'stop_count' is the cmd->stop_arg.
For any other stop_src the 'stop_count' is 0, which is also the cmd->stop_arg.

Simplify the 'stop_count' initialization.

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>
2014-09-11 14:35:21 -07:00
H Hartley Sweeten
75d46fd781 staging: comedi: pcmuio: remove 'continuous' from private data
This member of the private data is set based on the cmd->stop_src. Just use the
cmd->stop_src directly and remove the member.

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>
2014-09-11 14:35:21 -07:00
H Hartley Sweeten
7173126484 staging: comedi: pcmuio: remove "empty acquisition" async command
This driver currently allows a cmd->stop_src == TRIG_COUNT with a cmd->stop_arg
of 0. This causes the (*do_cmd) to immediately generate a COMEDI_CB_EOA event
without acquiring any data.

This "empty acquisition" async command is not really useful. Validate that the
cmd->stop_arg is >= 1 in the (*do_cmdtest) and remove the "empty acquisition"
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>
2014-09-11 14:35:21 -07:00
H Hartley Sweeten
22499048e3 staging: comedi: pcmmio: return void from pcmmio_start_intr()
This function always returns '0' so the comedi_event() is never done by the
callers.

Change the return type to void and remove the comedi_event() dead 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>
2014-09-11 14:35:21 -07:00