diff options
author | Philipp Zabel <philipp.zabel@gmail.com> | 2009-05-28 15:00:03 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2009-06-15 06:18:27 -0400 |
commit | c8f1e5025ca2fa8e6e037451f3d271e66745a19b (patch) | |
tree | 22d0cc384cee47f639163daa15a1d6dff91da1b4 /drivers/regulator | |
parent | b110a8fb242bc34e4b7686252899ce0fca956e2c (diff) |
regulator/max1586: fix V3 gain calculation integer overflow
On Thu, May 28, 2009 at 10:59 AM, Mark Brown <broonie@opensource.wolfsonmicro.com> wrote:
> On Thu, May 28, 2009 at 07:15:16AM +0200, Philipp Zabel wrote:
>> The V3 regulator can be configured with an external resistor
>> connected to the feedback pin (R24 in the data sheet) to
>> increase the voltage range.
>>
>> For example, hx4700 has R24 = 3.32 kOhm to achieve a maximum
>> V3 voltage of 1.55 V which is needed for 624 MHz CPU frequency.
>>
>> Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
>
> Looks good.
>
> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Thanks, but it turns out I hit a 32 bit integer overflow in
the gain calculation. I'd like to mend that with the following
patch. Now max_uV could be increased up to 4.294 V, enough to
charge LiPo cells.
Signed-off-by: Philipp Zabel <philipp.zabel@gmail.com>
Acked-by: Robert Jarzmik <robert.jarzmik@free.fr>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'drivers/regulator')
-rw-r--r-- | drivers/regulator/max1586.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index 92799f40c864..2c082d3ef484 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c | |||
@@ -40,8 +40,8 @@ struct max1586_data { | |||
40 | struct i2c_client *client; | 40 | struct i2c_client *client; |
41 | 41 | ||
42 | /* min/max V3 voltage */ | 42 | /* min/max V3 voltage */ |
43 | int min_uV; | 43 | unsigned int min_uV; |
44 | int max_uV; | 44 | unsigned int max_uV; |
45 | 45 | ||
46 | struct regulator_dev *rdev[0]; | 46 | struct regulator_dev *rdev[0]; |
47 | }; | 47 | }; |
@@ -199,8 +199,8 @@ static int max1586_pmic_probe(struct i2c_client *client, | |||
199 | ret = -EINVAL; | 199 | ret = -EINVAL; |
200 | goto out_unmap; | 200 | goto out_unmap; |
201 | } | 201 | } |
202 | max1586->min_uV = MAX1586_V3_MIN_UV * pdata->v3_gain / 1000000; | 202 | max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * pdata->v3_gain / 1000; |
203 | max1586->max_uV = MAX1586_V3_MAX_UV * pdata->v3_gain / 1000000; | 203 | max1586->max_uV = MAX1586_V3_MAX_UV / 1000 * pdata->v3_gain / 1000; |
204 | 204 | ||
205 | rdev = max1586->rdev; | 205 | rdev = max1586->rdev; |
206 | for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) { | 206 | for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) { |