Regulator deadcode cleanups
Subsystems (3)
cover Regulator deadcode cleanups
From: "Dr. David Alan Gilbert" <[email protected]>
Hi,
This is a bunch of deadcode cleanups for functions
that are unused (for quite some time).
The first patch was originally sent in October last
year but didn't get any traction; the rest are new.
Dave
Dr. David Alan Gilbert (5):
regulator: devres: Remove unused
devm_regulator_bulk_register_supply_alias
regulator: core: Remove unused regulator_bulk_force_disable
regulator: core: Remove unused regulator_*drvdata functions
regulator: core: Remove unused regulator_suspend_(disable|enable)
regulator: core: Remove unused regulator_set_suspend_voltage
.../driver-api/driver-model/devres.rst | 1 - drivers/regulator/core.c | 141 ------------------ drivers/regulator/devres.c | 74 --------- include/linux/regulator/consumer.h | 47 ------ include/linux/regulator/driver.h | 1 - 5 files changed, 264 deletions(-)
Signature · 1 line
2.49.0
PATCH 1/5 regulator: devres: Remove unused devm_regulator_bulk_register_supply_alias
From: "Dr. David Alan Gilbert" <[email protected]>
devm_regulator_bulk_register_supply_alias() has been unused since 2014's commit d137be00ee01 ("mfd: core: Don't use devres functions before device is added")
Remove it, and the static helpers only it used.
--- .../driver-api/driver-model/devres.rst | 1 - drivers/regulator/devres.c | 74 ------------------- include/linux/regulator/consumer.h | 6 -- 3 files changed, 81 deletions(-)
Documentation/driver-api/driver-model/devres.rst +0 -1
@@ -424,7 +424,6 @@ PWM devm_fwnode_pwm_get() REGULATOR - devm_regulator_bulk_register_supply_alias() devm_regulator_bulk_get() devm_regulator_bulk_get_const() devm_regulator_bulk_get_enable()
drivers/regulator/devres.c +0 -74
86 lines not on this page · raw message
include/linux/regulator/consumer.h +0 -6
@@ -185,12 +185,6 @@ int devm_regulator_register_supply_alias(struct device *dev, const char *id,struct device *alias_dev, const char *alias_id); -int devm_regulator_bulk_register_supply_alias (struct device *dev, -const char *const *id, -struct device *alias_dev, -const char *const *alias_id, -int num_id); -/* regulator output control and status */ int __must_check regulator_enable (struct regulator *regulator);int regulator_disable (struct regulator *regulator);
Signature · 1 line
2.49.0
PATCH 2/5 regulator: core: Remove unused regulator_bulk_force_disable
In reply to [email protected]From: "Dr. David Alan Gilbert" <[email protected]>
regulator_bulk_force_disable() was explicitly added in 2012 by commit e1de2f423462 ("regulator: add regulator_bulk_force_disable function")
but hasn't been used.
Remove it.
--- drivers/regulator/core.c | 34 ------------------------------ include/linux/regulator/consumer.h | 8 ------- 2 files changed, 42 deletions(-)
drivers/regulator/core.c +0 -34
@@ -5196,40 +5196,6 @@ int regulator_bulk_disable(int num_consumers, }EXPORT_SYMBOL_GPL (regulator_bulk_disable); -/** -* regulator_bulk_force_disable - force disable multiple regulator consumers -* -* @num_consumers: Number of consumers -* @consumers: Consumer data; clients are stored here. -* -* This convenience API allows consumers to forcibly disable multiple regulator -* clients in a single API call. -* NOTE: This should be used for situations when device damage will -* likely occur if the regulators are not disabled (e.g. over temp). -* Although regulator_force_disable function call for some consumers can -* return error numbers, the function is called for all consumers. -* -* Return: 0 on success or a negative error number on failure. -*/ -int regulator_bulk_force_disable (int num_consumers, -struct regulator_bulk_data *consumers) -{ -int i; -int ret =0 ; - -for (i =0 ; i < num_consumers; i++) { - consumers[i].ret = -regulator_force_disable (consumers[i].consumer); - -/* Store first error for reporting */ -if (consumers[i].ret && !ret) - ret = consumers[i].ret; - } - -return ret; -} -EXPORT_SYMBOL_GPL (regulator_bulk_force_disable); -/** * regulator_bulk_free - free multiple regulator consumers *
include/linux/regulator/consumer.h +0 -8
@@ -209,8 +209,6 @@ int devm_regulator_bulk_get_enable(struct device *dev, int num_consumers, const char * const *id);int regulator_bulk_disable (int num_consumers,struct regulator_bulk_data *consumers); -int regulator_bulk_force_disable (int num_consumers, -struct regulator_bulk_data *consumers);void regulator_bulk_free (int num_consumers,struct regulator_bulk_data *consumers);
@@ -470,12 +468,6 @@ static inline int regulator_bulk_disable(int num_consumers,return 0 ; } -static inline int regulator_bulk_force_disable (int num_consumers, -struct regulator_bulk_data *consumers) -{ -return 0 ; -} -static inline void regulator_bulk_free (int num_consumers,struct regulator_bulk_data *consumers) {
Signature · 1 line
2.49.0
PATCH 3/5 regulator: core: Remove unused regulator_*drvdata functions
In reply to [email protected]From: "Dr. David Alan Gilbert" <[email protected]>
regulator_get_init_drvdata() was added in 2008 by the
commit a5766f11cfd3 ("regulator: core - Rework machine API to remove string based functions.")regulator_set_drvdata() was also added in 2008 by the
commit 414c70cb91c4 ("regulator: regulator framework core")
neither have been used since,
Remove them.
--- drivers/regulator/core.c | 17 ----------------- include/linux/regulator/consumer.h | 6 ------ include/linux/regulator/driver.h | 1 - 3 files changed, 24 deletions(-)
drivers/regulator/core.c +0 -17
@@ -6096,17 +6096,6 @@ void *regulator_get_drvdata(struct regulator *regulator) }EXPORT_SYMBOL_GPL (regulator_get_drvdata); -/** -* regulator_set_drvdata - set regulator driver data -* @regulator: regulator -* @data: data -*/ -void regulator_set_drvdata (struct regulator *regulator,void *data) -{ - regulator->rdev->reg_data = data; -} -EXPORT_SYMBOL_GPL (regulator_set_drvdata); -/** * rdev_get_id - get regulator ID * @rdev: regulator
@@ -6131,12 +6120,6 @@ struct regmap *rdev_get_regmap(struct regulator_dev *rdev) }EXPORT_SYMBOL_GPL (rdev_get_regmap); -void *regulator_get_init_drvdata (struct regulator_init_data *reg_init_data) -{ -return reg_init_data->driver_data; -} -EXPORT_SYMBOL_GPL (regulator_get_init_drvdata); -#ifdef CONFIG_DEBUG_FS static int supply_map_show (struct seq_file *sf,void *data) {
include/linux/regulator/consumer.h +0 -6
@@ -267,7 +267,6 @@ int regulator_set_suspend_voltage(struct regulator *regulator, int min_uV,/* driver data - core doesn't touch */ void *regulator_get_drvdata (struct regulator *regulator); -void regulator_set_drvdata (struct regulator *regulator,void *data);/* misc helpers */
@@ -633,11 +632,6 @@ static inline void *regulator_get_drvdata(struct regulator *regulator)return NULL ; } -static inline void regulator_set_drvdata (struct regulator *regulator, -void *data) -{ -} -static inline int regulator_count_voltages (struct regulator *regulator) {return 0 ;
include/linux/regulator/driver.h +0 -1
@@ -765,7 +765,6 @@ int regulator_set_active_discharge_regmap(struct regulator_dev *rdev,int regulator_set_current_limit_regmap (struct regulator_dev *rdev,int min_uA,int max_uA);int regulator_get_current_limit_regmap (struct regulator_dev *rdev); -void *regulator_get_init_drvdata (struct regulator_init_data *reg_init_data);int regulator_find_closest_bigger (unsigned int target,const unsigned int *table,unsigned int num_sel,unsigned int *sel);int regulator_set_ramp_delay_regmap (struct regulator_dev *rdev,int ramp_delay);
Signature · 1 line
2.49.0
PATCH 4/5 regulator: core: Remove unused regulator_suspend_(disable|enable)
In reply to [email protected]From: "Dr. David Alan Gilbert" <[email protected]>
regulator_suspend_disable() and regulator_suspend_enable() were added by 2018's
commit f7efad10b5c4 ("regulator: add PM suspend and resume hooks")
but have remained unused.
Remove them and their helper function regulator_suspend_toggle().
--- drivers/regulator/core.c | 44 ------------------------------ include/linux/regulator/consumer.h | 16 ----------- 2 files changed, 60 deletions(-)
drivers/regulator/core.c +0 -44
@@ -4244,50 +4244,6 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) }EXPORT_SYMBOL_GPL (regulator_set_voltage); -static inline int regulator_suspend_toggle (struct regulator_dev *rdev, -suspend_state_t state,bool en) -{ -struct regulator_state *rstate; - - rstate =regulator_get_suspend_state (rdev, state); -if (rstate ==NULL ) -return -EINVAL ; - -if (!rstate->changeable) -return -EPERM ; - - rstate->enabled = (en) ?ENABLE_IN_SUSPEND :DISABLE_IN_SUSPEND ; - -return 0 ; -} - -int regulator_suspend_enable (struct regulator_dev *rdev, -suspend_state_t state) -{ -return regulator_suspend_toggle (rdev, state, true); -} -EXPORT_SYMBOL_GPL (regulator_suspend_enable); - -int regulator_suspend_disable (struct regulator_dev *rdev, -suspend_state_t state) -{ -struct regulator *regulator; -struct regulator_voltage *voltage; - -/* -* if any consumer wants this regulator device keeping on in -* suspend states, don't set it as disabled. -*/ -list_for_each_entry (regulator, &rdev->consumer_list, list) { - voltage = ®ulator->voltage[state]; -if (voltage->min_uV || voltage->max_uV) -return 0 ; - } - -return regulator_suspend_toggle (rdev, state, false); -} -EXPORT_SYMBOL_GPL (regulator_suspend_disable); -static int _regulator_set_suspend_voltage (struct regulator *regulator,int min_uV,int max_uV,suspend_state_t state)
include/linux/regulator/consumer.h +0 -16
@@ -258,10 +258,6 @@ void devm_regulator_unregister_notifier(struct regulator *regulator, struct notifier_block *nb);/* regulator suspend */ -int regulator_suspend_enable (struct regulator_dev *rdev, -suspend_state_t state); -int regulator_suspend_disable (struct regulator_dev *rdev, -suspend_state_t state);int regulator_set_suspend_voltage (struct regulator *regulator,int min_uV,int max_uV,suspend_state_t state);
@@ -608,18 +604,6 @@ static inline int devm_regulator_unregister_notifier(struct regulator *regulatorreturn 0 ; } -static inline int regulator_suspend_enable (struct regulator_dev *rdev, -suspend_state_t state) -{ -return -EINVAL ; -} - -static inline int regulator_suspend_disable (struct regulator_dev *rdev, -suspend_state_t state) -{ -return -EINVAL ; -} -static inline int regulator_set_suspend_voltage (struct regulator *regulator,int min_uV,int max_uV,suspend_state_t state)
Signature · 1 line
2.49.0
PATCH 5/5 regulator: core: Remove unused regulator_set_suspend_voltage
In reply to [email protected]From: "Dr. David Alan Gilbert" <[email protected]>
regulator_set_suspend_voltage() was added as part of 2018's commit f7efad10b5c4 ("regulator: add PM suspend and resume hooks") but is unused.
Remove it, and the helpers it's the only user of.
--- drivers/regulator/core.c | 46 ------------------------------ include/linux/regulator/consumer.h | 11 ------- 2 files changed, 57 deletions(-)
drivers/regulator/core.c +0 -46
@@ -446,12 +446,6 @@ int regulator_check_voltage(struct regulator_dev *rdev,return 0 ; } -/* return 0 if the state is valid */ -static int regulator_check_states (suspend_state_t state) -{ -return (state >PM_SUSPEND_MAX || state ==PM_SUSPEND_TO_IDLE ); -} -/* Make sure we select a voltage that suits the needs of all * regulator consumers */
@@ -4244,46 +4238,6 @@ int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) }EXPORT_SYMBOL_GPL (regulator_set_voltage); -static int _regulator_set_suspend_voltage (struct regulator *regulator, -int min_uV,int max_uV, -suspend_state_t state) -{ -struct regulator_dev *rdev = regulator->rdev; -struct regulator_state *rstate; - - rstate =regulator_get_suspend_state (rdev, state); -if (rstate ==NULL ) -return -EINVAL ; - -if (rstate->min_uV == rstate->max_uV) { -rdev_err (rdev,"The suspend voltage can't be changed!\n" ); -return -EPERM ; - } - -return regulator_set_voltage_unlocked (regulator, min_uV, max_uV, state); -} - -int regulator_set_suspend_voltage (struct regulator *regulator,int min_uV, -int max_uV,suspend_state_t state) -{ -struct ww_acquire_ctx ww_ctx; -int ret; - -/* PM_SUSPEND_ON is handled by regulator_set_voltage() */ -if (regulator_check_states (state) || state ==PM_SUSPEND_ON ) -return -EINVAL ; - -regulator_lock_dependent (regulator->rdev, &ww_ctx); - - ret =_regulator_set_suspend_voltage (regulator, min_uV, - max_uV, state); - -regulator_unlock_dependent (regulator->rdev, &ww_ctx); - -return ret; -} -EXPORT_SYMBOL_GPL (regulator_set_suspend_voltage); -/** * regulator_set_voltage_time - get raise/fall time * @regulator: regulator source
include/linux/regulator/consumer.h +0 -11
@@ -257,10 +257,6 @@ int regulator_unregister_notifier(struct regulator *regulator,void devm_regulator_unregister_notifier (struct regulator *regulator,struct notifier_block *nb); -/* regulator suspend */ -int regulator_set_suspend_voltage (struct regulator *regulator,int min_uV, -int max_uV,suspend_state_t state); -/* driver data - core doesn't touch */ void *regulator_get_drvdata (struct regulator *regulator);
@@ -604,13 +600,6 @@ static inline int devm_regulator_unregister_notifier(struct regulator *regulatorreturn 0 ; } -static inline int regulator_set_suspend_voltage (struct regulator *regulator, -int min_uV,int max_uV, -suspend_state_t state) -{ -return -EINVAL ; -} -static inline void *regulator_get_drvdata (struct regulator *regulator) {return NULL ;
Signature · 1 line
2.49.0
Mark Brown
maintainerQuoted 4 lines · On Sat, Apr 26, 2025 at 06:51:38PM +0100, [email protected] wrote:
This is a bunch of deadcode cleanups for functions
that are unused (for quite some time).
The first patch was originally sent in October last
year but didn't get any traction; the rest are new.
Please do some analysis as to why the functions are there, don't just blindly delete things.
Quoted 9 lines · * Mark Brown ([email protected]) wrote:
Quoted 4 lines · On Sat, Apr 26, 2025 at 06:51:38PM +0100, [email protected] wrote:
This is a bunch of deadcode cleanups for functions
that are unused (for quite some time).
The first patch was originally sent in October last
year but didn't get any traction; the rest are new.Please do some analysis as to why the functions are there, don't just blindly delete things.
I'd appreciate some more idea of what you're after; each patch shows where and when the function was added or last used. Some have comments saying things like the devm_ version is being used (so it seemed reasonable to me to delete the plain version if no one uses it).
For each one I've checked _when_ it was last used and not deleted anything that's been used in the last few years; I've not deleted anything which has been recently added or only recently unused.
That level seems to have been fine on the other ~300 clean up patches other maintainers have taken; you seem to be after something different - I'm fine to add that if you can just explain what you want.
Just point me in the right direction and I can have more of a dig.
Dave
Signature · 4 lines
-----Open up your eyes, open up your mind, open up your code ------- / Dr. David Alan Gilbert | Running GNU/Linux | Happy \ \ dave @ treblig.org | | In Hex / \ _________________________|_____ http://www.treblig.org |_______/
Mark Brown
maintainerQuoted 7 lines · Dr. David Alan Gilbert
Quoted 2 lines · * Mark Brown ([email protected]) wrote:
Please do some analysis as to why the functions are there, don't just blindly delete things.
I'd appreciate some more idea of what you're after; each patch shows where and when the function was added or last used. Some have
Something that indicates that this is a patch written by a human rather than some automated noise, that considers things like API usability and coherence, or what people might do if the API is not available when they need it, rather than just mechanically churning something out. None of your commit logs consider what the code you're deleting does at all.
Quoted 2 lines
comments saying things like the
devm_version is being used (so it seemed reasonable to me to delete the plain version if no one uses it).
Deleting the plain version of something where a devm version exists is an obvious example of making the API less coherent and hard to use, managed resources aren't universally appropriate and so you should generally be able to do the same thing with manual resource management.
Quoted 6 lines · * Mark Brown ([email protected]) wrote:
Quoted 4 lines · Dr. David Alan Gilbert
Quoted 2 lines · * Mark Brown ([email protected]) wrote:
Please do some analysis as to why the functions are there, don't just blindly delete things.
Quoted 8 lines
Quoted 2 lines
I'd appreciate some more idea of what you're after; each patch shows where and when the function was added or last used. Some have
Something that indicates that this is a patch written by a human rather than some automated noise, that considers things like API usability and coherence, or what people might do if the API is not available when they need it, rather than just mechanically churning something out. None of your commit logs consider what the code you're deleting does at all.
I do manually write each patch, but I don't have that global feel of the API; but I do use my judgement to avoid some things:
* I tend not to remove one side of an obvious pair of functions (e.g. a set/clear or an alloc/free)
* I avoid things that look like a function for every firmware interface where the functions are almost documenting the interface.
* I only bother deleting one line functions if it's part of a set.
and some others. It's not automatic, but I don't claim to understand the whole interface. I will try and follow a thread if I end up deleting something which then makes it look like something else isn't needed. I do have _some_ feel - so have spotted some bugs where a function should have been called.
Quoted 7 lines
Quoted 2 lines
comments saying things like the
devm_version is being used (so it seemed reasonable to me to delete the plain version if no one uses it).Deleting the plain version of something where a devm version exists is an obvious example of making the API less coherent and hard to use, managed resources aren't universally appropriate and so you should generally be able to do the same thing with manual resource management.
OK, that's something I hadn't expected - I'd thought if one style was used for many years, that the other was redundant.
It can be quite tricky to see why functions have ended up not being used for years (or decades), some is making a nice API, but sometimes it's people blindly copying another API or who had a set of patches which used the function but those patches got abandoned.
It also varies a lot between maintainer - some really prefer not to have unused functions at all.
Dave
Signature · 4 lines
-----Open up your eyes, open up your mind, open up your code ------- / Dr. David Alan Gilbert | Running GNU/Linux | Happy \ \ dave @ treblig.org | | In Hex / \ _________________________|_____ http://www.treblig.org |_______/