Re: [PATCH v2 03/10] pmdomain: Make genpd_get_from_provider() public

From: Ulf Hansson

Date: Tue Jul 14 2026 - 08:37:54 EST


On Wed, Jul 8, 2026 at 12:17 PM Geert Uytterhoeven
<geert+renesas@xxxxxxxxx> wrote:
>
> Unlike the corresponding function in the clock subsystem
> (of_clk_get_from_provider()), genpd_get_from_provider() is private, and
> thus cannot be used by PM Domain drivers.
>
> Make it public, so it be used by the R-Car X5H Module Controller driver.

I am a bit reluctant to make it public, because of potential abuse.
Moreover, there is no protection or reference counting of the genpd
that is returned, hence the caller needs to be careful.

That said, if there is a strong argument that it's really needed, I am
fine with it.

>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@xxxxxxxxx>
> ---
> v2:
> - No changes.
> ---
> drivers/pmdomain/core.c | 4 ++--
> include/linux/pm_domain.h | 7 +++++++
> 2 files changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
> index 842c4169e290677c..7de3c693ddd9a2c8 100644
> --- a/drivers/pmdomain/core.c
> +++ b/drivers/pmdomain/core.c
> @@ -2900,8 +2900,7 @@ EXPORT_SYMBOL_GPL(of_genpd_del_provider);
> * Returns a valid pointer to struct generic_pm_domain on success or ERR_PTR()
> * on failure.
> */
> -static struct generic_pm_domain *genpd_get_from_provider(
> - const struct of_phandle_args *genpdspec)
> +struct generic_pm_domain *genpd_get_from_provider(const struct of_phandle_args *genpdspec)

If we are going to do this, please add "of_" as prefix for the
function to have consistent names of public genpd functions.

> {
> struct generic_pm_domain *genpd = ERR_PTR(-ENOENT);
> struct of_genpd_provider *provider;
> @@ -2923,6 +2922,7 @@ static struct generic_pm_domain *genpd_get_from_provider(
>
> return genpd;
> }
> +EXPORT_SYMBOL_GPL(genpd_get_from_provider);
>
> /**
> * of_genpd_add_child_ids() - Parse power-domains-child-ids property
> diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
> index f925614aebdbc914..95fd7e63e87e2095 100644
> --- a/include/linux/pm_domain.h
> +++ b/include/linux/pm_domain.h
> @@ -458,6 +458,7 @@ int of_genpd_add_provider_simple(struct device_node *np,
> int of_genpd_add_provider_onecell(struct device_node *np,
> struct genpd_onecell_data *data);
> void of_genpd_del_provider(struct device_node *np);
> +struct generic_pm_domain *genpd_get_from_provider(const struct of_phandle_args *genpdspec);
> int of_genpd_add_device(const struct of_phandle_args *args, struct device *dev);
> int of_genpd_add_subdomain(const struct of_phandle_args *parent_spec,
> const struct of_phandle_args *subdomain_spec);
> @@ -492,6 +493,12 @@ static inline int of_genpd_add_provider_onecell(struct device_node *np,
>
> static inline void of_genpd_del_provider(struct device_node *np) {}
>
> +static inline struct generic_pm_domain *genpd_get_from_provider(
> + const struct of_phandle_args *genpdspec)
> +{
> + return ERR_PTR(-ENODEV);
> +}
> +
> static inline int of_genpd_add_device(const struct of_phandle_args *args,
> struct device *dev)
> {
> --
> 2.43.0
>

Kind regards
Uffe