lkml.org 
[lkml]   [2021]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.4 040/188] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel
    Date
    From: Axel Lin <axel.lin@ingics.com>

    [ Upstream commit a336dc8f683e5be794186b5643cd34cb28dd2c53 ]

    Use DIV_ROUND_UP to prevent truncation by integer division issue.
    This ensures we return enough delay time.

    Also fix returning negative value when new_sel < old_sel.

    Signed-off-by: Axel Lin <axel.lin@ingics.com>
    Link: https://lore.kernel.org/r/20210618141412.4014912-1-axel.lin@ingics.com
    Signed-off-by: Mark Brown <broonie@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/regulator/da9052-regulator.c | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c
    index 12a25b40e473..fa9cb7df79de 100644
    --- a/drivers/regulator/da9052-regulator.c
    +++ b/drivers/regulator/da9052-regulator.c
    @@ -258,7 +258,8 @@ static int da9052_regulator_set_voltage_time_sel(struct regulator_dev *rdev,
    case DA9052_ID_BUCK3:
    case DA9052_ID_LDO2:
    case DA9052_ID_LDO3:
    - ret = (new_sel - old_sel) * info->step_uV / 6250;
    + ret = DIV_ROUND_UP(abs(new_sel - old_sel) * info->step_uV,
    + 6250);
    break;
    }

    --
    2.30.2


    \
     
     \ /
      Last update: 2021-07-19 17:00    [W:2.712 / U:0.484 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site