Message ID | 20120203074408.GD1990@pengutronix.de |
---|---|
State | Not Applicable, archived |
Delegated to: | David Miller |
Headers | show |
On Fri, Feb 03, 2012 at 08:44:08AM +0100, Sascha Hauer wrote: > On Fri, Feb 03, 2012 at 01:17:23AM -0200, Fabio Estevam wrote: > > Please advise if I should fix it in Kconfig or defconfig, so that I > > can submit a patch. > If you enable it every device will get a regulator when it requests one. > If for some reason for example the initialization order of your devices > changes and a device gets probed before the corresponding (real) > regulator is registered, then this device will continue with the dummy > regulator and probably won't work. Hrm, yeah - the dummy regulator support will be totally broken by the stuff Grant is working on for fixing the general issues with probe ordering. > We could a) live with this problem and default enable the dummy > regulator. We could also b) apply (a fixed version of) the following > patch which simplifies registration of a dummy regulator. Still it's a There's also options c) set up the regulators for the board and d) don't enable the regulator API if the board doesn't use regulators. > bit annoying to have to fix all users once someone adds regulator > support for a driver. Yeah, it's a shame. I really can't see anything else useful we can do though.
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index d8e6a42..a7a38ba 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -1046,6 +1046,25 @@ static void unset_regulator_supplies(struct regulator_dev *rdev) } } +int regulator_add_dummy_supply(struct regulator_consumer_supply *supply, + int num_supplies) +{ + int i, ret; + + for (i = 0; i < num_supplies; i++) { + ret = set_consumer_device_supply(dummy_regulator_rdev, NULL, + supply[i].dev_name, supply[i].supply); + if (ret) + goto err_out; + } + + return 0; +err_out: + /* FIXME: unset device supply */ + return ret; +} +EXPORT_SYMBOL_GPL(regulator_add_dummy_supply); + #define REG_STR_SIZE 64 static struct regulator *create_regulator(struct regulator_dev *rdev, diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h index ce3127a..89089cd 100644 --- a/include/linux/regulator/machine.h +++ b/include/linux/regulator/machine.h @@ -192,6 +192,8 @@ int regulator_suspend_finish(void); #ifdef CONFIG_REGULATOR void regulator_has_full_constraints(void); void regulator_use_dummy_regulator(void); +int regulator_add_dummy_supply(struct regulator_consumer_supply *supply, + int num_supplies); #else static inline void regulator_has_full_constraints(void) { @@ -200,6 +202,12 @@ static inline void regulator_has_full_constraints(void) static inline void regulator_use_dummy_regulator(void) { } + +static inline int regulator_add_dummy_supply(struct regulator_consumer_supply *supply, + int num_supplies) +{ + return 0; +} #endif #endif