lib: utils/fdt: Require match data to be const
authorSamuel Holland <samuel@sholland.org>
Sun, 29 May 2022 18:32:11 +0000 (13:32 -0500)
committerAnup Patel <anup@brainfault.org>
Mon, 30 May 2022 05:02:35 +0000 (10:32 +0530)
Match data stores hardware attributes which do not change at runtime, so
it does not need to be mutable. Make it const.

Reviewed-by: Guo Ren <guoren@kernel.org>
Reviewed-by: Xiang W <wxjstz@126.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Samuel Holland <samuel@sholland.org>
include/sbi_utils/fdt/fdt_helper.h
lib/utils/ipi/fdt_ipi_mswi.c
lib/utils/reset/fdt_reset_gpio.c
lib/utils/timer/fdt_timer_mtimer.c

index 74ea234..c60af35 100644 (file)
@@ -15,7 +15,7 @@
 
 struct fdt_match {
        const char *compatible;
-       void *data;
+       const void *data;
 };
 
 #define FDT_MAX_PHANDLE_ARGS 16
index 1f0fda7..0176941 100644 (file)
@@ -51,7 +51,7 @@ static int ipi_mswi_cold_init(void *fdt, int nodeoff,
        return 0;
 }
 
-static unsigned long clint_offset = CLINT_MSWI_OFFSET;
+static const unsigned long clint_offset = CLINT_MSWI_OFFSET;
 
 static const struct fdt_match ipi_mswi_match[] = {
        { .compatible = "riscv,clint0", .data = &clint_offset },
index d28b6f5..bd2c622 100644 (file)
@@ -149,7 +149,7 @@ static int gpio_reset_init(void *fdt, int nodeoff,
 }
 
 static const struct fdt_match gpio_poweroff_match[] = {
-       { .compatible = "gpio-poweroff", .data = (void *)FALSE },
+       { .compatible = "gpio-poweroff", .data = (const void *)FALSE },
        { },
 };
 
@@ -159,7 +159,7 @@ struct fdt_reset fdt_poweroff_gpio = {
 };
 
 static const struct fdt_match gpio_reset_match[] = {
-       { .compatible = "gpio-restart", .data = (void *)TRUE },
+       { .compatible = "gpio-restart", .data = (const void *)TRUE },
        { },
 };
 
index 1ad8508..82239d5 100644 (file)
@@ -107,7 +107,7 @@ static int timer_mtimer_cold_init(void *fdt, int nodeoff,
        return 0;
 }
 
-static unsigned long clint_offset = CLINT_MTIMER_OFFSET;
+static const unsigned long clint_offset = CLINT_MTIMER_OFFSET;
 
 static const struct fdt_match timer_mtimer_match[] = {
        { .compatible = "riscv,clint0", .data = &clint_offset },