[PATCH 12/19] pmdomain: implement pm_genpd_remove/of_genpd_del_provider for cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We already have pm_genpd_init/of_genpd_add_provider, but lack functions
to deregister them. Port the deregisteration functions over from Linux.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/base/power.c | 31 +++++++++++++++++++++++++++++++
 include/pm_domain.h  | 13 +++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/drivers/base/power.c b/drivers/base/power.c
index c4318fa1dfd1..f7629f554a72 100644
--- a/drivers/base/power.c
+++ b/drivers/base/power.c
@@ -40,6 +40,19 @@ int pm_genpd_init(struct generic_pm_domain *genpd, void *gov, bool is_off)
 }
 EXPORT_SYMBOL_GPL(pm_genpd_init);
 
+int pm_genpd_remove(struct generic_pm_domain *genpd)
+{
+	if (IS_ERR_OR_NULL(genpd))
+		return -EINVAL;
+
+	list_del(&genpd->gpd_list_node);
+
+	pr_debug("%s: removed %s\n", __func__, genpd->name);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pm_genpd_remove);
+
 /**
  * struct of_genpd_provider - PM domain provider registration structure
  * @link: Entry in global list of PM domain providers
@@ -209,6 +222,24 @@ int of_genpd_add_provider_onecell(struct device_node *np,
 }
 EXPORT_SYMBOL_GPL(of_genpd_add_provider_onecell);
 
+/**
+ * of_genpd_del_provider() - Remove a previously registered PM domain provider
+ * @np: Device node pointer associated with the PM domain provider
+ */
+void of_genpd_del_provider(struct device_node *np)
+{
+	struct of_genpd_provider *cp, *tmp;
+
+	list_for_each_entry_safe(cp, tmp, &of_genpd_providers, link) {
+		if (cp->node == np) {
+			list_del(&cp->link);
+			kfree(cp);
+			break;
+		}
+	}
+}
+EXPORT_SYMBOL_GPL(of_genpd_del_provider);
+
 /**
  * genpd_get_from_provider() - Look-up PM domain
  * @genpdspec: OF phandle args to use for look-up
diff --git a/include/pm_domain.h b/include/pm_domain.h
index 1fa7f0bdbd3e..f637eb1afa9d 100644
--- a/include/pm_domain.h
+++ b/include/pm_domain.h
@@ -39,6 +39,8 @@ int pm_runtime_resume_and_get_genpd(struct device *dev);
 
 int pm_genpd_init(struct generic_pm_domain *genpd, void *gov, bool is_off);
 
+int pm_genpd_remove(struct generic_pm_domain *genpd);
+
 int of_genpd_add_provider_simple(struct device_node *np,
 				 struct generic_pm_domain *genpd);
 
@@ -51,6 +53,8 @@ struct genpd_onecell_data {
 int of_genpd_add_provider_onecell(struct device_node *np,
 				  struct genpd_onecell_data *data);
 
+void of_genpd_del_provider(struct device_node *np);
+
 void pm_genpd_print(void);
 
 #else
@@ -65,6 +69,11 @@ static inline int pm_genpd_init(struct generic_pm_domain *genpd,
 	return -ENOSYS;
 }
 
+static inline int pm_genpd_remove(struct generic_pm_domain *genpd);
+{
+	return -EOPNOTSUPP;
+}
+
 static inline int genpd_dev_pm_attach(struct device *dev)
 {
 	return 0;
@@ -94,6 +103,10 @@ of_genpd_add_provider_simple(struct device_node *np,
 	return -ENOTSUPP;
 }
 
+static inline void of_genpd_del_provider(struct device_node *np)
+{
+}
+
 #endif
 
 /**
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux