mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 3/3] efi: efi-iomem: fix erroneous use of IS_ENABLED()
Date: Mon, 15 Nov 2021 10:00:23 +0100	[thread overview]
Message-ID: <20211115090023.4192546-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20211115090023.4192546-1-a.fatoum@pengutronix.de>

IS_ENABLED() is supposed to be used for CONFIG_ macros, which a
local #define DEBUG isn't. Fix by using __is_defined instead.

The reason, we have this as a compile time switch is that the memory
map can be very extensive (> 100 entries) and is usually only
interesting during development.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/efi/efi-iomem.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/common/efi/efi-iomem.c b/common/efi/efi-iomem.c
index 11ea94f6a2a6..4d34328a5802 100644
--- a/common/efi/efi-iomem.c
+++ b/common/efi/efi-iomem.c
@@ -10,7 +10,7 @@
 #include <memory.h>
 #include <linux/sizes.h>
 
-static int efi_parse_mmap(struct efi_memory_desc *desc)
+static int efi_parse_mmap(struct efi_memory_desc *desc, bool verbose)
 {
 	struct resource *res;
 	u32 flags;
@@ -30,7 +30,7 @@ static int efi_parse_mmap(struct efi_memory_desc *desc)
 
 	switch (desc->type) {
 	case EFI_RESERVED_TYPE:
-		if (!IS_ENABLED(DEBUG))
+		if (verbose)
 			return 0;
 		name = "reserved";
 		flags = IORESOURCE_MEM | IORESOURCE_DISABLED;
@@ -44,67 +44,67 @@ static int efi_parse_mmap(struct efi_memory_desc *desc)
 		flags = IORESOURCE_MEM;
 		break;
 	case EFI_BOOT_SERVICES_CODE:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "boot services code";
 		flags = IORESOURCE_MEM | IORESOURCE_READONLY;
 		break;
 	case EFI_BOOT_SERVICES_DATA:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "boot services data";
 		flags = IORESOURCE_MEM;
 		break;
 	case EFI_RUNTIME_SERVICES_CODE:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "runtime services code";
 		flags = IORESOURCE_MEM | IORESOURCE_READONLY;
 		break;
 	case EFI_RUNTIME_SERVICES_DATA:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "runtime services data";
 		flags = IORESOURCE_MEM;
 		break;
 	case EFI_CONVENTIONAL_MEMORY:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "conventional memory";
 		flags = IORESOURCE_MEM | IORESOURCE_PREFETCH | IORESOURCE_CACHEABLE;
 		break;
 	case EFI_UNUSABLE_MEMORY:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "unusable";
 		flags = IORESOURCE_MEM | IORESOURCE_DISABLED;
 		break;
 	case EFI_ACPI_RECLAIM_MEMORY:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "ACPI reclaim memory";
 		flags = IORESOURCE_MEM | IORESOURCE_READONLY;
 		break;
 	case EFI_ACPI_MEMORY_NVS:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "ACPI NVS memory";
 		flags = IORESOURCE_MEM | IORESOURCE_READONLY;
 		break;
 	case EFI_MEMORY_MAPPED_IO:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "MMIO";
 		flags = IORESOURCE_MEM;
 		break;
 	case EFI_MEMORY_MAPPED_IO_PORT_SPACE:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "MMIOPORT";
 		flags = IORESOURCE_IO;
 		break;
 	case EFI_PAL_CODE:
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 		name = "PAL code";
 		flags = IORESOURCE_MEM | IORESOURCE_ROM_BIOS_COPY;
@@ -116,7 +116,7 @@ static int efi_parse_mmap(struct efi_memory_desc *desc)
 			return -EINVAL;
 		}
 
-		if (!IS_ENABLED(DEBUG))
+		if (!verbose)
 			return 0;
 
 		name = "vendor reserved";
@@ -169,8 +169,8 @@ static int efi_barebox_populate_mmap(void)
 		goto out;
 	}
 
-	for (desc = mmap_buf; (u8 *)desc < &mmap_buf[mmap_size]; desc += descsz)
-		efi_parse_mmap(desc);
+	for (desc = mmap_buf; (u8 *)desc < mmap_buf + mmap_size; desc += descsz)
+		efi_parse_mmap(desc, __is_defined(DEBUG));
 
 out:
 	free(mmap_buf);
-- 
2.30.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


  parent reply	other threads:[~2021-11-15  9:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15  9:00 [PATCH master 1/3] pci: efi: skip driver model fixup for non-EFI PCI busses Ahmad Fatoum
2021-11-15  9:00 ` [PATCH master 2/3] efi: efi-iomem: don't add EFI loader code/data as memory banks Ahmad Fatoum
2021-11-15  9:00 ` Ahmad Fatoum [this message]
2021-11-15  9:39 ` [PATCH master 1/3] pci: efi: skip driver model fixup for non-EFI PCI busses Sascha Hauer

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=20211115090023.4192546-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --subject='Re: [PATCH master 3/3] efi: efi-iomem: fix erroneous use of IS_ENABLED()' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox