From: Mans Rullgard <mans@mansr.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>
Subject: [PATCH v3] platform: set of_node in platform_device_register_full()
Date: Thu, 21 Feb 2019 11:29:35 +0000 [thread overview]
Message-ID: <20190221112935.4538-1-mans@mansr.com> (raw)
If the provided fwnode is an OF node, set dev.of_node as well.
Also add an of_node_reused flag to struct platform_device_info and copy
this to the new device. This is needed to avoid pinctrl settings being
requested twice. See 4e75e1d7dac9 ("driver core: add helper to reuse a
device-tree node") for a longer explanation.
Some drivers are just shims that create extra "glue" devices with the
DT device as parent and have the real driver bind to these. In these
cases, the glue device needs to get a reference to the original DT node
in order for the main driver to access properties and child nodes.
For example, the sunxi-musb driver creates such a glue device using
platform_device_register_full(). Consequently, devices attached to
this USB interface don't get associated with DT nodes, if present,
the way they do with EHCI.
This change will allow sunxi-musb and similar drivers to easily
propagate the DT node to child devices as required.
Signed-off-by: Mans Rullgard <mans@mansr.com>
---
Changes in v3:
- handle of_node_reused
---
drivers/base/platform.c | 2 ++
include/linux/platform_device.h | 1 +
2 files changed, 3 insertions(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index dff82a3c2caa..7058ecea779a 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -512,6 +512,8 @@ struct platform_device *platform_device_register_full(
pdev->dev.parent = pdevinfo->parent;
pdev->dev.fwnode = pdevinfo->fwnode;
+ pdev->dev.of_node = of_node_get(to_of_node(pdev->dev.fwnode));
+ pdev->dev.of_node_reused = pdevinfo->of_node_reused;
if (pdevinfo->dma_mask) {
/*
diff --git a/include/linux/platform_device.h b/include/linux/platform_device.h
index 1a9f38f27f65..4a29fdf16806 100644
--- a/include/linux/platform_device.h
+++ b/include/linux/platform_device.h
@@ -62,6 +62,7 @@ extern int platform_add_devices(struct platform_device **, int);
struct platform_device_info {
struct device *parent;
struct fwnode_handle *fwnode;
+ bool of_node_reused;
const char *name;
int id;
--
2.20.1
next reply other threads:[~2019-02-21 11:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 11:29 Mans Rullgard [this message]
2019-02-22 9:16 ` Rafael J. Wysocki
2019-02-22 13:23 ` Måns Rullgård
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=20190221112935.4538-1-mans@mansr.com \
--to=mans@mansr.com \
--cc=gregkh@linuxfoundation.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@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
Powered by JetHome