linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] regulator: tps65217: Fix voltage boundary checking in tps65217_pmic_map_voltage
@ 2012-07-03  7:19 Axel Lin
  2012-07-03  7:45 ` AnilKumar, Chimata
  2012-07-03 19:18 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Axel Lin @ 2012-07-03  7:19 UTC (permalink / raw)
  To: Mark Brown
  Cc: AnilKumar, Chimata, Girdwood, Liam, linux-kernel@vger.kernel.org,
	Nori, Sekhar

It is ok to request voltage with min_uV < tps->info[rid]->min_uV and
max_uV > tps->info[rid]->max_uV.

The equation we used in uv_to_vsel() does not allow
min_uV < tps->info[rid]->min_uV, otherwise it returns negative selector.
So we need to set min_uV = tps->info[rid]->min_uV if
min_uV < tps->info[rid]->min_uV.

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

diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c
index 0a3df5b..f7d0495 100644
--- a/drivers/regulator/tps65217-regulator.c
+++ b/drivers/regulator/tps65217-regulator.c
@@ -206,10 +206,10 @@ static int tps65217_pmic_map_voltage(struct regulator_dev *dev,
 	if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4)
 		return -EINVAL;
 
-	if (min_uV < tps->info[rid]->min_uV || min_uV > tps->info[rid]->max_uV)
-		return -EINVAL;
+	if (min_uV < tps->info[rid]->min_uV)
+		min_uV = tps->info[rid]->min_uV;
 
-	if (max_uV < tps->info[rid]->min_uV || max_uV > tps->info[rid]->max_uV)
+	if (max_uV < tps->info[rid]->min_uV || min_uV > tps->info[rid]->max_uV)
 		return -EINVAL;
 
 	ret = tps->info[rid]->uv_to_vsel(min_uV, &sel);
-- 
1.7.9.5




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

* RE: [PATCH v2] regulator: tps65217: Fix voltage boundary checking in tps65217_pmic_map_voltage
  2012-07-03  7:19 [PATCH v2] regulator: tps65217: Fix voltage boundary checking in tps65217_pmic_map_voltage Axel Lin
@ 2012-07-03  7:45 ` AnilKumar, Chimata
  2012-07-03 19:18 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: AnilKumar, Chimata @ 2012-07-03  7:45 UTC (permalink / raw)
  To: Axel Lin, Mark Brown
  Cc: Girdwood, Liam, linux-kernel@vger.kernel.org, Nori, Sekhar

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1606 bytes --]

Hi Axel,

Thanks for the patch

Acked-by: AnilKumar Ch <anilkumar@ti.com>

On Tue, Jul 03, 2012 at 12:49:33, Axel Lin wrote:
> It is ok to request voltage with min_uV < tps->info[rid]->min_uV and
> max_uV > tps->info[rid]->max_uV.
> 
> The equation we used in uv_to_vsel() does not allow
> min_uV < tps->info[rid]->min_uV, otherwise it returns negative selector.
> So we need to set min_uV = tps->info[rid]->min_uV if
> min_uV < tps->info[rid]->min_uV.
> 
> Signed-off-by: Axel Lin <axel.lin@gmail.com>
> ---
>  drivers/regulator/tps65217-regulator.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c
> index 0a3df5b..f7d0495 100644
> --- a/drivers/regulator/tps65217-regulator.c
> +++ b/drivers/regulator/tps65217-regulator.c
> @@ -206,10 +206,10 @@ static int tps65217_pmic_map_voltage(struct regulator_dev *dev,
>  	if (rid < TPS65217_DCDC_1 || rid > TPS65217_LDO_4)
>  		return -EINVAL;
>  
> -	if (min_uV < tps->info[rid]->min_uV || min_uV > tps->info[rid]->max_uV)
> -		return -EINVAL;
> +	if (min_uV < tps->info[rid]->min_uV)
> +		min_uV = tps->info[rid]->min_uV;
>  
> -	if (max_uV < tps->info[rid]->min_uV || max_uV > tps->info[rid]->max_uV)
> +	if (max_uV < tps->info[rid]->min_uV || min_uV > tps->info[rid]->max_uV)
>  		return -EINVAL;
>  
>  	ret = tps->info[rid]->uv_to_vsel(min_uV, &sel);
> -- 
> 1.7.9.5
> 
> 
> 
> 

ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH v2] regulator: tps65217: Fix voltage boundary checking in tps65217_pmic_map_voltage
  2012-07-03  7:19 [PATCH v2] regulator: tps65217: Fix voltage boundary checking in tps65217_pmic_map_voltage Axel Lin
  2012-07-03  7:45 ` AnilKumar, Chimata
@ 2012-07-03 19:18 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2012-07-03 19:18 UTC (permalink / raw)
  To: Axel Lin
  Cc: AnilKumar, Chimata, Girdwood, Liam, linux-kernel@vger.kernel.org,
	Nori, Sekhar

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

On Tue, Jul 03, 2012 at 03:19:33PM +0800, Axel Lin wrote:
> It is ok to request voltage with min_uV < tps->info[rid]->min_uV and
> max_uV > tps->info[rid]->max_uV.

Applied, 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-07-03 19:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-03  7:19 [PATCH v2] regulator: tps65217: Fix voltage boundary checking in tps65217_pmic_map_voltage Axel Lin
2012-07-03  7:45 ` AnilKumar, Chimata
2012-07-03 19:18 ` 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).