Re: [PATCH v4 02/29] driver core: Rename get_dev_from_fwnode() wrapper to get_device_from_fwnode()

Ulf Hansson
2025-10-21T10:37:15Z

On Wed, 15 Oct 2025 at 09:16, Herve Codina <herve.codina@bootlin.com> wrote:
>
> 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@kernel.org>
> Link: https://lore.kernel.org/lkml/CAGETcx97QjnjVR8Z5g0ndLHpK96hLd4aYSV=iEkKPNbNOccYmA@mail.gmail.com/
> Signed-off-by: Herve Codina <herve.codina@bootlin.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Saravana Kannan <saravanak@google.com>
> Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe

> ---
> 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 3c533dab8fa5..334f5a4fbb9e 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
> @@ -5279,7 +5279,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.
> @@ -5297,11 +5297,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 61c2277c9ce3..5a7822de5d8a 100644
> --- a/drivers/pmdomain/core.c
> +++ b/drivers/pmdomain/core.c
> @@ -2678,7 +2678,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);
> @@ -2753,7 +2753,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 b031ff71a5bd..d8906136c086 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -1090,7 +1090,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.51.0
>