]> git.baikalelectronics.ru Git - kernel.git/commitdiff
driver core: add a helper to setup both the of_node and fwnode of a device
authorIoana Ciornei <ioana.ciornei@nxp.com>
Thu, 17 Jun 2021 12:29:04 +0000 (15:29 +0300)
committerDavid S. Miller <davem@davemloft.net>
Thu, 17 Jun 2021 19:06:52 +0000 (12:06 -0700)
There are many places where both the fwnode_handle and the of_node of a
device need to be populated. Add a function which does both so that we
have consistency.

Suggested-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/base/core.c
include/linux/device.h

index 628e33939acaed4cb20c92016279b87071d4c430..b6836bfa985cd26b6983039c360521da76a90025 100644 (file)
@@ -4723,6 +4723,13 @@ void device_set_of_node_from_dev(struct device *dev, const struct device *dev2)
 }
 EXPORT_SYMBOL_GPL(device_set_of_node_from_dev);
 
+void device_set_node(struct device *dev, struct fwnode_handle *fwnode)
+{
+       dev->fwnode = fwnode;
+       dev->of_node = to_of_node(fwnode);
+}
+EXPORT_SYMBOL_GPL(device_set_node);
+
 int device_match_name(struct device *dev, const void *name)
 {
        return sysfs_streq(dev_name(dev), name);
index 38a2071cf77685a3b8c520f4d4eafb50ee080669..a1e7cab2c7bf7cac8f2937e212f1ab9206c40e64 100644 (file)
@@ -819,6 +819,7 @@ int device_online(struct device *dev);
 void set_primary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
 void set_secondary_fwnode(struct device *dev, struct fwnode_handle *fwnode);
 void device_set_of_node_from_dev(struct device *dev, const struct device *dev2);
+void device_set_node(struct device *dev, struct fwnode_handle *fwnode);
 
 static inline int dev_num_vf(struct device *dev)
 {