From: Patrice CHOTARD <patrice.chotard@foss.st.com>
To: Patrick Delaunay <patrick.delaunay@foss.st.com>, <u-boot@lists.denx.de>
Cc: Alexandru Gagniuc <mr.nuke.me@gmail.com>,
Marek Vasut <marex@denx.de>,
<uboot-stm32@st-md-mailman.stormreply.com>
Subject: Re: [PATCH 4/4] stm32mp15: tidy up #ifdefs in cpu.c
Date: Mon, 22 Nov 2021 09:45:26 +0100 [thread overview]
Message-ID: <7812bed6-a215-ea6d-ebd9-093f5f5dc261@foss.st.com> (raw)
In-Reply-To: <20211011075244.4.Id047d97a30c68f46ac2bcb57014faa42067dd1ba@changeid>
Hi Patrick
On 10/11/21 9:52 AM, Patrick Delaunay wrote:
> We should avoid #ifdef in C modules and the unused functions
> are eliminated by the linker.
>
> Use the more readable IS_ENABLE() instead.
>
> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
> ---
>
> arch/arm/mach-stm32mp/cpu.c | 34 +++++++++++++++-------------------
> 1 file changed, 15 insertions(+), 19 deletions(-)
>
> diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
> index 7421ea42a1..325d710100 100644
> --- a/arch/arm/mach-stm32mp/cpu.c
> +++ b/arch/arm/mach-stm32mp/cpu.c
> @@ -93,7 +93,6 @@ u8 early_tlb[PGTABLE_SIZE] __section(".data") __aligned(0x4000);
>
> struct lmb lmb;
>
> -#if defined(CONFIG_SPL_BUILD)
> static void security_init(void)
> {
> /* Disable the backup domain write protection */
> @@ -208,7 +207,6 @@ static void update_bootmode(void)
> TAMP_BOOT_MODE_MASK,
> boot_mode << TAMP_BOOT_MODE_SHIFT);
> }
> -#endif /* defined(CONFIG_SPL_BUILD) */
>
> u32 get_bootmode(void)
> {
> @@ -286,28 +284,26 @@ int arch_cpu_init(void)
> /* early armv7 timer init: needed for polling */
> timer_init();
>
> -#if defined(CONFIG_SPL_BUILD)
> - security_init();
> - update_bootmode();
> -#endif
> + if (IS_ENABLED(CONFIG_SPL_BUILD)) {
> + security_init();
> + update_bootmode();
> + }
> /* reset copro state in SPL, when used, or in U-Boot */
> -#if !defined(CONFIG_SPL) || defined(CONFIG_SPL_BUILD)
> - /* Reset Coprocessor state unless it wakes up from Standby power mode */
> - if (!(readl(PWR_MCUCR) & PWR_MCUCR_SBF)) {
> - writel(TAMP_COPRO_STATE_OFF, TAMP_COPRO_STATE);
> - writel(0, TAMP_COPRO_RSC_TBL_ADDRESS);
> + if (!IS_ENABLED(CONFIG_SPL) || IS_ENABLED(CONFIG_SPL_BUILD)) {
> + /* Reset Coprocessor state unless it wakes up from Standby power mode */
> + if (!(readl(PWR_MCUCR) & PWR_MCUCR_SBF)) {
> + writel(TAMP_COPRO_STATE_OFF, TAMP_COPRO_STATE);
> + writel(0, TAMP_COPRO_RSC_TBL_ADDRESS);
> + }
> }
> -#endif
>
> boot_mode = get_bootmode();
>
> if (IS_ENABLED(CONFIG_CMD_STM32PROG_SERIAL) &&
> (boot_mode & TAMP_BOOT_DEVICE_MASK) == BOOT_SERIAL_UART)
> gd->flags |= GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE;
> -#if defined(CONFIG_DEBUG_UART) && defined(CONFIG_SPL_BUILD)
> - else
> + else if (IS_ENABLED(CONFIG_DEBUG_UART) && IS_ENABLED(CONFIG_SPL_BUILD))
> debug_uart_init();
> -#endif
>
> return 0;
> }
> @@ -461,7 +457,7 @@ void get_soc_name(char name[SOC_NAME_SIZE])
> soc_type[type], soc_pkg[pkg], soc_rev[rev]);
> }
>
> -#if defined(CONFIG_DISPLAY_CPUINFO)
> +/* used when CONFIG_DISPLAY_CPUINFO is activated */
> int print_cpuinfo(void)
> {
> char name[SOC_NAME_SIZE];
> @@ -471,7 +467,6 @@ int print_cpuinfo(void)
>
> return 0;
> }
> -#endif /* CONFIG_DISPLAY_CPUINFO */
>
> static void setup_boot_mode(void)
> {
> @@ -601,13 +596,15 @@ static void setup_boot_mode(void)
> */
> __weak int setup_mac_address(void)
> {
> -#if defined(CONFIG_NET)
> int ret;
> int i;
> u32 otp[2];
> uchar enetaddr[6];
> struct udevice *dev;
>
> + if (!IS_ENABLED(CONFIG_NET))
> + return 0;
> +
> /* MAC already in environment */
> if (eth_env_get_enetaddr("ethaddr", enetaddr))
> return 0;
> @@ -634,7 +631,6 @@ __weak int setup_mac_address(void)
> ret = eth_env_set_enetaddr("ethaddr", enetaddr);
> if (ret)
> log_err("Failed to set mac address %pM from OTP: %d\n", enetaddr, ret);
> -#endif
>
> return 0;
> }
>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
Thanks
Patrice
next prev parent reply other threads:[~2021-11-22 8:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-11 7:52 [PATCH 1/4] arm: stm32mp: bsec: Update OTP shadow registers in SPL Patrick Delaunay
2021-10-11 7:52 ` [PATCH 2/4] stm32mp15: remove configs dependency on CONFIG_TFABOOT Patrick Delaunay
2021-11-22 8:09 ` Patrice CHOTARD
2021-11-22 9:32 ` Ilias Apalodimas
2021-10-11 7:52 ` [PATCH 3/4] stm32mp15: replace CONFIG_TFABOOT when it is possible Patrick Delaunay
2021-11-22 8:42 ` Patrice CHOTARD
2021-10-11 7:52 ` [PATCH 4/4] stm32mp15: tidy up #ifdefs in cpu.c Patrick Delaunay
2021-11-22 8:45 ` Patrice CHOTARD [this message]
2021-11-22 7:58 ` [PATCH 1/4] arm: stm32mp: bsec: Update OTP shadow registers in SPL Patrice CHOTARD
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7812bed6-a215-ea6d-ebd9-093f5f5dc261@foss.st.com \
--to=patrice.chotard@foss.st.com \
--cc=marex@denx.de \
--cc=mr.nuke.me@gmail.com \
--cc=patrick.delaunay@foss.st.com \
--cc=u-boot@lists.denx.de \
--cc=uboot-stm32@st-md-mailman.stormreply.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).