linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] regulator: devres: remove unused device-managed unregister APIs
@ 2021-06-25 12:23 Alexandru Ardelean
  2021-06-25 12:23 ` [PATCH 1/4] regulator: devres: remove devm_regulator_unregister_notifier() function Alexandru Ardelean
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Alexandru Ardelean @ 2021-06-25 12:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: lgirdwood, broonie, Alexandru Ardelean

These APIs aren't used anywhere and most-likely exist 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 these discourages any weird logic that could be created with
such an API functions.

Alexandru Ardelean (4):
  regulator: devres: remove devm_regulator_unregister_notifier()
    function
  regulator: devres: remove devm_regulator_unregister() function
  regulator: devres: remove
    devm_regulator_bulk_unregister_supply_alias()
  regulator: devres: unexport devm_regulator_unregister_supply_alias()

 drivers/regulator/devres.c         | 105 +----------------------------
 include/linux/regulator/consumer.h |  23 -------
 include/linux/regulator/driver.h   |   1 -
 3 files changed, 2 insertions(+), 127 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] regulator: devres: remove devm_regulator_unregister_notifier() function
  2021-06-25 12:23 [PATCH 0/4] regulator: devres: remove unused device-managed unregister APIs Alexandru Ardelean
@ 2021-06-25 12:23 ` Alexandru Ardelean
  2021-06-25 12:23 ` [PATCH 2/4] regulator: devres: remove devm_regulator_unregister() function Alexandru Ardelean
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Alexandru Ardelean @ 2021-06-25 12:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: lgirdwood, broonie, Alexandru Ardelean

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         | 36 ------------------------------
 include/linux/regulator/consumer.h |  8 -------
 2 files changed, 44 deletions(-)

diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c
index a8de0aa88bad..8895f0f5ad1d 100644
--- a/drivers/regulator/devres.c
+++ b/drivers/regulator/devres.c
@@ -402,15 +402,6 @@ struct regulator_notifier_match {
 	struct notifier_block *nb;
 };
 
-static int devm_regulator_match_notifier(struct device *dev, void *res,
-					 void *data)
-{
-	struct regulator_notifier_match *match = res;
-	struct regulator_notifier_match *target = data;
-
-	return match->regulator == target->regulator && match->nb == target->nb;
-}
-
 static void devm_regulator_destroy_notifier(struct device *dev, void *res)
 {
 	struct regulator_notifier_match *match = res;
@@ -455,33 +446,6 @@ int devm_regulator_register_notifier(struct regulator *regulator,
 }
 EXPORT_SYMBOL_GPL(devm_regulator_register_notifier);
 
-/**
- * devm_regulator_unregister_notifier - Resource managed
- * regulator_unregister_notifier()
- *
- * @regulator: regulator source
- * @nb:        notifier block
- *
- * Unregister a notifier registered with devm_regulator_register_notifier().
- * 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_notifier(struct regulator *regulator,
-					struct notifier_block *nb)
-{
-	struct regulator_notifier_match match;
-	int rc;
-
-	match.regulator = regulator;
-	match.nb = nb;
-
-	rc = devres_release(regulator->dev, devm_regulator_destroy_notifier,
-			    devm_regulator_match_notifier, &match);
-	if (rc != 0)
-		WARN_ON(rc);
-}
-EXPORT_SYMBOL_GPL(devm_regulator_unregister_notifier);
-
 static void regulator_irq_helper_drop(void *res)
 {
 	regulator_irq_helper_cancel(&res);
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index f72ca73631be..fb653d2a11f0 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -290,8 +290,6 @@ int devm_regulator_register_notifier(struct regulator *regulator,
 				     struct notifier_block *nb);
 int regulator_unregister_notifier(struct regulator *regulator,
 				struct notifier_block *nb);
-void devm_regulator_unregister_notifier(struct regulator *regulator,
-					struct notifier_block *nb);
 
 /* regulator suspend */
 int regulator_suspend_enable(struct regulator_dev *rdev,
@@ -597,12 +595,6 @@ static inline int regulator_unregister_notifier(struct regulator *regulator,
 	return 0;
 }
 
-static inline int devm_regulator_unregister_notifier(struct regulator *regulator,
-						     struct notifier_block *nb)
-{
-	return 0;
-}
-
 static inline int regulator_suspend_enable(struct regulator_dev *rdev,
 					   suspend_state_t state)
 {
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] regulator: devres: remove devm_regulator_unregister() function
  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
  2021-06-25 12:23 ` [PATCH 3/4] regulator: devres: remove devm_regulator_bulk_unregister_supply_alias() Alexandru Ardelean
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Alexandru Ardelean @ 2021-06-25 12:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: lgirdwood, broonie, Alexandru Ardelean

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] regulator: devres: remove devm_regulator_bulk_unregister_supply_alias()
  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 ` [PATCH 2/4] regulator: devres: remove devm_regulator_unregister() function Alexandru Ardelean
@ 2021-06-25 12:23 ` 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
  4 siblings, 0 replies; 6+ messages in thread
