[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <1340697707.12992.1.camel@phoenix>
Date: Tue, 26 Jun 2012 16:01:47 +0800
From: Axel Lin <axel.lin@...il.com>
To: linux-kernel@...r.kernel.org
Cc: Mark Brown <broonie@...nsource.wolfsonmicro.com>,
Liam Girdwood <lrg@...com>
Subject: [PATCH] regulator: arizona-micsupp: Fix choosing selector in
arizona_micsupp_map_voltage
ARIZONA_MICSUPP_MAX_SELECTOR is 0x1f
When selector is 0 ... 0x1e, we use below equation:
(selector * 50000) + 1700000;
so the voltage range is 1700000 ... 3200000 uV.
When selector is 0x1f:
voltage = 3300000 uV.
Thus in the map_voltage callback:
If min_uV > 3300000, we should return -EINVAL.
If min_uV > 3200000, selector should be ARIZONA_MICSUPP_MAX_SELECTOR.
Signed-off-by: Axel Lin <axel.lin@...il.com>
---
drivers/regulator/arizona-micsupp.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/regulator/arizona-micsupp.c b/drivers/regulator/arizona-micsupp.c
index 97d85b0..a27421e 100644
--- a/drivers/regulator/arizona-micsupp.c
+++ b/drivers/regulator/arizona-micsupp.c
@@ -54,10 +54,13 @@ static int arizona_micsupp_map_voltage(struct regulator_dev *rdev,
unsigned int voltage;
int selector;
+ if (min_uV > 3300000)
+ return -EINVAL;
+
if (min_uV < 1700000)
min_uV = 1700000;
- if (min_uV >= 3300000)
+ if (min_uV > 3200000)
selector = ARIZONA_MICSUPP_MAX_SELECTOR;
else
selector = DIV_ROUND_UP(min_uV - 1700000, 50000);
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists