regulator: palmas: Fix off-by-one for ramp_delay and register value mapping
Subsystems (2)
PATCH 1/1 regulator: palmas: Fix off-by-one for ramp_delay and register value mapping
In probe(), we have below code to set ramp_delay:
e.g. When reg is 2, current code set
pmic->desc[id].ramp_delay = palmas_smps_ramp_delay[reg & 0x3];
= 5000which means ramp_delay = 5000 is mapping to reg value = 2;
However, in palmas_smps_set_ramp_delay()
ramp_delay = 5000 is mapping to reg value = 1.
This patch fixes the off-by-one value range checking for ramp_delay in palmas_smps_set_ramp_delay().
---
Hi Laxman,
I don't have the datasheet, so please check if this fix is correct.
Thanks,
Axel
drivers/regulator/palmas-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/palmas-regulator.c +1 -1
@@ -447,9 +447,9 @@ static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev,if (ramp_delay <=0 ) reg =0 ; -else if (ramp_delay <2500 ) + else if (ramp_delay <= 2500)From 6f6875db93eeff52d39623dd68522e1875cf5ef1 Mon Sep 17 00:00:00 2001
From: Axel Lin <[email protected]>
Date: Mon, 22 Apr 2013 00:50:55 +0800
Subject: [PATCH RFT] regulator: palmas: Fix off-by-one for ramp_delay and register value mapping
In probe(), we have below code to set ramp_delay:
e.g. When reg is 2, current code set
pmic->desc[id].ramp_delay = palmas_smps_ramp_delay[reg & 0x3];
= 5000which means ramp_delay = 5000 is mapping to reg value = 2;
However, in palmas_smps_set_ramp_delay()
ramp_delay = 5000 is mapping to reg value = 1.
This patch fixes the off-by-one value range checking for ramp_delay in palmas_smps_set_ramp_delay().
---
Hi Laxman,
I don't have the datasheet, so please check if this fix is correct.
Thanks,
Axel
drivers/regulator/palmas-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/regulator/palmas-regulator.c +2 -2
@@ -447,9 +447,9 @@ static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev,if (ramp_delay <=0 ) reg =0 ; -else if (ramp_delay <2500 ) +else if (ramp_delay <=2500 ) reg =3 ; -else if (ramp_delay <5000 ) +else if (ramp_delay <=5000 ) reg =2 ;else reg =1 ;
Signature · 11 lines
1.7.10.4 reg = 3; - else if (ramp_delay < 5000) + else if (ramp_delay <= 5000) reg = 2; else reg = 1; -- 1.7.10.4
Quoted 45 lines · Axel Lin
In
probe(), we have below code to setramp_delay:
e.g. When reg is 2, current code setpmic->desc[id].ramp_delay = palmas_smps_ramp_delay[reg & 0x3]; = 5000which means
ramp_delay= 5000 is mapping to reg value = 2;However, in
palmas_smps_set_ramp_delay()
ramp_delay= 5000 is mapping to reg value = 1.This patch fixes the off-by-one value range checking for
ramp_delayinpalmas_smps_set_ramp_delay().Signed-off-by Axel Lin <[email protected]>---
Hi Laxman,
I don't have the datasheet, so please check if this fix is correct.Thanks,
Axeldrivers/regulator/palmas-regulator.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/regulator/palmas-regulator.c +1
-1@@ -447,9 +447,9 @@ static int palmas_smps_set_ramp_delay(struct regulator_dev *rdev,if (ramp_delay <=0 ) reg =0 ; -else if (ramp_delay <2500 ) + else if (ramp_delay <= 2500)From 6f6875db93eeff52d39623dd68522e1875cf5ef1 Mon Sep 17 00:00:00 2001From: Axel Lin <[email protected]>
Date: Mon, 22 Apr 2013 00:50:55 +0800
Subject: [PATCH RFT] regulator: palmas: Fix off-by-one forramp_delayand register value mappingIn
probe(), we have below code to setramp_delay:
e.g. When reg is 2, current code setpmic->desc[id].ramp_delay = palmas_smps_ramp_delay[reg & 0x3]; = 5000which means
ramp_delay= 5000 is mapping to reg value = 2;However, in
palmas_smps_set_ramp_delay()
ramp_delay= 5000 is mapping to reg value = 1.
Quoted 8 lines
This patch fixes the off-by-one value range checking for
ramp_delayinpalmas_smps_set_ramp_delay().Signed-off-by Axel Lin <[email protected]>---
Hi Laxman,
I don't have the datasheet, so please check if this fix is correct.
Datasheet says:
Time Step (TSTEP) selection, when changing the output voltage, the new value is reached through successive voltage steps (if not bypassed). The equivalent programmable slew rate of the output voltage is:
TSTEP[1:0]: 00 Jump (no slope control) TSTEP[1:0]: 01 10mV/us
TSTEP[1:0]: 10 5mV/us (default) TSTEP[1:0]: 11 2.5mV/us