All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH 08/11] dm: core: Add an ofnode function to get the devicetree root
Date: Sat, 28 Nov 2020 17:50:07 -0700	[thread overview]
Message-ID: <20201128174958.8.I6c692ce05eb01451838b2a517b166bd4dd76aec0@changeid> (raw)
In-Reply-To: <20201129005011.2104545-1-sjg@chromium.org>

This is needed in at least one place. Avoid the conditional code in root.c
by adding this inline function.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/core/root.c |  8 ++------
 include/dm/ofnode.h | 12 ++++++++++++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/drivers/core/root.c b/drivers/core/root.c
index 5f10d7a39c7..9ee65504e6e 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -147,12 +147,8 @@ int dm_init(bool of_live)
 	ret = device_bind_by_name(NULL, false, &root_info, &DM_ROOT_NON_CONST);
 	if (ret)
 		return ret;
-#if CONFIG_IS_ENABLED(OF_CONTROL)
-	if (CONFIG_IS_ENABLED(OF_LIVE) && of_live)
-		DM_ROOT_NON_CONST->node = np_to_ofnode(gd_of_root());
-	else
-		DM_ROOT_NON_CONST->node = offset_to_ofnode(0);
-#endif
+	if (CONFIG_IS_ENABLED(OF_CONTROL))
+		DM_ROOT_NON_CONST->node = ofnode_root();
 	ret = device_probe(DM_ROOT_NON_CONST);
 	if (ret)
 		return ret;
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index ee8c44a71ec..53f04ac91d0 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -218,6 +218,18 @@ static inline ofnode ofnode_null(void)
 	return node;
 }
 
+static inline ofnode ofnode_root(void)
+{
+	ofnode node;
+
+	if (of_live_active())
+		node.np = gd_of_root();
+	else
+		node.of_offset = 0;
+
+	return node;
+}
+
 /**
  * ofnode_read_u32() - Read a 32-bit integer from a property
  *
-- 
2.29.2.454.gaff20da3a2-goog

  parent reply	other threads:[~2020-11-29  0:50 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-29  0:49 [PATCH 00/11] dm: Simplify livetree handling Simon Glass
2020-11-29  0:50 ` [PATCH 01/11] dm: core: Rename device_bind() to device_bind_offset() Simon Glass
2020-11-29  0:50 ` [PATCH 02/11] dm: core: Rename device_bind_ofnode() to device_bind() Simon Glass
2020-11-29  0:50 ` [PATCH 03/11] dm: core: Add a livetree function to check node status Simon Glass
2020-11-29  0:50 ` [PATCH 04/11] dm: Remove uses of device_bind_offset() Simon Glass
2020-11-29  0:50 ` [PATCH 05/11] dm: Drop uses of dev_set_of_offset() Simon Glass
2020-11-29  0:50 ` [PATCH 06/11] dm: core: Drop dev_set_of_offset() Simon Glass
2020-11-29  0:50 ` [PATCH 07/11] dm: core: Drop device_bind_offset() Simon Glass
2020-11-29  0:50 ` Simon Glass [this message]
2020-11-29  0:50 ` [PATCH 09/11] dm: core: Combine the flattree and livetree binding code Simon Glass
2020-11-29  0:50 ` [PATCH 10/11] dm: core: Drop unused parameter from dm_scan_fdt() Simon Glass
2020-11-29  0:50 ` [PATCH 11/11] dm: core: Drop unused parameter from dm_extended_scan_fdt() Simon Glass
2020-12-10  0:26 ` Simon Glass
2020-12-10  0:26 ` [PATCH 10/11] dm: core: Drop unused parameter from dm_scan_fdt() Simon Glass
2020-12-10  0:26 ` [PATCH 09/11] dm: core: Combine the flattree and livetree binding code Simon Glass
2020-12-10  0:26 ` [PATCH 08/11] dm: core: Add an ofnode function to get the devicetree root Simon Glass
2020-12-10  0:26 ` [PATCH 07/11] dm: core: Drop device_bind_offset() Simon Glass
2020-12-10  0:26 ` [PATCH 06/11] dm: core: Drop dev_set_of_offset() Simon Glass
2020-12-10  0:26 ` [PATCH 05/11] dm: Drop uses of dev_set_of_offset() Simon Glass
2020-12-10  0:26   ` Simon Glass
2020-12-10  0:26 ` [PATCH 04/11] dm: Remove uses of device_bind_offset() Simon Glass
2020-12-10  0:26   ` Simon Glass
2021-01-31  9:18   ` Eugen.Hristev at microchip.com
2021-01-31  9:18     ` Eugen.Hristev
2021-01-31 15:37     ` Simon Glass
2021-01-31 15:37       ` Simon Glass
2021-02-01  8:13       ` Eugen.Hristev at microchip.com
2021-02-01  8:13         ` Eugen.Hristev
2021-02-01 12:02         ` Simon Glass
2021-02-01 12:02           ` Simon Glass
2021-02-01 12:14           ` Eugen.Hristev at microchip.com
2020-12-10  0:26 ` [PATCH 03/11] dm: core: Add a livetree function to check node status Simon Glass
2020-12-10  0:26 ` [PATCH 02/11] dm: core: Rename device_bind_ofnode() to device_bind() Simon Glass
2020-12-10  0:26 ` [PATCH 01/11] dm: core: Rename device_bind() to device_bind_offset() Simon Glass
2020-12-10  0:26   ` 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=20201128174958.8.I6c692ce05eb01451838b2a517b166bd4dd76aec0@changeid \
    --to=sjg@chromium.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.