public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Kory Maincent <kory.maincent@bootlin.com>
To: u-boot@lists.denx.de
Subject: [PATCH v5 2/3] pxe_utils: clean-up, replace ifdef by IS_ENABLED
Date: Tue,  2 Feb 2021 16:42:28 +0100	[thread overview]
Message-ID: <20210202154229.26103-2-kory.maincent@bootlin.com> (raw)
In-Reply-To: <20210202154229.26103-1-kory.maincent@bootlin.com>

Replace all the macro ifdef by IS_ENABLED.
All of these configs are set in the defconfig files and not in the
include board headers files.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
---

Change since v4:
- Use 'if (IS_ENABLED(CONFIG...))' instead of '#if or #ifdef' where possible

 cmd/pxe_utils.c | 52 ++++++++++++++++++++++++-------------------------
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index 3526a651d7..e062c9edcf 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -340,7 +340,7 @@ static int label_localboot(struct pxe_label *label)
 /*
  * Loads fdt overlays specified in 'fdtoverlays'.
  */
-#ifdef CONFIG_OF_LIBFDT_OVERLAY
+#if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY))
 static void label_boot_fdtoverlay(struct cmd_tbl *cmdtp, struct pxe_label *label)
 {
 	char *fdtoverlay = label->fdtoverlays;
@@ -492,16 +492,16 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
 			env_get("gatewayip"), env_get("netmask"));
 	}
 
-#ifdef CONFIG_CMD_NET
-	if (label->ipappend & 0x2) {
-		int err;
+	if (IS_ENABLED(CONFIG_CMD_NET))	{
+		if (label->ipappend & 0x2) {
+			int err;
 
-		strcpy(mac_str, " BOOTIF=");
-		err = format_mac_pxe(mac_str + 8, sizeof(mac_str) - 8);
-		if (err < 0)
-			mac_str[0] = '\0';
+			strcpy(mac_str, " BOOTIF=");
+			err = format_mac_pxe(mac_str + 8, sizeof(mac_str) - 8);
+			if (err < 0)
+				mac_str[0] = '\0';
+		}
 	}
-#endif
 
 	if ((label->ipappend & 0x3) || label->append) {
 		char bootargs[CONFIG_SYS_CBSIZE] = "";
@@ -626,7 +626,7 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
 				}
 			}
 
-#ifdef CONFIG_OF_LIBFDT_OVERLAY
+#if IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY)
 			if (label->fdtoverlays)
 				label_boot_fdtoverlay(cmdtp, label);
 #endif
@@ -649,15 +649,13 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label)
 	/* Try bootm for legacy and FIT format image */
 	if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID)
 		do_bootm(cmdtp, 0, bootm_argc, bootm_argv);
-#ifdef CONFIG_CMD_BOOTI
 	/* Try booting an AArch64 Linux kernel image */
-	else
+	else if (IS_ENABLED(CONFIG_CMD_BOOTI))
 		do_booti(cmdtp, 0, bootm_argc, bootm_argv);
-#elif defined(CONFIG_CMD_BOOTZ)
 	/* Try booting a Image */
-	else
+	else if (IS_ENABLED(CONFIG_CMD_BOOTZ))
 		do_bootz(cmdtp, 0, bootm_argc, bootm_argv);
-#endif
+
 	unmap_sysmem(buf);
 
 cleanup:
@@ -1424,20 +1422,20 @@ void handle_pxe_menu(struct cmd_tbl *cmdtp, struct pxe_menu *cfg)
 	struct menu *m;
 	int err;
 
-#ifdef CONFIG_CMD_BMP
-	/* display BMP if available */
-	if (cfg->bmp) {
-		if (get_relfile(cmdtp, cfg->bmp, image_load_addr)) {
-			if (CONFIG_IS_ENABLED(CMD_CLS))
-				run_command("cls", 0);
-			bmp_display(image_load_addr,
-				    BMP_ALIGN_CENTER, BMP_ALIGN_CENTER);
-		} else {
-			printf("Skipping background bmp %s for failure\n",
-			       cfg->bmp);
+	if (IS_ENABLED(CONFIG_CMD_BMP)) {
+		/* display BMP if available */
+		if (cfg->bmp) {
+			if (get_relfile(cmdtp, cfg->bmp, image_load_addr)) {
+				if (CONFIG_IS_ENABLED(CMD_CLS))
+					run_command("cls", 0);
+				bmp_display(image_load_addr,
+					    BMP_ALIGN_CENTER, BMP_ALIGN_CENTER);
+			} else {
+				printf("Skipping background bmp %s for failure\n",
+				       cfg->bmp);
+			}
 		}
 	}
-#endif
 
 	m = pxe_menu_to_menu(cfg);
 	if (!m)
-- 
2.17.1

  reply	other threads:[~2021-02-02 15:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-02 15:42 [PATCH v5 1/3] command.h: Clean-up patch, remove extern from the header Kory Maincent
2021-02-02 15:42 ` Kory Maincent [this message]
2021-02-03  6:28   ` [PATCH v5 2/3] pxe_utils: clean-up, replace ifdef by IS_ENABLED Bin Meng
2021-02-03 12:59   ` Simon Glass
2021-02-03 13:37     ` Bin Meng
2021-02-02 15:42 ` [PATCH v5 3/3] sysboot: add zboot support to boot x86 Linux kernel image Kory Maincent
2021-02-03  6:28   ` Bin Meng
2021-02-03  6:28 ` [PATCH v5 1/3] command.h: Clean-up patch, remove extern from the header Bin Meng
2021-02-03 12:59 ` Simon Glass

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=20210202154229.26103-2-kory.maincent@bootlin.com \
    --to=kory.maincent@bootlin.com \
    --cc=u-boot@lists.denx.de \
    /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