public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC RESEND 1/3] regulator: core: Handle fixed voltage in map_voltage_linear
@ 2012-06-07  7:01 Axel Lin
  2012-06-07  7:02 ` [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops Axel Lin
  2012-06-07  7:03 ` [PATCH RFC RESEND 3/3] regulator: da903x: Don't read/write to DA9030_INVAL/DA9034_INVAL address Axel Lin
  0 siblings, 2 replies; 5+ messages in thread
From: Axel Lin @ 2012-06-07  7:01 UTC (permalink / raw)
  To: linux-kernel
  Cc: Marek Vasut, Liam Girdwood, Mark Brown, Eric Miao, Mike Rapoport

Fixed voltage is a kind of linear mapping where n_voltages is 1.
This change allows [list|map]_voltage_linear to be used for fixed voltage.

For fixed voltage, n_voltages is 1 and the only valid selector is 0.
Thus we actually don't care the uV_step setting.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
This patch is v2 of 
[PATCH RFC 1/2] regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage.

I change the subject line because for fixed voltage, we actually don't care the uV_step setting.

 drivers/regulator/core.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 02c1940..45baa72 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2070,6 +2070,15 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
 {
 	int ret, voltage;
 
+	/* For fixed voltage, check if voltage falls within specified range */
+	if (rdev->desc->n_voltages == 1) {
+		if (min_uV <= rdev->desc->min_uV &&
+		    rdev->desc->min_uV <= max_uV)
+			return 0;
+		else
+			return -EINVAL;
+	}
+
 	if (!rdev->desc->uV_step) {
 		BUG_ON(!rdev->desc->uV_step);
 		return -EINVAL;
-- 
1.7.9.5




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

end of thread, other threads:[~2012-06-08  0:57 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-07  7:01 [PATCH RFC RESEND 1/3] regulator: core: Handle fixed voltage in map_voltage_linear Axel Lin
2012-06-07  7:02 ` [PATCH RFC RESEND 2/3] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops Axel Lin
2012-06-08  0:08   ` Axel Lin
2012-06-08  0:31     ` Mark Brown
2012-06-07  7:03 ` [PATCH RFC RESEND 3/3] regulator: da903x: Don't read/write to DA9030_INVAL/DA9034_INVAL address Axel Lin

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