All of lore.kernel.org
 help / color / mirror / Atom feed
From: robh@kernel.org (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] of/fdt: add of_fdt_device_is_available function
Date: Tue,  3 Oct 2017 11:18:14 -0500	[thread overview]
Message-ID: <20171003161815.25999-1-robh@kernel.org> (raw)

Add an equivalent function to of_device_is_available for flattened DT, and
convert the one existing open coded occurrence.

Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/of/fdt.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 27c535af0be8..f8c39705418b 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -132,6 +132,19 @@ bool of_fdt_is_big_endian(const void *blob, unsigned long node)
 	return false;
 }
 
+static bool of_fdt_device_is_available(const void *blob, unsigned long node)
+{
+	const char *status = fdt_getprop(blob, node, "status", NULL);
+
+	if (!status)
+		return true;
+
+	if (!strcmp(status, "ok") || !strcmp(status, "okay"))
+		return true;
+
+	return false;
+}
+
 /**
  * of_fdt_match - Return true if node matches a list of compatible values
  */
@@ -605,7 +618,6 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname,
 					  int depth, void *data)
 {
 	static int found;
-	const char *status;
 	int err;
 
 	if (!found && depth == 1 && strcmp(uname, "reserved-memory") == 0) {
@@ -625,8 +637,7 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname,
 		return 1;
 	}
 
-	status = of_get_flat_dt_prop(node, "status", NULL);
-	if (status && strcmp(status, "okay") != 0 && strcmp(status, "ok") != 0)
+	if (!of_fdt_device_is_available(initial_boot_params, node))
 		return 0;
 
 	err = __reserved_mem_reserve_reg(node, uname);
-- 
2.11.0

WARNING: multiple messages have this Message-ID (diff)
From: Rob Herring <robh@kernel.org>
To: devicetree@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	Nicolas Pitre <nicolas.pitre@linaro.org>,
	Frank Rowand <frowand.list@gmail.com>
Subject: [PATCH 1/2] of/fdt: add of_fdt_device_is_available function
Date: Tue,  3 Oct 2017 11:18:14 -0500	[thread overview]
Message-ID: <20171003161815.25999-1-robh@kernel.org> (raw)

Add an equivalent function to of_device_is_available for flattened DT, and
convert the one existing open coded occurrence.

Cc: Nicolas Pitre <nicolas.pitre@linaro.org>
Cc: Frank Rowand <frowand.list@gmail.com>
Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/of/fdt.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 27c535af0be8..f8c39705418b 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -132,6 +132,19 @@ bool of_fdt_is_big_endian(const void *blob, unsigned long node)
 	return false;
 }
 
+static bool of_fdt_device_is_available(const void *blob, unsigned long node)
+{
+	const char *status = fdt_getprop(blob, node, "status", NULL);
+
+	if (!status)
+		return true;
+
+	if (!strcmp(status, "ok") || !strcmp(status, "okay"))
+		return true;
+
+	return false;
+}
+
 /**
  * of_fdt_match - Return true if node matches a list of compatible values
  */
@@ -605,7 +618,6 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname,
 					  int depth, void *data)
 {
 	static int found;
-	const char *status;
 	int err;
 
 	if (!found && depth == 1 && strcmp(uname, "reserved-memory") == 0) {
@@ -625,8 +637,7 @@ static int __init __fdt_scan_reserved_mem(unsigned long node, const char *uname,
 		return 1;
 	}
 
-	status = of_get_flat_dt_prop(node, "status", NULL);
-	if (status && strcmp(status, "okay") != 0 && strcmp(status, "ok") != 0)
+	if (!of_fdt_device_is_available(initial_boot_params, node))
 		return 0;
 
 	err = __reserved_mem_reserve_reg(node, uname);
-- 
2.11.0

             reply	other threads:[~2017-10-03 16:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-03 16:18 Rob Herring [this message]
2017-10-03 16:18 ` [PATCH 1/2] of/fdt: add of_fdt_device_is_available function Rob Herring
2017-10-03 16:18 ` [PATCH 2/2] of/fdt: skip unflattening of disabled nodes Rob Herring
2017-10-03 16:18   ` Rob Herring
2017-10-03 18:46   ` Nicolas Pitre
2017-10-03 18:46     ` Nicolas Pitre
2017-10-03 18:46     ` Nicolas Pitre
2017-10-03 21:58     ` Frank Rowand
2017-10-03 21:58       ` Frank Rowand
2017-10-03 21:58       ` Frank Rowand
2017-10-05 18:29       ` Nicolas Pitre
2017-10-05 18:29         ` Nicolas Pitre
2017-10-05 18:29         ` Nicolas Pitre
2017-10-08 22:57   ` Frank Rowand
2017-10-08 22:57     ` Frank Rowand
2017-10-08 22:57     ` Frank Rowand
2017-10-09 18:59     ` Rob Herring
2017-10-09 18:59       ` Rob Herring
2017-10-09 20:20       ` Frank Rowand
2017-10-09 20:20         ` Frank Rowand
2017-10-03 18:43 ` [PATCH 1/2] of/fdt: add of_fdt_device_is_available function Nicolas Pitre
2017-10-03 18:43   ` Nicolas Pitre
2017-10-03 18:43   ` Nicolas Pitre

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=20171003161815.25999-1-robh@kernel.org \
    --to=robh@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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.