diff mbox

[RFC,13/14] PM / Domains: Introduce pm_genpd_present()

Message ID 201207162331.00295.rjw@sisk.pl (mailing list archive)
State Awaiting Upstream
Headers show

Commit Message

Rafael Wysocki July 16, 2012, 9:30 p.m. UTC
From: Rafael J. Wysocki <rjw@sisk.pl>

Introduce function pm_genpd_present() allowing the caller to check if
the given generic PM domain has been initialized.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/base/power/domain.c |   22 ++++++++++++++++++++++
 include/linux/pm_domain.h   |    5 +++++
 2 files changed, 27 insertions(+)


--
To unsubscribe from this list: send the line "unsubscribe linux-sh" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

Index: linux/drivers/base/power/domain.c
===================================================================
--- linux.orig/drivers/base/power/domain.c
+++ linux/drivers/base/power/domain.c
@@ -2089,3 +2089,25 @@  void pm_genpd_init(struct generic_pm_dom
 	list_add(&genpd->gpd_list_node, &gpd_list);
 	mutex_unlock(&gpd_list_lock);
 }
+
+/**
+ * pm_genpd_present - Check if the given PM domain has been initialized
+ * @genpd: PM domain to check.
+ */
+bool pm_genpd_present(struct generic_pm_domain *genpd)
+{
+	struct generic_pm_domain *gpd = NULL;
+
+	if (IS_ERR_OR_NULL(genpd))
+		return false;
+
+	mutex_lock(&gpd_list_lock);
+
+	list_for_each_entry(gpd, &gpd_list, gpd_list_node)
+		if (gpd == genpd)
+			break;
+
+	mutex_unlock(&gpd_list_lock);
+
+	return gpd == genpd;
+}
Index: linux/include/linux/pm_domain.h
===================================================================
--- linux.orig/include/linux/pm_domain.h
+++ linux/include/linux/pm_domain.h
@@ -161,6 +161,7 @@  extern int genpd_attach_cpuidle(struct g
 extern int genpd_detach_cpuidle(struct generic_pm_domain *genpd);
 extern void pm_genpd_init(struct generic_pm_domain *genpd,
 			  struct dev_power_governor *gov, bool is_off);
+extern bool pm_genpd_present(struct generic_pm_domain *genpd);
 
 extern int pm_genpd_poweron(struct generic_pm_domain *genpd);
 extern int pm_genpd_name_poweron(const char *domain_name);
@@ -239,6 +240,10 @@  static inline void pm_genpd_init(struct
 				 struct dev_power_governor *gov, bool is_off)
 {
 }
+static inline bool pm_genpd_present(struct generic_pm_domain *genpd)
+{
+	return false;
+}
 static inline int pm_genpd_poweron(struct generic_pm_domain *genpd)
 {
 	return -ENOSYS;