Skip to contentSkip to conversation

dma/contiguous: avoid warning about unused size_bytes

PATCH Applied Arnd Bergmann 2 participants 2 messages Apr 9, 2025 DMA mapping helpers

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 dma/contiguous: avoid warning about unused size_bytes

From: Arnd Bergmann <[email protected]>

When building with W=1, this variable is unused for configs with CONFIG_CMA_SIZE_SEL_PERCENTAGE=y:

kernel/dma/contiguous.c:67:26: error: 'size_bytes' defined but not used [-Werror=unused-const-variable=]

Change this to a macro to avoid the warning.

Fixes c64be2bb1c6e ("drivers: add Contiguous Memory Allocator")

---
v4: fix type mistake from v3
v3: use a macro instead of constant
v2: fix spelling mistake.

---
 kernel/dma/contiguous.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/dma/contiguous.c +1 -2
index 055da410ac71..8df0dfaaca18 100644
@@ -64,8 +64,7 @@ struct cma *dma_contiguous_default_area;
  * Users, who want to set the size of global CMA area for their system
  * should use cma= kernel parameter.
  */
-static const phys_addr_t size_bytes __initconst =
-	(phys_addr_t)CMA_SIZE_MBYTES * SZ_1M;
+#define size_bytes ((phys_addr_t)CMA_SIZE_MBYTES * SZ_1M)
 static phys_addr_t  size_cmdline __initdata = -1;
 static phys_addr_t base_cmdline __initdata;
 static phys_addr_t limit_cmdline __initdata;
Signature · 1 line
2.39.5
maintainer Applied
#1 lore raw
Quoted 11 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When building with W=1, this variable is unused for configs with CONFIG_CMA_SIZE_SEL_PERCENTAGE=y:

kernel/dma/contiguous.c:67:26: error: 'size_bytes' defined but not used [-Werror=unused-const-variable=]

Change this to a macro to avoid the warning.

Fixes c64be2bb1c6e ("drivers: add Contiguous Memory Allocator")

Thanks, applied to dma-mapping-fixes branch.

Quoted 13 lines

---
v4: fix type mistake from v3
v3: use a macro instead of constant
v2: fix spelling mistake.

---
  kernel/dma/contiguous.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)
kernel/dma/contiguous.c +0 -0
index 055da410ac71..8df0dfaaca18 100644

kernel/dma/contiguous.c struct cma *dma_contiguous_default_area; · line 70

Quoted 9 lines
kernel/dma/contiguous.c +1 -2
@@ -64,8 +64,7 @@ struct cma *dma_contiguous_default_area;
   * Users, who want to set the size of global CMA area for their system
   * should use cma= kernel parameter.
   */
-static const phys_addr_t size_bytes __initconst =
-	(phys_addr_t)CMA_SIZE_MBYTES * SZ_1M;
+#define size_bytes ((phys_addr_t)CMA_SIZE_MBYTES * SZ_1M)
  static phys_addr_t  size_cmdline __initdata = -1;
  static phys_addr_t base_cmdline __initdata;
  static phys_addr_t limit_cmdline __initdata;

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland