regulator: devres: remove unused device-managed unregister APIs
cover 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(-)
Signature · 1 line
2.31.1
PATCH 1/4 regulator: devres: remove devm_regulator_unregister_notifier() function
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.
--- drivers/regulator/devres.c | 36 ------------------------------ include/linux/regulator/consumer.h | 8 ------- 2 files changed, 44 deletions(-)
drivers/regulator/devres.c +0 -36
@@ -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);
include/linux/regulator/consumer.h +0 -8
@@ -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) {
Signature · 1 line
2.31.1
PATCH 2/4 regulator: devres: remove devm_regulator_unregister() function
In reply to Alexandru ArdeleanThis 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.
--- drivers/regulator/devres.c | 29 ----------------------------- include/linux/regulator/driver.h | 1 - 2 files changed, 30 deletions(-)
drivers/regulator/devres.c +0 -29
@@ -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;
include/linux/regulator/driver.h +0 -1
@@ -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);
Signature · 1 line
2.31.1
PATCH 3/4 regulator: devres: remove devm_regulator_bulk_unregister_supply_alias()
In reply to Alexandru ArdeleanThis 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.
--- drivers/regulator/devres.c | 24 ------------------------ include/linux/regulator/consumer.h | 8 -------- 2 files changed, 32 deletions(-)
drivers/regulator/devres.c +0 -24
@@ -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;
include/linux/regulator/consumer.h +0 -8
@@ -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 ;
Signature · 1 line
2.31.1
PATCH 4/4 regulator: devres: unexport devm_regulator_unregister_supply_alias()
In reply to Alexandru ArdeleanThis 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.
--- drivers/regulator/devres.c | 16 ++-------------- include/linux/regulator/consumer.h | 7 ------- 2 files changed, 2 insertions(+), 21 deletions(-)
drivers/regulator/devres.c +2 -14
@@ -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
include/linux/regulator/consumer.h +0 -7
@@ -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,
Signature · 1 line
2.31.1
Mark Brown
maintainerQuoted 10 lines · 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 ondrivers/systemde-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: 4d9f4d1de3ceb84fa6ce68177a26b8fac6a71290All 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