Skip to content

Commit

Permalink
dma-mapping: Convert NO_DMA get_dma_ops() into a real dummy
Browse files Browse the repository at this point in the history
If NO_DMA=y, get_dma_ops() returns a reference to the
non-existing symbol bad_dma_ops, thus causing a link failure if it is
ever used.

Make get_dma_ops() return NULL instead, to avoid the link failure.
This allows to improve compile-testing, and limits the need to keep on
sprinkling dependencies on HAS_DMA all over the place.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Reviewed-by: Mark Brown <broonie@kernel.org>
Acked-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Geert Uytterhoeven authored and Christoph Hellwig committed Mar 16, 2018
1 parent 0c8efd6 commit f29ab49
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions include/linux/dma-mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ static inline void set_dma_ops(struct device *dev,
}
#else
/*
* Define the dma api to allow compilation but not linking of
* dma dependent code. Code that depends on the dma-mapping
* API needs to set 'depends on HAS_DMA' in its Kconfig
* Define the dma api to allow compilation of dma dependent code.
* Code that depends on the dma-mapping API needs to set 'depends on HAS_DMA'
* in its Kconfig, unless it already depends on <something> || COMPILE_TEST,
* where <something> guarantuees the availability of the dma-mapping API.
*/
extern const struct dma_map_ops bad_dma_ops;
static inline const struct dma_map_ops *get_dma_ops(struct device *dev)
{
return &bad_dma_ops;
return NULL;
}
#endif

Expand Down

0 comments on commit f29ab49

Please sign in to comment.