All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Zabel <philipp.zabel@gmail.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: linux-kernel@vger.kernel.org, Liam Girdwood <lrg@slimlogic.co.uk>,
	Robert Jarzmik <robert.jarzmik@free.fr>,
	Philipp Zabel <philipp.zabel@gmail.com>
Subject: [PATCH] regulator/max1586: fix V3 gain calculation integer overflow
Date: Thu, 28 May 2009 21:00:03 +0200	[thread overview]
Message-ID: <1243537203-4663-1-git-send-email-philipp.zabel@gmail.com> (raw)
In-Reply-To: <20090528085920.GA4624@rakim.wolfsonmicro.main>

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>
---
 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 92799f4..2c082d3 100644
--- a/drivers/regulator/max1586.c
+++ b/drivers/regulator/max1586.c
@@ -40,8 +40,8 @@ struct max1586_data {
 	struct i2c_client *client;
 
 	/* min/max V3 voltage */
-	int min_uV;
-	int max_uV;
+	unsigned int min_uV;
+	unsigned int max_uV;
 
 	struct regulator_dev *rdev[0];
 };
@@ -199,8 +199,8 @@ static int max1586_pmic_probe(struct i2c_client *client,
 		ret = -EINVAL;
 		goto out_unmap;
 	}
-	max1586->min_uV = MAX1586_V3_MIN_UV * pdata->v3_gain / 1000000;
-	max1586->max_uV = MAX1586_V3_MAX_UV * pdata->v3_gain / 1000000;
+	max1586->min_uV = MAX1586_V3_MIN_UV / 1000 * pdata->v3_gain / 1000;
+	max1586->max_uV = MAX1586_V3_MAX_UV / 1000 * pdata->v3_gain / 1000;
 
 	rdev = max1586->rdev;
 	for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) {
-- 
1.6.3.1


  reply	other threads:[~2009-05-28 18:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-26 19:39 [PATCH] regulator/max1586: support increased V3 voltage range Philipp Zabel
2009-05-26 20:43 ` Mark Brown
2009-05-26 21:26   ` pHilipp Zabel
2009-05-26 21:31 ` Robert Jarzmik
2009-05-26 23:40   ` pHilipp Zabel
2009-05-27 15:12     ` Robert Jarzmik
2009-05-28  5:15       ` Philipp Zabel
2009-05-28  5:15       ` [PATCH 1/3] regulator/max1586: support increased V3 voltage range Philipp Zabel
2009-05-28  8:59         ` Mark Brown
2009-05-28 19:00           ` Philipp Zabel [this message]
2009-05-28 20:36             ` [PATCH] regulator/max1586: fix V3 gain calculation integer overflow Robert Jarzmik
2009-05-29  9:04               ` Liam Girdwood
2009-05-28 18:58         ` [PATCH 1/3] regulator/max1586: support increased V3 voltage range Robert Jarzmik
2009-05-28 19:01           ` pHilipp Zabel
2009-05-28 20:36             ` Robert Jarzmik
2009-05-28  5:15       ` [PATCH 4/5] pxa/mioa701: add V3 gain configuration for Maxim 1586 voltage regulator Philipp Zabel
2009-05-28  5:16         ` pHilipp Zabel
2009-05-29  6:22         ` Robert Jarzmik
2009-06-01  5:39           ` Eric Miao
2009-05-28  5:15       ` [PATCH 3/3] pxa/hx4700: add Maxim 1587A " Philipp Zabel
2009-06-01  5:37         ` Eric Miao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1243537203-4663-1-git-send-email-philipp.zabel@gmail.com \
    --to=philipp.zabel@gmail.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lrg@slimlogic.co.uk \
    --cc=robert.jarzmik@free.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.