Currently regulator_set_voltage() returns zero when support for regulators isn't
present in kernel, i.e. CONFIG_REGULATOR=n.
Make it return -EINVAL to propagate error instead of success here.
Audit of all users of this routine is done to make sure nothing breaks due to
this change.
Signed-off-by: Viresh Kumar <viresh.kumar(a)linaro.org>
---
V1->V2: - New patch as suggested by Mark.
include/linux/regulator/consumer.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index 1a4a8c1..28fa089 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -394,7 +394,7 @@ static inline void regulator_bulk_free(int num_consumers,
static inline int regulator_set_voltage(struct regulator *regulator,
int min_uV, int max_uV)
{
- return 0;
+ return -EINVAL;
}
static inline int regulator_get_voltage(struct regulator *regulator)
--
2.0.0.rc2
From: Mark Brown <broonie(a)linaro.org>
In the spirit of conservatism that governs our general approach to
permissions it is better if we don't touch regulators we weren't explicitly
given permissions to control. This avoids the need to explicitly specify
unknown regulators in DT as always on, if a regulator is not otherwise
involved in software control it can be omitted from the DT.
Regulators explicitly given constraints in DT still need to have an always
on constraint specified as before.
Signed-off-by: Mark Brown <broonie(a)linaro.org>
---
drivers/regulator/core.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index af7a17677f3d..d7f111781867 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -3822,8 +3822,9 @@ static int __init regulator_init_complete(void)
mutex_lock(®ulator_list_mutex);
/* If we have a full configuration then disable any regulators
- * which are not in use or always_on. This will become the
- * default behaviour in the future.
+ * we have permission to change the status for and which are
+ * not in use or always_on. This is effectively the default
+ * for DT and ACPI as they have full constraints.
*/
list_for_each_entry(rdev, ®ulator_list, list) {
ops = rdev->desc->ops;
@@ -3832,6 +3833,9 @@ static int __init regulator_init_complete(void)
if (c && c->always_on)
continue;
+ if (c && !(c->valid_ops_mask & REGULATOR_CHANGE_STATUS))
+ continue;
+
mutex_lock(&rdev->mutex);
if (rdev->use_count)
--
2.0.0.rc4