2021-06-25 12:33:43

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH 0/4] regulator: devres: remove unused device-managed unregister APIs

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


2021-06-25 12:34:55

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH 3/4] regulator: devres: remove devm_regulator_bulk_unregister_supply_alias()

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 <[email protected]>
---
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

2021-06-25 12:35:24

by Alexandru Ardelean

[permalink] [raw]
Subject: [PATCH 4/4] regulator: devres: unexport devm_regulator_unregister_supply_alias()

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 <[email protected]>
---
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

2021-07-12 11:13:37

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 0/4] regulator: devres: remove unused device-managed unregister APIs

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