diff mbox series

[5/5] dm: ofnode: simplify ofnode_read_bool()

Message ID 1498118047-11918-5-git-send-email-yamada.masahiro@socionext.com
State Accepted
Commit b2ec7ea731a1300fc3b888d9efa870fb4dafda79
Headers show
Series [1/5] dm: ofnode: use ofnode_read_bool() to check property existence | expand

Commit Message

Masahiro Yamada June 22, 2017, 7:54 a.m. UTC
Reuse ofnode_get_property() to simplify the implementation.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 drivers/core/ofnode.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

Comments

Simon Glass July 6, 2017, 4:49 a.m. UTC | #1
On 22 June 2017 at 01:54, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> Reuse ofnode_get_property() to simplify the implementation.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  drivers/core/ofnode.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>
Simon Glass July 6, 2017, 5:36 p.m. UTC | #2
On 22 June 2017 at 01:54, Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> Reuse ofnode_get_property() to simplify the implementation.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
>  drivers/core/ofnode.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)

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

Applied to u-boot-dm, thanks!
diff mbox series

Patch

diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c
index 87e731dc2b77..5a3e1d452fbb 100644
--- a/drivers/core/ofnode.c
+++ b/drivers/core/ofnode.c
@@ -57,20 +57,16 @@  int ofnode_read_s32_default(ofnode node, const char *propname, s32 def)
 
 bool ofnode_read_bool(ofnode node, const char *propname)
 {
-	bool val;
+	const void *prop;
 
 	assert(ofnode_valid(node));
 	debug("%s: %s: ", __func__, propname);
 
-	if (ofnode_is_np(node)) {
-		val = !!of_find_property(ofnode_to_np(node), propname, NULL);
-	} else {
-		val = !!fdt_getprop(gd->fdt_blob, ofnode_to_offset(node),
-				    propname, NULL);
-	}
-	debug("%s\n", val ? "true" : "false");
+	prop = ofnode_get_property(node, propname, NULL);
+
+	debug("%s\n", prop ? "true" : "false");
 
-	return val;
+	return prop ? true : false;
 }
 
 const char *ofnode_read_string(ofnode node, const char *propname)