mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 12/19] pmdomain: implement pm_genpd_remove/of_genpd_del_provider for cleanup
Date: Fri, 19 Jan 2024 17:26:03 +0100	[thread overview]
Message-ID: <20240119162610.1014870-13-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240119162610.1014870-1-a.fatoum@pengutronix.de>

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@pengutronix.de>
---
 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




  parent reply	other threads:[~2024-01-19 16:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19 16:25 [PATCH 00/19] pmdomain: imx: add i.MX8MP HSIO blk-ctrl driver Ahmad Fatoum
2024-01-19 16:25 ` [PATCH 01/19] drivers: soc: split off powerdomains into new pmdomain directory Ahmad Fatoum
2024-01-19 16:25 ` [PATCH 02/19] pmdomain: use single implementation for dev_pm_domain_attach Ahmad Fatoum
2024-01-19 16:25 ` [PATCH 03/19] pmdomain: power: drop unused parameters for internal functions Ahmad Fatoum
2024-01-19 16:25 ` [PATCH 04/19] pmdomain: associate devices with their power domain Ahmad Fatoum
2024-01-19 16:25 ` [PATCH 05/19] pmdomain: push have_genpd_providers check into __genpd_dev_pm_attach Ahmad Fatoum
2024-01-19 16:25 ` [PATCH 06/19] pmdomain: drop superfluous parameter to __genpd_dev_pm_attach Ahmad Fatoum
2024-01-19 16:25 ` [PATCH 07/19] pmdomain: implement dev_pm_domain_attach_by_id/name Ahmad Fatoum
2024-01-19 16:25 ` [PATCH 08/19] pmdomain: add support for enabling power domains later on Ahmad Fatoum
2024-01-19 16:26 ` [PATCH 09/19] pmdomain: imx: gpcv2: enable COMPILE_TEST build Ahmad Fatoum
2024-01-19 16:26 ` [PATCH 10/19] pmdomain: add stub definition for dev_pm_domain_detach Ahmad Fatoum
2024-01-19 16:26 ` [PATCH 11/19] pmdomain: add stub definition for pm_runtime_put_genpd Ahmad Fatoum
2024-01-19 16:26 ` Ahmad Fatoum [this message]
2024-01-19 16:26 ` [PATCH 13/19] driver: have dev_request_mem_region_err_null warn if resource starts at 0 Ahmad Fatoum
2024-01-19 16:26 ` [PATCH 14/19] include: linux/device.h: implement dev_platform_ioremap_resource Ahmad Fatoum
2024-01-19 16:26 ` [PATCH 15/19] regmap: include missing header from linux/regmap.h Ahmad Fatoum
2024-01-19 16:26 ` [PATCH 16/19] clk: define aliases for clk_bulk_prepare_enable/disable_unprepare Ahmad Fatoum
2024-01-19 16:26 ` [PATCH 17/19] driver: make driver.h header self-contained Ahmad Fatoum
2024-01-19 16:26 ` [PATCH 18/19] pmdomain: imx: add i.MX8MP HSIO blk-ctrl driver Ahmad Fatoum
2024-01-19 16:26 ` [PATCH 19/19] ARM: dts: i.MX8MP: drop barebox,allow-dummy for HSIO blk-ctrl Ahmad Fatoum
2024-01-22 10:12 ` [PATCH 00/19] pmdomain: imx: add i.MX8MP HSIO blk-ctrl driver Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240119162610.1014870-13-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox