From: Vikas Manocha Date: Mon, 5 Feb 2018 08:24:02 -0800 Subject: [U-Boot] [PATCH v2 1/3] mach-stm32: Add set_env_soc_name support In-Reply-To: <1517826807-30899-2-git-send-email-patrice.chotard@st.com> References: <1517826807-30899-1-git-send-email-patrice.chotard@st.com> <1517826807-30899-2-git-send-email-patrice.chotard@st.com> Message-ID: <6d3acad9-6bb3-bc80-7287-75ac88ca53bd@st.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi, On 02/05/2018 02:33 AM, patrice.chotard at st.com wrote: > From: Patrice Chotard > > This allows to create and set the environment variable > "soc_name" which contains the current STM32 SoC's name. > > Signed-off-by: Christophe Priouzeau > Signed-off-by: Patrice Chotard For the series, Reviewed-by: Vikas Manocha One point below, [...] > + > #endif /* _ASM_ARCH_HARDWARE_H */ > diff --git a/arch/arm/mach-stm32/soc.c b/arch/arm/mach-stm32/soc.c > index df20d547c500..06ca61b270cf 100644 > --- a/arch/arm/mach-stm32/soc.c > +++ b/arch/arm/mach-stm32/soc.c > @@ -8,6 +8,7 @@ > #include > #include > #include > +#include > > int arch_cpu_init(void) > { > @@ -54,3 +55,17 @@ int arch_cpu_init(void) > > return 0; > } > + > +void set_env_soc_name(void) > +{ > + char soc[16]; > + > +#ifdef CONFIG_STM32F4 > + snprintf(soc, sizeof(soc), "stm32f4"); > +#elif CONFIG_STM32F7 > + snprintf(soc, sizeof(soc), "stm32f7"); > +#elif CONFIG_STM32H7 > + snprintf(soc, sizeof(soc), "stm32h7"); > +#endif Can we move these conditional checks in the background like in some header file inline function & use it like get_soc_name(); Cheers, Vikas > + env_set("soc_name", soc); > +} >