dm: ofnode: simplify ofnode_read_bool()
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 22 Jun 2017 07:54:07 +0000 (16:54 +0900)
committerSimon Glass <sjg@chromium.org>
Tue, 11 Jul 2017 16:08:20 +0000 (10:08 -0600)
Reuse ofnode_get_property() to simplify the implementation.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Simon Glass <sjg@chromium.org>
drivers/core/ofnode.c

index 372d07a0c9395dd78a18956bba9cdb226cbdadaa..be6447daa17b85fb4220e2e1e6c6998158c868d1 100644 (file)
@@ -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)