[PATCH 1/5] fdtdec: make fdtdec_get_config_string() return const char*
Rasmus Villemoes
rasmus.villemoes at prevas.dk
Tue Nov 10 21:25:59 CET 2020
Nobody should modify the string returned by
fdtdec_get_config_string(), so make it return a const pointer.
Signed-off-by: Rasmus Villemoes <rasmus.villemoes at prevas.dk>
---
arch/arm/mach-exynos/include/mach/mipi_dsim.h | 2 +-
arch/arm/mach-rockchip/rk3188/rk3188.c | 2 +-
board/dhelectronics/dh_stm32mp1/board.c | 2 +-
board/firefly/firefly-rk3288/firefly-rk3288.c | 2 +-
board/st/stm32mp1/stm32mp1.c | 2 +-
common/cli.c | 2 +-
include/fdtdec.h | 2 +-
lib/fdtdec.c | 4 ++--
8 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/arch/arm/mach-exynos/include/mach/mipi_dsim.h b/arch/arm/mach-exynos/include/mach/mipi_dsim.h
index 20e6ce7f72..1cdea29b78 100644
--- a/arch/arm/mach-exynos/include/mach/mipi_dsim.h
+++ b/arch/arm/mach-exynos/include/mach/mipi_dsim.h
@@ -313,7 +313,7 @@ struct mipi_dsim_master_ops {
* @platform_data: lcd panel specific platform data.
*/
struct mipi_dsim_lcd_device {
- char *name;
+ const char *name;
int id;
int bus_id;
int reverse_panel;
diff --git a/arch/arm/mach-rockchip/rk3188/rk3188.c b/arch/arm/mach-rockchip/rk3188/rk3188.c
index 222953ab94..1f0adac62a 100644
--- a/arch/arm/mach-rockchip/rk3188/rk3188.c
+++ b/arch/arm/mach-rockchip/rk3188/rk3188.c
@@ -111,7 +111,7 @@ static int setup_led(void)
{
#ifdef CONFIG_SPL_LED
struct udevice *dev;
- char *led_name;
+ const char *led_name;
int ret;
led_name = fdtdec_get_config_string(gd->fdt_blob, "u-boot,boot-led");
diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c
index f42d395098..c59bf26223 100644
--- a/board/dhelectronics/dh_stm32mp1/board.c
+++ b/board/dhelectronics/dh_stm32mp1/board.c
@@ -372,7 +372,7 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
#ifdef CONFIG_LED
static int get_led(struct udevice **dev, char *led_string)
{
- char *led_name;
+ const char *led_name;
int ret;
led_name = fdtdec_get_config_string(gd->fdt_blob, led_string);
diff --git a/board/firefly/firefly-rk3288/firefly-rk3288.c b/board/firefly/firefly-rk3288/firefly-rk3288.c
index bd8a32cf7b..a2bef1c928 100644
--- a/board/firefly/firefly-rk3288/firefly-rk3288.c
+++ b/board/firefly/firefly-rk3288/firefly-rk3288.c
@@ -14,7 +14,7 @@ static int setup_led(void)
{
#ifdef CONFIG_SPL_LED
struct udevice *dev;
- char *led_name;
+ const char *led_name;
int ret;
led_name = fdtdec_get_config_string(gd->fdt_blob, "u-boot,boot-led");
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 03a19af930..82798773f5 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -226,7 +226,7 @@ int g_dnl_bind_fixup(struct usb_device_descriptor *dev, const char *name)
static int get_led(struct udevice **dev, char *led_string)
{
- char *led_name;
+ const char *led_name;
int ret;
led_name = fdtdec_get_config_string(gd->fdt_blob, led_string);
diff --git a/common/cli.c b/common/cli.c
index 6635ab2bcf..f0e8f2880c 100644
--- a/common/cli.c
+++ b/common/cli.c
@@ -156,7 +156,7 @@ int do_run(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
bool cli_process_fdt(const char **cmdp)
{
/* Allow the fdt to override the boot command */
- char *env = fdtdec_get_config_string(gd->fdt_blob, "bootcmd");
+ const char *env = fdtdec_get_config_string(gd->fdt_blob, "bootcmd");
if (env)
*cmdp = env;
/*
diff --git a/include/fdtdec.h b/include/fdtdec.h
index 62d1660973..a037f6ed9c 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -778,7 +778,7 @@ int fdtdec_get_config_bool(const void *blob, const char *prop_name);
* @param prop_name property name to look up
* @returns property string, NULL on error.
*/
-char *fdtdec_get_config_string(const void *blob, const char *prop_name);
+const char *fdtdec_get_config_string(const void *blob, const char *prop_name);
/*
* Look up a property in a node and return its contents in a byte
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index ee1bd41b08..25a71bc8f9 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -879,7 +879,7 @@ int fdtdec_get_config_bool(const void *blob, const char *prop_name)
return prop != NULL;
}
-char *fdtdec_get_config_string(const void *blob, const char *prop_name)
+const char *fdtdec_get_config_string(const void *blob, const char *prop_name)
{
const char *nodep;
int nodeoffset;
@@ -894,7 +894,7 @@ char *fdtdec_get_config_string(const void *blob, const char *prop_name)
if (!nodep)
return NULL;
- return (char *)nodep;
+ return nodep;
}
u64 fdtdec_get_number(const fdt32_t *ptr, unsigned int cells)
--
2.23.0
More information about the U-Boot
mailing list