Skip to content

Commit 9a4681a

Browse files
author
Ulf Hansson
committed
driver core: Export get_dev_from_fwnode()
It has turned out get_dev_from_fwnode() is useful at a few other places outside of the driver core, as in gpiolib.c for example. Therefore let's make it available as a common helper function. Suggested-by: Saravana Kannan <saravanak@google.com> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Tested-by: Hiago De Franco <hiago.franco@toradex.com> # Colibri iMX8X Tested-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> # TI AM62A,Xilinx ZynqMP ZCU106 Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://lore.kernel.org/r/20250701114733.636510-18-ulf.hansson@linaro.org
1 parent 29ea338 commit 9a4681a

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

drivers/base/core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,8 +1881,6 @@ static void fw_devlink_unblock_consumers(struct device *dev)
18811881
device_links_write_unlock();
18821882
}
18831883

1884-
#define get_dev_from_fwnode(fwnode) get_device((fwnode)->dev)
1885-
18861884
static bool fwnode_init_without_drv(struct fwnode_handle *fwnode)
18871885
{
18881886
struct device *dev;
@@ -5281,6 +5279,12 @@ void device_set_node(struct device *dev, struct fwnode_handle *fwnode)
52815279
}
52825280
EXPORT_SYMBOL_GPL(device_set_node);
52835281

5282+
struct device *get_dev_from_fwnode(struct fwnode_handle *fwnode)
5283+
{
5284+
return get_device((fwnode)->dev);
5285+
}
5286+
EXPORT_SYMBOL_GPL(get_dev_from_fwnode);
5287+
52845288
int device_match_name(struct device *dev, const void *name)
52855289
{
52865290
return sysfs_streq(dev_name(dev), name);

include/linux/device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,7 @@ void device_set_node(struct device *dev, struct fwnode_handle *fwnode);
10481048
int device_add_of_node(struct device *dev, struct device_node *of_node);
10491049
void device_remove_of_node(struct device *dev);
10501050
void device_set_of_node_from_dev(struct device *dev, const struct device *dev2);
1051+
struct device *get_dev_from_fwnode(struct fwnode_handle *fwnode);
10511052

10521053
static inline struct device_node *dev_of_node(struct device *dev)
10531054
{

0 commit comments

Comments
 (0)