linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH RFC 1/2] regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage
@ 2012-06-07  2:05 Axel Lin
  2012-06-07  2:06 ` [PATCH RFC 2/2] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops Axel Lin
  2012-06-07 23:27 ` [PATCH RFC 1/2] regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-06-07  2:05 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marek Vasut, Liam Girdwood, Mark Brown

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

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/core.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 02c1940..876f5fc 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2070,6 +2070,14 @@ int regulator_map_voltage_linear(struct regulator_dev *rdev,
 {
 	int ret, voltage;
 
+	/* Allow uV_step to be 0 for fixed voltage */
+	if (rdev->desc->n_voltages == 1 && rdev->desc->uV_step == 0) {
+		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] 3+ messages in thread

* [PATCH RFC 2/2] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops
  2012-06-07  2:05 [PATCH RFC 1/2] regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage Axel Lin
@ 2012-06-07  2:06 ` Axel Lin
  2012-06-07 23:27 ` [PATCH RFC 1/2] regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Axel Lin @ 2012-06-07  2:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: Marek Vasut, Liam Girdwood, Mark Brown

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/regulator/isl6271a-regulator.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/regulator/isl6271a-regulator.c b/drivers/regulator/isl6271a-regulator.c
index 56d273f..4a11b82a 100644
--- a/drivers/regulator/isl6271a-regulator.c
+++ b/drivers/regulator/isl6271a-regulator.c
@@ -75,19 +75,13 @@ static struct regulator_ops isl_core_ops = {
 
 static int isl6271a_get_fixed_voltage(struct regulator_dev *dev)
 {
-	int id = rdev_get_id(dev);
-	return (id == 1) ? 1100000 : 1300000;
-}
-
-static int isl6271a_list_fixed_voltage(struct regulator_dev *dev, unsigned selector)
-{
-	int id = rdev_get_id(dev);
-	return (id == 1) ? 1100000 : 1300000;
+	return dev->desc->min_uV;
 }
 
 static struct regulator_ops isl_fixed_ops = {
 	.get_voltage	= isl6271a_get_fixed_voltage,
-	.list_voltage	= isl6271a_list_fixed_voltage,
+	.list_voltage	= regulator_list_voltage_linear,
+	.map_voltage	= regulator_map_voltage_linear,
 };
 
 static const struct regulator_desc isl_rd[] = {
@@ -107,6 +101,7 @@ static const struct regulator_desc isl_rd[] = {
 		.ops		= &isl_fixed_ops,
 		.type		= REGULATOR_VOLTAGE,
 		.owner		= THIS_MODULE,
+		.min_uV		= 1100000,
 	}, {
 		.name		= "LDO2",
 		.id		= 2,
@@ -114,6 +109,7 @@ static const struct regulator_desc isl_rd[] = {
 		.ops		= &isl_fixed_ops,
 		.type		= REGULATOR_VOLTAGE,
 		.owner		= THIS_MODULE,
+		.min_uV		= 1300000,
 	},
 };
 
-- 
1.7.9.5




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

* Re: [PATCH RFC 1/2] regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage
  2012-06-07  2:05 [PATCH RFC 1/2] regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage Axel Lin
  2012-06-07  2:06 ` [PATCH RFC 2/2] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops Axel Lin
@ 2012-06-07 23:27 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-06-07 23:27 UTC (permalink / raw)
  To: Axel Lin; +Cc: linux-kernel, Marek Vasut, Liam Girdwood

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

On Thu, Jun 07, 2012 at 10:05:14AM +0800, Axel Lin wrote:
> Fixed voltage is a kind of linear mapping where n_voltages is 1 and uV_step is
> 0. This change allows [list|map]_voltage_linear to be used for fixed voltage.

Applied all, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-07  2:05 [PATCH RFC 1/2] regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage Axel Lin
2012-06-07  2:06 ` [PATCH RFC 2/2] regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops Axel Lin
2012-06-07 23:27 ` [PATCH RFC 1/2] regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).