Issue
I am writing a kernel module and in it I have the following piece of code:
dma_dev->coherent_dma_mask = DMA_BIT_MASK(64);
I do not always want 64 in there: when I am targetting ARM, I want it to be
dma_dev->coherent_dma_mask = DMA_BIT_MASK(32);
So basically, for now I want:
#ifdef x86_64
dma_dev->coherent_dma_mask = DMA_BIT_MASK(64);
#else
dma_dev->coherent_dma_mask = DMA_BIT_MASK(32);
#endif
How can I achieve something like this?
Solution
There are CONFIG_
definitions for that. Something like this might fit your needs:
#if defined(CONFIG_X86_64)
dma_dev->coherent_dma_mask = DMA_BIT_MASK(64);
#else
dma_dev->coherent_dma_mask = DMA_BIT_MASK(32);
#endif
CONFIG_ARM
(for 32bit), CONFIG_ARM64
and similar options may also come in handy.
Answered By - user8549610 Answer Checked By - Cary Denson (WPSolving Admin)