Skip to content

Commit c9b19ea

Browse files
committed
dma-mapping: avoid potential unused data compilation warning
When CONFIG_NEED_DMA_MAP_STATE is not defined, dma-mapping clients might report unused data compilation warnings for dma_unmap_*() calls arguments. Redefine macros for those calls to let compiler to notice that it is okay when the provided arguments are not used. Reported-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Suggested-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20250415075659.428549-1-m.szyprowski@samsung.com
1 parent 2042c35 commit c9b19ea

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

include/linux/dma-mapping.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -629,10 +629,14 @@ static inline int dma_mmap_wc(struct device *dev,
629629
#else
630630
#define DEFINE_DMA_UNMAP_ADDR(ADDR_NAME)
631631
#define DEFINE_DMA_UNMAP_LEN(LEN_NAME)
632-
#define dma_unmap_addr(PTR, ADDR_NAME) (0)
633-
#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) do { } while (0)
634-
#define dma_unmap_len(PTR, LEN_NAME) (0)
635-
#define dma_unmap_len_set(PTR, LEN_NAME, VAL) do { } while (0)
632+
#define dma_unmap_addr(PTR, ADDR_NAME) \
633+
({ typeof(PTR) __p __maybe_unused = PTR; 0; })
634+
#define dma_unmap_addr_set(PTR, ADDR_NAME, VAL) \
635+
do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
636+
#define dma_unmap_len(PTR, LEN_NAME) \
637+
({ typeof(PTR) __p __maybe_unused = PTR; 0; })
638+
#define dma_unmap_len_set(PTR, LEN_NAME, VAL) \
639+
do { typeof(PTR) __p __maybe_unused = PTR; } while (0)
636640
#endif
637641

638642
#endif /* _LINUX_DMA_MAPPING_H */

0 commit comments

Comments
 (0)