lib: utils/fdt: Require match data to be const
PATCH v2 1/1 lib: utils/fdt: Require match data to be const
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 <[email protected]>
Reviewed-by Xiang W <[email protected]>
Signed-off-by Samuel Holland <[email protected]>
---
Changes in v2:
- Send separately from D1 CLINT patch
- Add Reviewed-by tags
include/sbi_utils/fdt/fdt_helper.h | 2 +- lib/utils/ipi/fdt_ipi_mswi.c | 2 +- lib/utils/reset/fdt_reset_gpio.c | 4 ++-- lib/utils/timer/fdt_timer_mtimer.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)
include/sbi_utils/fdt/fdt_helper.h +1 -1
@@ -15,7 +15,7 @@struct fdt_match {const char *compatible; -void *data; +const void *data; };#define FDT_MAX_PHANDLE_ARGS 16
lib/utils/ipi/fdt_ipi_mswi.c +1 -1
@@ -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 },
lib/utils/reset/fdt_reset_gpio.c +2 -2
@@ -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 }, { }, };
lib/utils/timer/fdt_timer_mtimer.c +1 -1
@@ -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 },
Signature · 1 line
2.35.1
Anup Patel
AppliedPATCH v2 1/1 lib: utils/fdt: Require match data to be const
Quoted 7 lines · Samuel Holland
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 <[email protected]>Reviewed-by Xiang W <[email protected]>Signed-off-by Samuel Holland <[email protected]>
Looks good to me.
Reviewed-by Anup Patel <[email protected]>
Applied this patch to the riscv/opensbi repo.
Thanks,
Anup
Quoted 81 lines
---
Changes in v2:
- Send separately from D1 CLINT patch
- Add Reviewed-by tagsinclude/sbi_utils/fdt/fdt_helper.h | 2 +- lib/utils/ipi/fdt_ipi_mswi.c | 2 +- lib/utils/reset/fdt_reset_gpio.c | 4 ++-- lib/utils/timer/fdt_timer_mtimer.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-)include/sbi_utils/fdt/fdt_helper.h +1
-1@@ -15,7 +15,7 @@struct fdt_match {const char *compatible; -void *data; +const void *data; };#define FDT_MAX_PHANDLE_ARGS 16lib/utils/ipi/fdt_ipi_mswi.c +1
-1@@ -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 },lib/utils/reset/fdt_reset_gpio.c +2
-2@@ -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 }, { }, };lib/utils/timer/fdt_timer_mtimer.c +1
-2@@ -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 }, --2.35.1
--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi