summaryrefslogtreecommitdiffstats
path: root/board/st/stm32mp1/stm32mp1.c
diff options
context:
space:
mode:
authorPatrick Delaunay <patrick.delaunay@st.com>2020-07-31 16:31:48 +0200
committerPatrice Chotard <patrice.chotard@st.com>2020-08-13 09:52:49 +0200
commit72b099897a61ce87cf95c88344690e1b8bf92142 (patch)
tree1e0a2368daf5e3174dbb0d41b045fece1322ae30 /board/st/stm32mp1/stm32mp1.c
parente817c8eca5a25762f44adf3871bae13af39215d4 (diff)
downloadu-boot-72b099897a61ce87cf95c88344690e1b8bf92142.tar.gz
u-boot-72b099897a61ce87cf95c88344690e1b8bf92142.tar.xz
u-boot-72b099897a61ce87cf95c88344690e1b8bf92142.zip
board: stm32mp1: use IS_ENABLED to prevent ifdef in board_late_init
Use IS_ENABLED to prevent ifdef in board_late_init. Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com> Reviewed-by: Patrice Chotard <patrice.chotard@st.com>
Diffstat (limited to 'board/st/stm32mp1/stm32mp1.c')
-rw-r--r--board/st/stm32mp1/stm32mp1.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
index 985233f2b3..a9705baa24 100644
--- a/board/st/stm32mp1/stm32mp1.c
+++ b/board/st/stm32mp1/stm32mp1.c
@@ -654,47 +654,47 @@ int board_init(void)
int board_late_init(void)
{
-#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
const void *fdt_compat;
int fdt_compat_len;
int ret;
u32 otp;
struct udevice *dev;
char buf[10];
+ char dtb_name[256];
+ int buf_len;
+
+ if (IS_ENABLED(CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG)) {
+ fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
+ &fdt_compat_len);
+ if (fdt_compat && fdt_compat_len) {
+ if (strncmp(fdt_compat, "st,", 3) != 0) {
+ env_set("board_name", fdt_compat);
+ } else {
+ env_set("board_name", fdt_compat + 3);
- fdt_compat = fdt_getprop(gd->fdt_blob, 0, "compatible",
- &fdt_compat_len);
- if (fdt_compat && fdt_compat_len) {
- if (strncmp(fdt_compat, "st,", 3) != 0) {
- env_set("board_name", fdt_compat);
- } else {
- char dtb_name[256];
- int buf_len = sizeof(dtb_name);
+ buf_len = sizeof(dtb_name);
+ strncpy(dtb_name, fdt_compat + 3, buf_len);
+ buf_len -= strlen(fdt_compat + 3);
+ strncat(dtb_name, ".dtb", buf_len);
+ env_set("fdtfile", dtb_name);
+ }
+ }
+ ret = uclass_get_device_by_driver(UCLASS_MISC,
+ DM_GET_DRIVER(stm32mp_bsec),
+ &dev);
- env_set("board_name", fdt_compat + 3);
+ if (!ret)
+ ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
+ &otp, sizeof(otp));
+ if (ret > 0 && otp) {
+ snprintf(buf, sizeof(buf), "0x%04x", otp >> 16);
+ env_set("board_id", buf);
- strncpy(dtb_name, fdt_compat + 3, buf_len);
- buf_len -= strlen(fdt_compat + 3);
- strncat(dtb_name, ".dtb", buf_len);
- env_set("fdtfile", dtb_name);
+ snprintf(buf, sizeof(buf), "0x%04x",
+ ((otp >> 8) & 0xF) - 1 + 0xA);
+ env_set("board_rev", buf);
}
}
- ret = uclass_get_device_by_driver(UCLASS_MISC,
- DM_GET_DRIVER(stm32mp_bsec),
- &dev);
-
- if (!ret)
- ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD),
- &otp, sizeof(otp));
- if (ret > 0 && otp) {
- snprintf(buf, sizeof(buf), "0x%04x", otp >> 16);
- env_set("board_id", buf);
-
- snprintf(buf, sizeof(buf), "0x%04x",
- ((otp >> 8) & 0xF) - 1 + 0xA);
- env_set("board_rev", buf);
- }
-#endif
/* for DK1/DK2 boards */
board_check_usb_power();