linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandru Ardelean <aardelean@deviqon.com>
To: linux-kernel@vger.kernel.org
Cc: lgirdwood@gmail.com, broonie@kernel.org,
	Alexandru Ardelean <aardelean@deviqon.com>
Subject: [PATCH 2/4] regulator: devres: remove devm_regulator_unregister() function
Date: Fri, 25 Jun 2021 15:23:22 +0300	[thread overview]
Message-ID: <20210625122324.327585-3-aardelean@deviqon.com> (raw)
In-Reply-To: <20210625122324.327585-1-aardelean@deviqon.com>

This API hook isn't used anywhere and most-likely exists because of the
general principle of C APIs, where if an API function does an
allocation/registration, it must also have an equivalent
deallocation/deregistration counterpart.

For devm_ functions this isn't all that true (for all cases), as the idea
of these function is to provide an auto-cleanup logic on drivers/system
de-init.

Removing this also discourages any weird logic that could be created with
such an API function.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
---
 drivers/regulator/devres.c       | 29 -----------------------------
 include/linux/regulator/driver.h |  1 -
 2 files changed, 30 deletions(-)

diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c
index 8895f0f5ad1d..bf0d19a7fb69 100644
--- a/drivers/regulator/devres.c
+++ b/drivers/regulator/devres.c
@@ -205,35 +205,6 @@ struct regulator_dev *devm_regulator_register(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(devm_regulator_register);
 
-static int devm_rdev_match(struct device *dev, void *res, void *data)
-{
-	struct regulator_dev **r = res;
-	if (!r || !*r) {
-		WARN_ON(!r || !*r);
-		return 0;
-	}
-	return *r == data;
-}
-
-/**
- * devm_regulator_unregister - Resource managed regulator_unregister()
- * @dev:  device to supply
- * @rdev: regulator to free
- *
- * Unregister a regulator registered with devm_regulator_register().
- * Normally this function will not need to be called and the resource
- * management code will ensure that the resource is freed.
- */
-void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev)
-{
-	int rc;
-
-	rc = devres_release(dev, devm_rdev_release, devm_rdev_match, rdev);
-	if (rc != 0)
-		WARN_ON(rc);
-}
-EXPORT_SYMBOL_GPL(devm_regulator_unregister);
-
 struct regulator_supply_alias_match {
 	struct device *dev;
 	const char *id;
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index 4aec20387857..5447a6b33fa0 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -645,7 +645,6 @@ devm_regulator_register(struct device *dev,
 			const struct regulator_desc *regulator_desc,
 			const struct regulator_config *config);
 void regulator_unregister(struct regulator_dev *rdev);
-void devm_regulator_unregister(struct device *dev, struct regulator_dev *rdev);
 
 int regulator_notifier_call_chain(struct regulator_dev *rdev,
 				  unsigned long event, void *data);
-- 
2.31.1


  parent reply	other threads:[~2021-06-25 12:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-25 12:23 [PATCH 0/4] regulator: devres: remove unused device-managed unregister APIs Alexandru Ardelean
2021-06-25 12:23 ` [PATCH 1/4] regulator: devres: remove devm_regulator_unregister_notifier() function Alexandru Ardelean
2021-06-25 12:23 ` Alexandru Ardelean [this message]
2021-06-25 12:23 ` [PATCH 3/4] regulator: devres: remove devm_regulator_bulk_unregister_supply_alias() Alexandru Ardelean
2021-06-25 12:23 ` [PATCH 4/4] regulator: devres: unexport devm_regulator_unregister_supply_alias() Alexandru Ardelean
2021-07-12 10:45 ` [PATCH 0/4] regulator: devres: remove unused device-managed unregister APIs Mark Brown

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=20210625122324.327585-3-aardelean@deviqon.com \
    --to=aardelean@deviqon.com \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 2/4] regulator: devres: remove devm_regulator_unregister() function' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).