Skip to contentSkip to conversation

regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage

RFC PATCH Applied Axel Lin 2 participants 3 messages Jun 7, 2012 – Jun 8, 2012 Voltage and current regulator framework

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

RFC PATCH 1/2 regulator: core: Allow uV_step to be 0 for linear mapping if fixed voltage

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.

---
 drivers/regulator/core.c |    8 ++++++++
 1 file changed, 8 insertions(+)
drivers/regulator/core.c +8 -0
index 02c1940..876f5fc 100644
@@ -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;
Signature · 1 line
1.7.9.5
author
#1 lore raw

RFC PATCH 2/2 regulator: isl6271a: Use regulator_[list|map]_voltage_linear for isl_fixed_ops

---
 drivers/regulator/isl6271a-regulator.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/regulator/isl6271a-regulator.c +5 -9
index 56d273f..4a11b82a 100644
@@ -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,
 	},
 };
 
Signature · 1 line
1.7.9.5
Applied
#2 lore raw
In reply to Axel Lin
Quoted 2 lines · Axel Lin

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.