aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2024-01-24 16:01:01 +0100
committerUlf Hansson <ulf.hansson@linaro.org>2024-02-01 13:22:25 +0100
commit47249fff0e60854aeb8875ddca57edd9883b8e97 (patch)
treec970646890a3217e3d4c2ec019883532095ba6a0
parent90886b47b2b0e082bfea894bafec218826046d77 (diff)
pmdomain: core: Add an OF helper to get the index for a power-domain-name
To enable some simplification of code, let's introduce an OF helper function to genpd, of_genpd_index_by_name(), which gets the corresponding index for a name if it's present in the power-domain-names DT property. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
-rw-r--r--drivers/pmdomain/core.c16
-rw-r--r--include/linux/pm_domain.h8
2 files changed, 23 insertions, 1 deletions
diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c
index 46331e71108a..f97e8ccf1678 100644
--- a/drivers/pmdomain/core.c
+++ b/drivers/pmdomain/core.c
@@ -2951,6 +2951,22 @@ struct device *genpd_dev_pm_attach_by_name(struct device *dev, const char *name)
return genpd_dev_pm_attach_by_id(dev, index);
}
+/**
+ * of_genpd_index_by_name - Find the index for power-domain-name
+ * @np: The device node to parse.
+ * @name: The name to look for in the power-domain-names DT property.
+ *
+ * This function looks for the corresponding index for a name in the
+ * power-domain-names list specified in DT.
+ *
+ * Returns the index on success or a negative error code on failure.
+ */
+int of_genpd_index_by_name(const struct device_node *np, const char *name)
+{
+ return of_property_match_string(np, "power-domain-names", name);
+}
+EXPORT_SYMBOL_GPL(of_genpd_index_by_name);
+
static const struct of_device_id idle_state_match[] = {
{ .compatible = "domain-idle-state", },
{ }
diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
index fb91770ba4ba..470c1ded93ea 100644
--- a/include/linux/pm_domain.h
+++ b/include/linux/pm_domain.h
@@ -372,7 +372,7 @@ int of_genpd_remove_subdomain(struct of_phandle_args *parent_spec,
struct generic_pm_domain *of_genpd_remove_last(struct device_node *np);
int of_genpd_parse_idle_states(struct device_node *dn,
struct genpd_power_state **states, int *n);
-
+int of_genpd_index_by_name(const struct device_node *np, const char *name);
int genpd_dev_pm_attach(struct device *dev);
struct device *genpd_dev_pm_attach_by_id(struct device *dev,
unsigned int index);
@@ -417,6 +417,12 @@ static inline int of_genpd_parse_idle_states(struct device_node *dn,
return -ENODEV;
}
+static inline int of_genpd_index_by_name(const struct device_node *np,
+ const char *name)
+{
+ return -EOPNOTSUPP;
+}
+
static inline int genpd_dev_pm_attach(struct device *dev)
{
return 0;