aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Kaehlcke <mka@chromium.org>2017-03-27 19:54:12 -0400
committerMark Brown <broonie@kernel.org>2017-03-29 07:49:38 -0400
commitfd086045559d90cd7854818b4c60a7119eda6231 (patch)
tree395f225c6be480bcb7d0396608540a7225b5b454
parentfffd1133388857f5b4b8c588b41b2ade16c7891c (diff)
regulator: core: Limit propagation of parent voltage count and list
Commit 26988efe11b1 ("regulator: core: Allow to get voltage count and list from parent") introduces the propagation of the parent voltage count and list for regulators that don't provide this information themselves. The goal is to support simple switch regulators, however as a side effect normal continuous regulators can leak details of their supplies and provide consumers with inconsistent information. Limit the propagation of the voltage count and list to switch regulators. Fixes: 26988efe11b1 ("regulator: core: Allow to get voltage count and list from parent") Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-by: Javier Martinez Canillas <javier@osg.samsung.com> Tested-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/core.c9
-rw-r--r--include/linux/regulator/driver.h2
2 files changed, 9 insertions, 2 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index c20b28a63d15..aff302dfab5d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2484,7 +2484,7 @@ static int _regulator_list_voltage(struct regulator *regulator,
2484 ret = ops->list_voltage(rdev, selector); 2484 ret = ops->list_voltage(rdev, selector);
2485 if (lock) 2485 if (lock)
2486 mutex_unlock(&rdev->mutex); 2486 mutex_unlock(&rdev->mutex);
2487 } else if (rdev->supply) { 2487 } else if (rdev->is_switch && rdev->supply) {
2488 ret = _regulator_list_voltage(rdev->supply, selector, lock); 2488 ret = _regulator_list_voltage(rdev->supply, selector, lock);
2489 } else { 2489 } else {
2490 return -EINVAL; 2490 return -EINVAL;
@@ -2542,7 +2542,7 @@ int regulator_count_voltages(struct regulator *regulator)
2542 if (rdev->desc->n_voltages) 2542 if (rdev->desc->n_voltages)
2543 return rdev->desc->n_voltages; 2543 return rdev->desc->n_voltages;
2544 2544
2545 if (!rdev->supply) 2545 if (!rdev->is_switch || !rdev->supply)
2546 return -EINVAL; 2546 return -EINVAL;
2547 2547
2548 return regulator_count_voltages(rdev->supply); 2548 return regulator_count_voltages(rdev->supply);
@@ -4097,6 +4097,11 @@ regulator_register(const struct regulator_desc *regulator_desc,
4097 mutex_unlock(&regulator_list_mutex); 4097 mutex_unlock(&regulator_list_mutex);
4098 } 4098 }
4099 4099
4100 if (!rdev->desc->ops->get_voltage &&
4101 !rdev->desc->ops->list_voltage &&
4102 !rdev->desc->fixed_uV)
4103 rdev->is_switch = true;
4104
4100 ret = device_register(&rdev->dev); 4105 ret = device_register(&rdev->dev);
4101 if (ret != 0) { 4106 if (ret != 0) {
4102 put_device(&rdev->dev); 4107 put_device(&rdev->dev);
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index dac8e7b16bc6..4cb1c9be6073 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -429,6 +429,8 @@ struct regulator_dev {
429 struct regulator_enable_gpio *ena_pin; 429 struct regulator_enable_gpio *ena_pin;
430 unsigned int ena_gpio_state:1; 430 unsigned int ena_gpio_state:1;
431 431
432 unsigned int is_switch:1;
433
432 /* time when this regulator was disabled last time */ 434 /* time when this regulator was disabled last time */
433 unsigned long last_off_jiffy; 435 unsigned long last_off_jiffy;
434}; 436};