Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd086045 authored by Matthias Kaehlcke's avatar Matthias Kaehlcke Committed by Mark Brown
Browse files

regulator: core: Limit propagation of parent voltage count and list



Commit 26988efe ("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: 26988efe ("regulator: core: Allow to get voltage count and
  list from parent")
Signed-off-by: default avatarMatthias Kaehlcke <mka@chromium.org>
Reviewed-by: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
Tested-by: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent fffd1133
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -2484,7 +2484,7 @@ static int _regulator_list_voltage(struct regulator *regulator,
		ret = ops->list_voltage(rdev, selector);
		if (lock)
			mutex_unlock(&rdev->mutex);
	} else if (rdev->supply) {
	} else if (rdev->is_switch && rdev->supply) {
		ret = _regulator_list_voltage(rdev->supply, selector, lock);
	} else {
		return -EINVAL;
@@ -2542,7 +2542,7 @@ int regulator_count_voltages(struct regulator *regulator)
	if (rdev->desc->n_voltages)
		return rdev->desc->n_voltages;

	if (!rdev->supply)
	if (!rdev->is_switch || !rdev->supply)
		return -EINVAL;

	return regulator_count_voltages(rdev->supply);
@@ -4097,6 +4097,11 @@ regulator_register(const struct regulator_desc *regulator_desc,
		mutex_unlock(&regulator_list_mutex);
	}

	if (!rdev->desc->ops->get_voltage &&
	    !rdev->desc->ops->list_voltage &&
	    !rdev->desc->fixed_uV)
		rdev->is_switch = true;

	ret = device_register(&rdev->dev);
	if (ret != 0) {
		put_device(&rdev->dev);
+2 −0
Original line number Diff line number Diff line
@@ -429,6 +429,8 @@ struct regulator_dev {
	struct regulator_enable_gpio *ena_pin;
	unsigned int ena_gpio_state:1;

	unsigned int is_switch:1;

	/* time when this regulator was disabled last time */
	unsigned long last_off_jiffy;
};