From: Saravana Kannan <saravanak@google.com>
To: Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Frank Rowand <frowand.list@gmail.com>
Cc: Saravana Kannan <saravanak@google.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
David Collins <collinsd@codeaurora.org>,
kernel-team@android.com
Subject: [PATCH v5 08/11] of/platform: Make sure supplier DT node is device when creating device links
Date: Fri, 12 Jul 2019 16:52:41 -0700 [thread overview]
Message-ID: <20190712235245.202558-9-saravanak@google.com> (raw)
In-Reply-To: <20190712235245.202558-1-saravanak@google.com>
While most phandle references in common bindings point to the supplier
device node, there are also common bindings where the phandle can
pointing to a child node of the supplier device node.
Therefore, when trying to find the supplier device that corresponds to a
supplier phandle, we need to make sure we are using the supplier's
device node. Otherwise, we'll never find the supplier device.
Signed-off-by: Saravana Kannan <saravanak@google.com>
---
drivers/of/platform.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/of/platform.c b/drivers/of/platform.c
index 98414ba53b1f..cf8625abe30c 100644
--- a/drivers/of/platform.c
+++ b/drivers/of/platform.c
@@ -529,19 +529,33 @@ static int of_link_binding(struct device *dev,
const char *binding, const char *cell)
{
struct of_phandle_args sup_args;
+ struct device_node *sup_np;
struct platform_device *sup_dev;
unsigned int i = 0, links = 0;
u32 dl_flags = DL_FLAG_AUTOPROBE_CONSUMER;
while (!of_parse_phandle_with_args(dev->of_node, binding, cell, i,
&sup_args)) {
- if (!of_link_is_valid(dev->of_node, sup_args.np)) {
- of_node_put(sup_args.np);
+ sup_np = sup_args.np;
+ /*
+ * Since we are trying to create device links, we need to find
+ * the actual device node that owns this supplier phandle.
+ * Often times it's the same node, but sometimes it can be one
+ * of the parents. So walk up the parent till you find a
+ * device.
+ */
+ while (sup_np && !of_find_property(sup_np, "compatible", NULL))
+ sup_np = of_get_next_parent(sup_np);
+ if (!sup_np)
+ continue;
+
+ if (!of_link_is_valid(dev->of_node, sup_np)) {
+ of_node_put(sup_np);
continue;
}
i++;
- sup_dev = of_find_device_by_node(sup_args.np);
- of_node_put(sup_args.np);
+ sup_dev = of_find_device_by_node(sup_np);
+ of_node_put(sup_np);
if (!sup_dev)
continue;
if (device_link_add(dev, &sup_dev->dev, dl_flags))
--
2.22.0.510.g264f2c817a-goog
next prev parent reply other threads:[~2019-07-12 23:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-12 23:52 [PATCH v5 00/11] Solve postboot supplier cleanup and optimize probe ordering Saravana Kannan
2019-07-12 23:52 ` [PATCH v5 01/11] driver core: Add support for linking devices during device addition Saravana Kannan
2019-07-12 23:52 ` [PATCH v5 02/11] of/platform: Add functional dependency link from DT bindings Saravana Kannan
2019-07-16 23:43 ` Rob Herring
2019-07-16 23:53 ` Saravana Kannan
2019-07-17 14:35 ` Rob Herring
2019-07-17 20:38 ` Saravana Kannan
2019-07-12 23:52 ` [PATCH v5 03/11] driver core: Add sync_state driver/bus callback Saravana Kannan
2019-07-12 23:52 ` [PATCH v5 04/11] driver core: Add edit_links() callback for drivers Saravana Kannan
2019-07-12 23:52 ` [PATCH v5 05/11] driver core: Add APIs to pause/resume sync state callbacks Saravana Kannan
2019-07-12 23:52 ` [PATCH v5 06/11] of/platform: Pause/resume sync state in of_platform_populate() Saravana Kannan
2019-07-12 23:52 ` [PATCH v5 07/11] of/platform: Sanity check DT bindings before creating device links Saravana Kannan
2019-07-12 23:52 ` Saravana Kannan [this message]
2019-07-12 23:52 ` [PATCH v5 09/11] of/platform: Create device links for all child-supplier depencencies Saravana Kannan
2019-07-12 23:52 ` [PATCH v5 10/11] of/platform: Add functional dependency link from DT regulator bindings Saravana Kannan
2019-07-12 23:52 ` [PATCH v5 11/11] of/platform: Don't create device links default busses Saravana Kannan
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=20190712235245.202558-9-saravanak@google.com \
--to=saravanak@google.com \
--cc=collinsd@codeaurora.org \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-team@android.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=rafael@kernel.org \
--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).