linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC] driver core: Ensure DT devices always have fwnode set
@ 2020-11-06 15:07 Mark Brown
  2020-11-06 19:09 ` Saravana Kannan
  0 siblings, 1 reply; 7+ messages in thread
From: Mark Brown @ 2020-11-06 15:07 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rafael J . Wysocki
  Cc: Daniel Mentz, Saravana Kannan, linux-kernel, Mark Brown

Currently the fwnode API and things that rely on it like fw_devlink will
not reliably work for devices created from DT since each subsystem that
creates devices must individually set dev->fwnode in addition to setting
dev->of_node, currently a number of subsystems don't do so. Ensure that
this can't get missed by setting fwnode from of_node if it's not
previously been set by the subsystem.

Reported-by: Saravana Kannan <saravanak@google.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---

*Very* minimally tested.

 drivers/base/core.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index d661ada1518f..658626bafd76 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -2864,6 +2864,10 @@ int device_add(struct device *dev)
 	if (parent && (dev_to_node(dev) == NUMA_NO_NODE))
 		set_dev_node(dev, dev_to_node(parent));
 
+	/* ensure that fwnode is set up */
+	if (IS_ENABLED(CONFIG_OF) && dev->of_node && !dev->fwnode)
+		dev->fwnode = of_fwnode_handle(dev->of_node);
+
 	/* first, register with generic layer. */
 	/* we require the name to be set before, and pass NULL */
 	error = kobject_add(&dev->kobj, dev->kobj.parent, NULL);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-11-09 17:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-06 15:07 [PATCH RFC] driver core: Ensure DT devices always have fwnode set Mark Brown
2020-11-06 19:09 ` Saravana Kannan
2020-11-06 19:23   ` Mark Brown
2020-11-07  1:55     ` Saravana Kannan
2020-11-09 17:08       ` Mark Brown
2020-11-09 17:25   ` Rob Herring
2020-11-09 17:41     ` Mark Brown

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).