[PATCH v5 02/28] driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode()

From: Herve Codina

Date: Fri Feb 27 2026 - 08:58:16 EST


get_dev_from_fwnode() calls get_device() and so it acquires a reference
on the device returned.

In order to be more obvious that this wrapper is a get_device() variant,
rename it to get_device_from_fwnode().

Suggested-by: Mark Brown <broonie@xxxxxxxxxx>
Link: https://lore.kernel.org/lkml/CAGETcx97QjnjVR8Z5g0ndLHpK96hLd4aYSV=iEkKPNbNOccYmA@xxxxxxxxxxxxxx/
Signed-off-by: Herve Codina <herve.codina@xxxxxxxxxxx>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Reviewed-by: Saravana Kannan <saravanak@xxxxxxxxxx>
Reviewed-by: Luca Ceresoli <luca.ceresoli@xxxxxxxxxxx>
Acked-by: Ulf Hansson <ulf.hansson@xxxxxxxxxx>
---
drivers/base/core.c | 18 +++++++++---------
drivers/pmdomain/core.c | 4 ++--
include/linux/device.h | 2 +-
3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 791f9e444df8..33c0ff2b162d 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1888,7 +1888,7 @@ static bool fwnode_init_without_drv(struct fwnode_handle *fwnode)
if (!(fwnode->flags & FWNODE_FLAG_INITIALIZED))
return false;

- dev = get_dev_from_fwnode(fwnode);
+ dev = get_device_from_fwnode(fwnode);
ret = !dev || dev->links.status == DL_DEV_NO_DRIVER;
put_device(dev);

@@ -1957,7 +1957,7 @@ static struct device *fwnode_get_next_parent_dev(const struct fwnode_handle *fwn
struct device *dev;

fwnode_for_each_parent_node(fwnode, parent) {
- dev = get_dev_from_fwnode(parent);
+ dev = get_device_from_fwnode(parent);
if (dev) {
fwnode_handle_put(parent);
return dev;
@@ -2013,8 +2013,8 @@ static bool __fw_devlink_relax_cycles(struct fwnode_handle *con_handle,
goto out;
}

- sup_dev = get_dev_from_fwnode(sup_handle);
- con_dev = get_dev_from_fwnode(con_handle);
+ sup_dev = get_device_from_fwnode(sup_handle);
+ con_dev = get_device_from_fwnode(con_handle);
/*
* If sup_dev is bound to a driver and @con hasn't started binding to a
* driver, sup_dev can't be a consumer of @con. So, no need to check
@@ -2153,7 +2153,7 @@ static int fw_devlink_create_devlink(struct device *con,
if (sup_handle->flags & FWNODE_FLAG_NOT_DEVICE)
sup_dev = fwnode_get_next_parent_dev(sup_handle);
else
- sup_dev = get_dev_from_fwnode(sup_handle);
+ sup_dev = get_device_from_fwnode(sup_handle);

if (sup_dev) {
/*
@@ -2222,7 +2222,7 @@ static void __fw_devlink_link_to_consumers(struct device *dev)
bool own_link = true;
int ret;

- con_dev = get_dev_from_fwnode(link->consumer);
+ con_dev = get_device_from_fwnode(link->consumer);
/*
* If consumer device is not available yet, make a "proxy"
* SYNC_STATE_ONLY link from the consumer's parent device to
@@ -5278,7 +5278,7 @@ void device_set_node(struct device *dev, struct fwnode_handle *fwnode)
EXPORT_SYMBOL_GPL(device_set_node);

/**
- * get_dev_from_fwnode - Obtain a reference count of the struct device the
+ * get_device_from_fwnode - Obtain a reference count of the struct device the
* struct fwnode_handle is associated with.
* @fwnode: The pointer to the struct fwnode_handle to obtain the struct device
* reference count of.
@@ -5296,11 +5296,11 @@ EXPORT_SYMBOL_GPL(device_set_node);
* This is possible since struct fwnode_handle has its own reference count and
* hence can out-live the struct device it is associated with.
*/
-struct device *get_dev_from_fwnode(struct fwnode_handle *fwnode)
+struct device *get_device_from_fwnode(struct fwnode_handle *fwnode)
{
return get_device((fwnode)->dev);
}
-EXPORT_SYMBOL_GPL(get_dev_from_fwnode);
+EXPORT_SYMBOL_GPL(get_device_from_fwnode);

int device_match_name(struct device *dev, const void *name)
{
diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 52ea84e548ff..444008234b05 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -2686,7 +2686,7 @@ int of_genpd_add_provider_simple(struct device_node *np,
genpd->dev.of_node = np;

fwnode = of_fwnode_handle(np);
- dev = get_dev_from_fwnode(fwnode);
+ dev = get_device_from_fwnode(fwnode);
if (!dev && !genpd_is_no_sync_state(genpd)) {
genpd->sync_state = GENPD_SYNC_STATE_SIMPLE;
device_set_node(&genpd->dev, fwnode);
@@ -2761,7 +2761,7 @@ int of_genpd_add_provider_onecell(struct device_node *np,
data->xlate = genpd_xlate_onecell;

fwnode = of_fwnode_handle(np);
- dev = get_dev_from_fwnode(fwnode);
+ dev = get_device_from_fwnode(fwnode);
if (!dev)
sync_state = true;
else
diff --git a/include/linux/device.h b/include/linux/device.h
index 0be95294b6e6..fd08e55e05de 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -1071,7 +1071,7 @@ void device_set_node(struct device *dev, struct fwnode_handle *fwnode);
int device_add_of_node(struct device *dev, struct device_node *of_node);
void device_remove_of_node(struct device *dev);
void device_set_of_node_from_dev(struct device *dev, const struct device *dev2);
-struct device *get_dev_from_fwnode(struct fwnode_handle *fwnode);
+struct device *get_device_from_fwnode(struct fwnode_handle *fwnode);

static inline struct device_node *dev_of_node(struct device *dev)
{
--
2.53.0