staging: comedi: work without HAS_DMA
The core "comedi" module and the "mite" helper module for NI PCI devices both have calls to `dma_alloc_coherent()` and `dma_free_coherent()`. Those functions are only available if `CONFIG_HAS_DMA` is defined. Apart from the "mite" module, the functions are only called for comedi drivers that set `s->async_dma_dir` (where `s` is a pointer to a `struct comedi_subdevice`) to anything other than `DMA_NONE`. Change local helper functions `__comedi_buf_alloc()` and `__comedi_buf_free()` to only call `dma_alloc_coherent()` and `dma_free_coherent()` if `CONFIG_HAS_DMA` is defined. Change the "Kconfig" to make the following configuration options depend on `HAS_DMA`: `COMEDI_MITE` - builds the "mite" module. `COMEDI_NI_6527` - selects `COMEDI_MITE`. `COMEDI_NI_65XX` - selects `COMEDI_MITE`. `COMEDI_NI_670X` - selects `COMEDI_MITE`. `COMEDI_NI_LABPC_PCI` - selects `COMEDI_MITE`. `COMEDI_NI_PCIDIO` - selects `COMEDI_MITE`. `COMEDI_NI_TIOCMD` - selects `COMEDI_MITE`. `COMEDI_NI_660X` - selects `COMEDI_NI_TIOCMD`, sets `s->async_dma_dir`. `COMEDI_NI_PCIMIO` - selects `COMEDI_NI_TIOCMD`, sets `s->async_dma_dir`. 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>
This commit is contained in:
parent
b3fab42773
commit
4efc4bbdc1
|
@ -981,6 +981,7 @@ config COMEDI_ME_DAQ
|
|||
|
||||
config COMEDI_NI_6527
|
||||
tristate "NI 6527 support"
|
||||
depends on HAS_DMA
|
||||
select COMEDI_MITE
|
||||
---help---
|
||||
Enable support for the National Instruments 6527 PCI card
|
||||
|
@ -990,6 +991,7 @@ config COMEDI_NI_6527
|
|||
|
||||
config COMEDI_NI_65XX
|
||||
tristate "NI 65xx static dio PCI card support"
|
||||
depends on HAS_DMA
|
||||
select COMEDI_MITE
|
||||
---help---
|
||||
Enable support for National Instruments 65xx static dio boards.
|
||||
|
@ -1003,6 +1005,7 @@ config COMEDI_NI_65XX
|
|||
|
||||
config COMEDI_NI_660X
|
||||
tristate "NI 660x counter/timer PCI card support"
|
||||
depends on HAS_DMA
|
||||
select COMEDI_NI_TIOCMD
|
||||
---help---
|
||||
Enable support for National Instruments PCI-6601 (ni_660x), PCI-6602,
|
||||
|
@ -1013,6 +1016,7 @@ config COMEDI_NI_660X
|
|||
|
||||
config COMEDI_NI_670X
|
||||
tristate "NI 670x PCI card support"
|
||||
depends on HAS_DMA
|
||||
select COMEDI_MITE
|
||||
---help---
|
||||
Enable support for National Instruments PCI-6703 and PCI-6704
|
||||
|
@ -1022,6 +1026,7 @@ config COMEDI_NI_670X
|
|||
|
||||
config COMEDI_NI_LABPC_PCI
|
||||
tristate "NI Lab-PC PCI-1200 support"
|
||||
depends on HAS_DMA
|
||||
select COMEDI_NI_LABPC
|
||||
select COMEDI_MITE
|
||||
---help---
|
||||
|
@ -1032,6 +1037,7 @@ config COMEDI_NI_LABPC_PCI
|
|||
|
||||
config COMEDI_NI_PCIDIO
|
||||
tristate "NI PCI-DIO32HS, PCI-6533, PCI-6534 support"
|
||||
depends on HAS_DMA
|
||||
select COMEDI_MITE
|
||||
select COMEDI_8255
|
||||
---help---
|
||||
|
@ -1043,6 +1049,7 @@ config COMEDI_NI_PCIDIO
|
|||
|
||||
config COMEDI_NI_PCIMIO
|
||||
tristate "NI PCI-MIO-E series and M series support"
|
||||
depends on HAS_DMA
|
||||
select COMEDI_NI_TIOCMD
|
||||
select COMEDI_8255
|
||||
select COMEDI_FC
|
||||
|
@ -1095,10 +1102,12 @@ config COMEDI_SSV_DNP
|
|||
called ssv_dnp.
|
||||
|
||||
config COMEDI_MITE
|
||||
depends on HAS_DMA
|
||||
tristate
|
||||
|
||||
config COMEDI_NI_TIOCMD
|
||||
tristate
|
||||
depends on HAS_DMA
|
||||
select COMEDI_NI_TIO
|
||||
select COMEDI_MITE
|
||||
|
||||
|
|
|
@ -51,10 +51,12 @@ static void __comedi_buf_free(struct comedi_device *dev,
|
|||
clear_bit(PG_reserved,
|
||||
&(virt_to_page(buf->virt_addr)->flags));
|
||||
if (s->async_dma_dir != DMA_NONE) {
|
||||
#ifdef CONFIG_HAS_DMA
|
||||
dma_free_coherent(dev->hw_dev,
|
||||
PAGE_SIZE,
|
||||
buf->virt_addr,
|
||||
buf->dma_addr);
|
||||
#endif
|
||||
} else {
|
||||
free_page((unsigned long)buf->virt_addr);
|
||||
}
|
||||
|
@ -84,11 +86,15 @@ static void __comedi_buf_alloc(struct comedi_device *dev,
|
|||
for (i = 0; i < n_pages; i++) {
|
||||
buf = &async->buf_page_list[i];
|
||||
if (s->async_dma_dir != DMA_NONE)
|
||||
#ifdef CONFIG_HAS_DMA
|
||||
buf->virt_addr = dma_alloc_coherent(dev->hw_dev,
|
||||
PAGE_SIZE,
|
||||
&buf->dma_addr,
|
||||
GFP_KERNEL |
|
||||
__GFP_COMP);
|
||||
#else
|
||||
break;
|
||||
#endif
|
||||
else
|
||||
buf->virt_addr = (void *)get_zeroed_page(GFP_KERNEL);
|
||||
if (!buf->virt_addr)
|
||||
|
|
Loading…
Reference in New Issue