staging: comedi: ni_mio_common: only do counter commands for ni_pcimio
authorIan Abbott <abbotti@mev.co.uk>
Fri, 10 May 2013 13:07:17 +0000 (14:07 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 May 2013 21:38:47 +0000 (17:38 -0400)
commitbd304a736afd99cc38bad4d1628e8e2d05d308d5
tree4afa3a578f030de355bbeb49a1d342c8a40f1e54
parent4efc4bbdc1602d887d784be629a7a4efbf6b6e19
staging: comedi: ni_mio_common: only do counter commands for ni_pcimio

"ni_mio_common.c" holds common code included by "ni_pcimio.c",
"ni_atmio.c" and "ni_mio_cs.c", including a common initialization
function `ni_E_init()`.  Amongst other things, this initializes some
counter subdevices to support comedi instructions and asynchronous
commands.  However, even though it sets up the handlers to support
asynchronous commands on these subdevices, the handlers will return an
error unless the `PCIDMA` macro is defined (which is defined only in
"ni_pcimio.c").  If the `PCIDMA` macro is not defined, the comedi core
will needlessly allocate buffers to support the asynchronous commands.
Also, `s->async_dma_dir` is set to `DMA_BIDIRECTIONAL`, causing the
physical pages for the buffers to be allocated using
`dma_alloc_coherent()`.

If the comedi core cannot call `dma_alloc_coherent()` because
`CONFIG_HAS_DMA` is not defined, it will fail to allocate the buffers,
which ultimately causes `ni_E_init()` to fail.

Avoid the wastage and prevent the failure by only setting up
asynchronous command support for the counter subdevices if the `PCIDMA`
macro is defined.

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