Re: [PATCH u-boot-marvell v2 8/9] arm: mvebu: spl: Use IS_ENABLED() instead of #ifdef where possible

Stefan Roese
2021-11-30T06:22:18Z

On 11/26/21 15:37, Marek Behún wrote:
> From: Marek Behún <marek.behun@nic.cz>
>
> Use the preferred
> if (IS_ENABLED(X))
> instead of
> #ifdef X
> where possible.
>
> There are still places where this is not possible or is more complicated
> to convert in this file. Leave those be for now.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>

Nice, thanks.

Reviewed-by: Stefan Roese <sr@denx.de>

Thanks,
Stefan

> ---
> arch/arm/mach-mvebu/spl.c | 43 ++++++++++++++++-----------------------
> 1 file changed, 18 insertions(+), 25 deletions(-)
>
> diff --git a/arch/arm/mach-mvebu/spl.c b/arch/arm/mach-mvebu/spl.c
> index 97d7aea179..7dbe8eeba3 100644
> --- a/arch/arm/mach-mvebu/spl.c
> +++ b/arch/arm/mach-mvebu/spl.c
> @@ -150,26 +150,24 @@ int spl_parse_board_header(struct spl_image_info *spl_image,
> return -EINVAL;
> }
>
> -#ifdef CONFIG_SPL_SPI_FLASH_SUPPORT
> - if (bootdev->boot_device == BOOT_DEVICE_SPI &&
> + if (IS_ENABLED(CONFIG_SPL_SPI_FLASH_SUPPORT) &&
> + bootdev->boot_device == BOOT_DEVICE_SPI &&
> mhdr->blockid != IBR_HDR_SPI_ID) {
> printf("ERROR: Wrong blockid (%u) in SPI kwbimage\n",
> mhdr->blockid);
> return -EINVAL;
> }
> -#endif
>
> -#ifdef CONFIG_SPL_SATA
> - if (bootdev->boot_device == BOOT_DEVICE_SATA &&
> + if (IS_ENABLED(CONFIG_SPL_SATA) &&
> + bootdev->boot_device == BOOT_DEVICE_SATA &&
> mhdr->blockid != IBR_HDR_SATA_ID) {
> printf("ERROR: Wrong blockid (%u) in SATA kwbimage\n",
> mhdr->blockid);
> return -EINVAL;
> }
> -#endif
>
> -#ifdef CONFIG_SPL_MMC
> - if ((bootdev->boot_device == BOOT_DEVICE_MMC1 ||
> + if (IS_ENABLED(CONFIG_SPL_MMC) &&
> + (bootdev->boot_device == BOOT_DEVICE_MMC1 ||
> bootdev->boot_device == BOOT_DEVICE_MMC2 ||
> bootdev->boot_device == BOOT_DEVICE_MMC2_2) &&
> mhdr->blockid != IBR_HDR_SDIO_ID) {
> @@ -177,18 +175,16 @@ int spl_parse_board_header(struct spl_image_info *spl_image,
> mhdr->blockid);
> return -EINVAL;
> }
> -#endif
>
> spl_image->offset = mhdr->srcaddr;
>
> -#ifdef CONFIG_SPL_SATA
> /*
> * For SATA srcaddr is specified in number of sectors.
> * The main header is must be stored at sector number 1.
> * This expects that sector size is 512 bytes and recalculates
> * data offset to bytes relative to the main header.
> */
> - if (mhdr->blockid == IBR_HDR_SATA_ID) {
> + if (IS_ENABLED(CONFIG_SPL_SATA) && mhdr->blockid == IBR_HDR_SATA_ID) {
> if (spl_image->offset < 1) {
> printf("ERROR: Wrong SATA srcaddr (%u) in kwbimage\n",
> spl_image->offset);
> @@ -197,17 +193,14 @@ int spl_parse_board_header(struct spl_image_info *spl_image,
> spl_image->offset -= 1;
> spl_image->offset *= 512;
> }
> -#endif
>
> -#ifdef CONFIG_SPL_MMC
> /*
> * For SDIO (eMMC) srcaddr is specified in number of sectors.
> * This expects that sector size is 512 bytes and recalculates
> * data offset to bytes.
> */
> - if (mhdr->blockid == IBR_HDR_SDIO_ID)
> + if (IS_ENABLED(CONFIG_SPL_MMC) && mhdr->blockid == IBR_HDR_SDIO_ID)
> spl_image->offset *= 512;
> -#endif
>
> if (spl_image->offset % 4 != 0) {
> printf("ERROR: Wrong srcaddr (%u) in kwbimage\n",
> @@ -340,17 +333,17 @@ void board_init_f(ulong dummy)
> timer_init();
>
> /* Armada 375 does not support SerDes and DDR3 init yet */
> -#if !defined(CONFIG_ARMADA_375)
> - /* First init the serdes PHY's */
> - serdes_phy_config();
> -
> - /* Setup DDR */
> - ret = ddr3_init();
> - if (ret) {
> - debug("ddr3_init() failed: %d\n", ret);
> - hang();
> + if (!IS_ENABLED(CONFIG_ARMADA_375)) {
> + /* First init the serdes PHY's */
> + serdes_phy_config();
> +
> + /* Setup DDR */
> + ret = ddr3_init();
> + if (ret) {
> + debug("ddr3_init() failed: %d\n", ret);
> + hang();
> + }
> }
> -#endif
>
> /* Initialize Auto Voltage Scaling */
> mv_avs_init();
>

Viele Grüße,
Stefan Roese

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de