[PATCH 1/4] regulator: devres: remove devm_regulator_unregister_notifier() function

From: Alexandru Ardelean
Date: Fri Jun 25 2021 - 08:30:23 EST


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@xxxxxxxxxxx>
---
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