From: Alexandru Ardelean @ 2021-06-25 12:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: lgirdwood, broonie, Alexandru Ardelean

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         | 24 ------------------------
 include/linux/regulator/consumer.h |  8 --------
 2 files changed, 32 deletions(-)

diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c
index bf0d19a7fb69..007855ae165b 100644
--- a/drivers/regulator/devres.c
+++ b/drivers/regulator/devres.c
@@ -344,30 +344,6 @@ int devm_regulator_bulk_register_supply_alias(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(devm_regulator_bulk_register_supply_alias);
 
-/**
- * devm_regulator_bulk_unregister_supply_alias - Managed unregister
- * multiple aliases
- *
- * @dev:    device to supply
- * @id:     list of supply names or regulator IDs
- * @num_id: number of aliases to unregister
- *
- * Unregister aliases registered with
- * devm_regulator_bulk_register_supply_alias(). Normally this function
- * will not need to be called and the resource management code
- * will ensure that the resource is freed.
- */
-void devm_regulator_bulk_unregister_supply_alias(struct device *dev,
-						 const char *const *id,
-						 int num_id)
-{
-	int i;
-
-	for (i = 0; i < num_id; ++i)
-		devm_regulator_unregister_supply_alias(dev, id[i]);
-}
-EXPORT_SYMBOL_GPL(devm_regulator_bulk_unregister_supply_alias);
-
 struct regulator_notifier_match {
 	struct regulator *regulator;
 	struct notifier_block *nb;
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index fb653d2a11f0..10ff6b66ca9e 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -230,9 +230,6 @@ int devm_regulator_bulk_register_supply_alias(struct device *dev,
 					      struct device *alias_dev,
 					      const char *const *alias_id,
 					      int num_id);
-void devm_regulator_bulk_unregister_supply_alias(struct device *dev,
-						 const char *const *id,
-						 int num_id);
 
 /* regulator output control and status */
 int __must_check regulator_enable(struct regulator *regulator);
@@ -420,11 +417,6 @@ static inline int devm_regulator_bulk_register_supply_alias(struct device *dev,
 	return 0;
 }
 
-static inline void devm_regulator_bulk_unregister_supply_alias(
-	struct device *dev, const char *const *id, int num_id)
-{
-}
-
 static inline int regulator_enable(struct regulator *regulator)
 {
 	return 0;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] regulator: devres: unexport devm_regulator_unregister_supply_alias()
  2021-06-25 12:23 [PATCH 0/4] regulator: devres: remove unused device-managed unregister APIs Alexandru Ardelean
                   ` (2 preceding siblings ...)
  2021-06-25 12:23 ` [PATCH 3/4] regulator: devres: remove devm_regulator_bulk_unregister_supply_alias() Alexandru Ardelean
@ 2021-06-25 12:23 ` Alexandru Ardelean
  2021-07-12 10:45 ` [PATCH 0/4] regulator: devres: remove unused device-managed unregister APIs Mark Brown
  4 siblings, 0 replies; 6+ messages in thread
From: Alexandru Ardelean @ 2021-06-25 12:23 UTC (permalink / raw)
  To: linux-kernel; +Cc: lgirdwood, broonie, Alexandru Ardelean

This API hook isn't used anywhere outside of the regulator devres code.
This function is needed for the devm_regulator_bulk_register_supply_alias()
function on the error path, to cleanup any previously registered supply
aliases.

This change makes the devm_regulator_unregister_supply_alias() local to the
regulator core framework, to avoid it being used in any weird logic.
It's also removing the doc-string for
devm_regulator_unregister_supply_alias(), since it doesn't need to be
documented anymore, as no other external consumer should use it.

Signed-off-by: Alexandru Ardelean <aardelean@deviqon.com>
---
 drivers/regulator/devres.c         | 16 ++--------------
 include/linux/regulator/consumer.h |  7 -------
 2 files changed, 2 insertions(+), 21 deletions(-)

diff --git a/drivers/regulator/devres.c b/drivers/regulator/devres.c
index 007855ae165b..826c29499d69 100644
--- a/drivers/regulator/devres.c
+++ b/drivers/regulator/devres.c
@@ -267,19 +267,8 @@ int devm_regulator_register_supply_alias(struct device *dev, const char *id,
 }
 EXPORT_SYMBOL_GPL(devm_regulator_register_supply_alias);
 
-/**
- * devm_regulator_unregister_supply_alias - Resource managed
- * regulator_unregister_supply_alias()
- *
- * @dev: device to supply
- * @id:  supply name or regulator ID
- *
- * Unregister an alias registered with
- * devm_regulator_register_supply_alias(). 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_supply_alias(struct device *dev, const char *id)
+static void devm_regulator_unregister_supply_alias(struct device *dev,
+						   const char *id)
 {
 	struct regulator_supply_alias_match match;
 	int rc;
@@ -292,7 +281,6 @@ void devm_regulator_unregister_supply_alias(struct device *dev, const char *id)
 	if (rc != 0)
 		WARN_ON(rc);
 }
-EXPORT_SYMBOL_GPL(devm_regulator_unregister_supply_alias);
 
 /**
  * devm_regulator_bulk_register_supply_alias - Managed register
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 10ff6b66ca9e..d5441345d024 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -222,8 +222,6 @@ void regulator_bulk_unregister_supply_alias(struct device *dev,
 int devm_regulator_register_supply_alias(struct device *dev, const char *id,
 					 struct device *alias_dev,
 					 const char *alias_id);
-void devm_regulator_unregister_supply_alias(struct device *dev,
-					    const char *id);
 
 int devm_regulator_bulk_register_supply_alias(struct device *dev,
 					      const char *const *id,
@@ -403,11 +401,6 @@ static inline int devm_regulator_register_supply_alias(struct device *dev,
 	return 0;
 }
 
-static inline void devm_regulator_unregister_supply_alias(struct device *dev,
-							  const char *id)
-{
-}
-
 static inline int devm_regulator_bulk_register_supply_alias(struct device *dev,
 						const char *const *id,
 						struct device *alias_dev,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/4] regulator: devres: remove unused device-managed unregister APIs
  2021-06-25 12:23 [PATCH 0/4] regulator: devres: remove unused device-managed unregister APIs Alexandru Ardelean
                   ` (3 preceding siblings ...)
  2021-06-25 12:23 ` [PATCH 4/4] regulator: devres: unexport devm_regulator_unregister_supply_alias() Alexandru Ardelean
@ 2021-07-12 10:45 ` Mark Brown
  4 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2021-07-12 10:45 UTC (permalink / raw)
  To: Alexandru Ardelean, linux-kernel; +Cc: Mark Brown, lgirdwood

On Fri, 25 Jun 2021 15:23:20 +0300, Alexandru Ardelean wrote:
> These APIs aren't used anywhere and most-likely exist 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.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next

Thanks!

[1/4] regulator: devres: remove devm_regulator_unregister_notifier() function
      (no commit info)
[2/4] regulator: devres: remove devm_regulator_unregister() function
      commit: 4ff75a29976590bc7afe3ed75d547c1f2a924c75
[3/4] regulator: devres: remove devm_regulator_bulk_unregister_supply_alias()
      commit: eed43b96ede9c3f018ad24149de83f24b86ad729
[4/4] regulator: devres: unexport devm_regulator_unregister_supply_alias()
      commit: 4d9f4d1de3ceb84fa6ce68177a26b8fac6a71290

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-07-12 10:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 2/4] regulator: devres: remove devm_regulator_unregister() function Alexandru Ardelean
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

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).