mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] regulator: core: Limit propagation of parent voltage count and list
@ 2017-03-27 21:22 Matthias Kaehlcke
  2017-03-28  4:20 ` kbuild test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Matthias Kaehlcke @ 2017-03-27 21:22 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Javier Martinez Canillas
  Cc: linux-kernel, Douglas Anderson, Brian Norris, Matthias Kaehlcke

Change 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.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
Changes in v2:
 - Added flag 'is_switch' that indicates if regulator is a switch
 - Reworked conditions checking for switch to evaluate the new flag

 drivers/regulator/core.c         | 11 +++++++++--
 include/linux/regulator/driver.h |  2 ++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 53d4fc70dbd0..c81b4f608559 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2486,7 +2486,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;
@@ -2540,11 +2540,12 @@ EXPORT_SYMBOL_GPL(regulator_is_enabled);
 int regulator_count_voltages(struct regulator *regulator)
 {
 	struct regulator_dev	*rdev = regulator->rdev;
+	const struct regulator_ops *ops = rdev->desc->ops;
 
 	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);
@@ -4099,6 +4100,12 @@ regulator_register(const struct regulator_desc *regulator_desc,
 		mutex_unlock(&regulator_list_mutex);
 	}
 
+	if (!rdev->desc->ops->get_voltage &&
+	    !rdev->desc->ops->get_voltage_sel &&
+	    !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);
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 {
 	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;
 };
-- 
2.12.2.564.g063fe858b8-goog

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] regulator: core: Limit propagation of parent voltage count and list
  2017-03-27 21:22 [PATCH v2] regulator: core: Limit propagation of parent voltage count and list Matthias Kaehlcke
@ 2017-03-28  4:20 ` kbuild test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2017-03-28  4:20 UTC (permalink / raw)
  To: Matthias Kaehlcke
  Cc: kbuild-all, Liam Girdwood, Mark Brown, Javier Martinez Canillas,
	linux-kernel, Douglas Anderson, Brian Norris, Matthias Kaehlcke

[-- Attachment #1: Type: text/plain, Size: 1865 bytes --]

Hi Matthias,

[auto build test WARNING on regulator/for-next]
[also build test WARNING on v4.11-rc4 next-20170327]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Matthias-Kaehlcke/regulator-core-Limit-propagation-of-parent-voltage-count-and-list/20170328-095816
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git for-next
config: x86_64-randconfig-s0-03281146 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers//regulator/core.c: In function 'regulator_count_voltages':
>> drivers//regulator/core.c:2543: warning: unused variable 'ops'

vim +/ops +2543 drivers//regulator/core.c

  2527	
  2528		return ret;
  2529	}
  2530	EXPORT_SYMBOL_GPL(regulator_is_enabled);
  2531	
  2532	/**
  2533	 * regulator_count_voltages - count regulator_list_voltage() selectors
  2534	 * @regulator: regulator source
  2535	 *
  2536	 * Returns number of selectors, or negative errno.  Selectors are
  2537	 * numbered starting at zero, and typically correspond to bitfields
  2538	 * in hardware registers.
  2539	 */
  2540	int regulator_count_voltages(struct regulator *regulator)
  2541	{
  2542		struct regulator_dev	*rdev = regulator->rdev;
> 2543		const struct regulator_ops *ops = rdev->desc->ops;
  2544	
  2545		if (rdev->desc->n_voltages)
  2546			return rdev->desc->n_voltages;
  2547	
  2548		if (!rdev->is_switch || !rdev->supply)
  2549			return -EINVAL;
  2550	
  2551		return regulator_count_voltages(rdev->supply);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 22079 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-03-28  4:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-27 21:22 [PATCH v2] regulator: core: Limit propagation of parent voltage count and list Matthias Kaehlcke
2017-03-28  4:20 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®