devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bjorn Andersson <bjorn.andersson@linaro.org>
To: Rob Herring <robh+dt@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	Andy Gross <andy.gross@linaro.org>,
	David Brown <david.brown@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
	linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org
Subject: [PATCH v2 1/5] of/platform: Generalize /reserved-memory handling
Date: Wed,  2 Aug 2017 19:57:50 -0700	[thread overview]
Message-ID: <20170803025754.19101-2-bjorn.andersson@linaro.org> (raw)
In-Reply-To: <20170803025754.19101-1-bjorn.andersson@linaro.org>

By iterating over all /reserved-memory child nodes and match each one to
a list of compatibles that we want to treat specially, we can easily
extend the list of compatibles to handle - without having to resort to
of_platform_populate() that would create unnecessary platform_devices.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
---

Changes since v1:
- New patch

 drivers/of/platform.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index b19524623498..8c241a116b08 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -497,23 +497,32 @@ int of_platform_default_populate(struct device_node *root,
 EXPORT_SYMBOL_GPL(of_platform_default_populate);
 
 #ifndef CONFIG_PPC
+static const char *rmem_compats[] = {
+	"ramoops",
+	NULL
+};
+
 static int __init of_platform_default_populate_init(void)
 {
+	struct device_node *rmem_nodes;
 	struct device_node *node;
+	int ret;
 
 	if (!of_have_populated_dt())
 		return -ENODEV;
 
 	/*
-	 * Handle ramoops explicitly, since it is inside /reserved-memory,
-	 * which lacks a "compatible" property.
+	 * Handle certain compatibles explicitly, since we don't want to create
+	 * platform_devices for every node in /reserved-memory with a
+	 * "compatible",
 	 */
-	node = of_find_node_by_path("/reserved-memory");
-	if (node) {
-		node = of_find_compatible_node(node, NULL, "ramoops");
-		if (node)
+	rmem_nodes = of_find_node_by_path("/reserved-memory");
+	for_each_available_child_of_node(rmem_nodes, node) {
+		ret = of_device_compatible_match(node, rmem_compats);
+		if (ret)
 			of_platform_device_create(node, NULL, NULL);
 	}
+	of_node_put(rmem_nodes);
 
 	/* Populate everything else. */
 	of_platform_default_populate(NULL, NULL, NULL);
-- 
2.12.0

  reply	other threads:[~2017-08-03  2:57 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-03  2:57 [PATCH v2 0/5] Qualcomm remote filesystem shared memory driver Bjorn Andersson
2017-08-03  2:57 ` Bjorn Andersson [this message]
2017-08-03 17:40   ` [PATCH v2 1/5] of/platform: Generalize /reserved-memory handling Rob Herring
     [not found]     ` <CAL_JsqKBre5yPJHG3s+8Y7_hgj0_r35nNZc3QiL4HbWLuFx=Bg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-08-03 23:33       ` Bjorn Andersson
2017-08-03  2:57 ` [PATCH v2 2/5] of: reserved_mem: Accessor for acquiring reserved_mem Bjorn Andersson
     [not found]   ` <20170803025754.19101-3-bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-08-03 17:45     ` Rob Herring
2017-08-03 23:31       ` Bjorn Andersson
2017-08-04 14:50         ` Rob Herring
2017-08-04 15:08           ` Bjorn Andersson
2017-08-03  2:57 ` [PATCH v2 3/5] dt-binding: soc: qcom: Add binding for RFSA Bjorn Andersson
2017-08-10 16:50   ` Rob Herring
     [not found] ` <20170803025754.19101-1-bjorn.andersson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2017-08-03  2:57   ` [PATCH v2 4/5] soc: qcom: Remote FS memory driver Bjorn Andersson
2017-08-05  9:58     ` Christoph Hellwig
2017-08-07 16:23       ` Bjorn Andersson
2017-08-11 10:00         ` Christoph Hellwig
2017-08-03  2:57 ` [PATCH v2 5/5] arm64: dts: msm8916: Mark rmtfs node as qcom,rfsa compatible Bjorn Andersson

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=20170803025754.19101-2-bjorn.andersson@linaro.org \
    --to=bjorn.andersson@linaro.org \
    --cc=andy.gross@linaro.org \
    --cc=david.brown@linaro.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-soc@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).