public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: edk2-devel@lists.01.org
Cc: leif.lindholm@linaro.org, lersek@redhat.com, philmd@redhat.com,
	hongbo.zhang@linaro.org, nariman.poushin@linaro.org,
	thomas.abraham@arm.com,
	Ard Biesheuvel <ard.biesheuvel@linaro.org>
Subject: [PATCH v2 3/5] ArmVirtPkg/FdtClientDxe: take DT node 'status' properties into account
Date: Wed, 21 Nov 2018 12:58:26 +0100	[thread overview]
Message-ID: <20181121115828.3026-4-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <20181121115828.3026-1-ard.biesheuvel@linaro.org>

DT has a [pseudo-]standardized 'status' property that can be set on
any node, and which signifies that a node should be treated as
absent unless it is set to 'ok' or 'okay'. So take this into account
when iterating over nodes.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmVirtPkg/FdtClientDxe/FdtClientDxe.c | 38 +++++++++++++++++---
 1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c
index fb6e0aeb9215..5bfde381ecd0 100644
--- a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c
+++ b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c
@@ -78,6 +78,33 @@ SetNodeProperty (
   return EFI_SUCCESS;
 }
 
+STATIC
+BOOLEAN
+IsNodeEnabled (
+  INT32                       Node
+  )
+{
+  CONST CHAR8   *NodeStatus;
+  INT32         Len;
+
+  //
+  // A missing status property implies 'ok' so ignore any errors that
+  // may occur here. If the status property is present, check whether
+  // it is set to 'ok' or 'okay', anything else is treated as 'disabled'.
+  //
+  NodeStatus = fdt_getprop (mDeviceTreeBase, Node, "status", &Len);
+  if (NodeStatus == NULL) {
+    return TRUE;
+  }
+  if (Len >= 5 && AsciiStrCmp (NodeStatus, "okay") == 0) {
+    return TRUE;
+  }
+  if (Len >= 3 && AsciiStrCmp (NodeStatus, "ok") == 0) {
+    return TRUE;
+  }
+  return FALSE;
+}
+
 STATIC
 EFI_STATUS
 EFIAPI
@@ -101,6 +128,10 @@ FindNextCompatibleNode (
       break;
     }
 
+    if (!IsNodeEnabled (Next)) {
+      continue;
+    }
+
     Type = fdt_getprop (mDeviceTreeBase, Next, "compatible", &Len);
     if (Type == NULL) {
       continue;
@@ -210,7 +241,6 @@ FindNextMemoryNodeReg (
 {
   INT32          Prev, Next;
   CONST CHAR8    *DeviceType;
-  CONST CHAR8    *NodeStatus;
   INT32          Len;
   EFI_STATUS     Status;
 
@@ -223,10 +253,8 @@ FindNextMemoryNodeReg (
       break;
     }
 
-    NodeStatus = fdt_getprop (mDeviceTreeBase, Next, "status", &Len);
-    if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) {
-      DEBUG ((DEBUG_WARN, "%a: ignoring memory node with status \"%a\"\n",
-        __FUNCTION__, NodeStatus));
+    if (!IsNodeEnabled (Next)) {
+      DEBUG ((DEBUG_WARN, "%a: ignoring disabled memory node\n", __FUNCTION__));
       continue;
     }
 
-- 
2.17.1



  parent reply	other threads:[~2018-11-21 11:58 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-21 11:58 [PATCH v2 0/5] ArmPlatformPkg, ArmVirtPkg: discover NOR flash banks from DTB Ard Biesheuvel
2018-11-21 11:58 ` [PATCH v2 1/5] ArmPlatformPkg/NorFlashDxe: prepare for devicepath format change Ard Biesheuvel
2018-11-21 17:01   ` Laszlo Ersek
2018-11-22 15:54   ` Philippe Mathieu-Daudé
2018-11-21 11:58 ` [PATCH v2 2/5] ArmPlatformPkg/NorFlashDxe: use one GUID plus index to identify flash banks Ard Biesheuvel
2018-11-21 17:03   ` Laszlo Ersek
2018-11-22 15:36   ` Philippe Mathieu-Daudé
2018-11-21 11:58 ` Ard Biesheuvel [this message]
2018-11-21 17:12   ` [PATCH v2 3/5] ArmVirtPkg/FdtClientDxe: take DT node 'status' properties into account Laszlo Ersek
2018-11-22 13:12     ` Ard Biesheuvel
2018-11-22 15:38   ` Philippe Mathieu-Daudé
2018-11-21 11:58 ` [PATCH v2 4/5] ArmVirtPkg/NorFlashQemuLib: discover NOR flash banks dynamically Ard Biesheuvel
2018-11-21 17:18   ` Laszlo Ersek
2018-11-21 11:58 ` [PATCH v2 5/5] ArmPlatformPkg/NorFlashPlatformLib: remove unused Guid member from struct Ard Biesheuvel
2018-11-21 17:22   ` Laszlo Ersek
2018-11-26 17:00 ` [PATCH v2 0/5] ArmPlatformPkg, ArmVirtPkg: discover NOR flash banks from DTB Ard Biesheuvel
2018-11-26 17:02   ` Ard Biesheuvel
2018-11-27 12:07     ` Ard Biesheuvel

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-list 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=20181121115828.3026-4-ard.biesheuvel@linaro.org \
    --to=devel@edk2.groups.io \
    /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