Skip to content

Commit

Permalink
regulator: max8998: Ensure enough delay time for max8998_set_voltage_…
Browse files Browse the repository at this point in the history
…buck_time_sel

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

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: stable@vger.kernel.org
  • Loading branch information
Axel Lin authored and Mark Brown committed Jan 10, 2013
1 parent adf6178 commit 81d0a6a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/regulator/max8998.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ static int max8998_set_voltage_buck_time_sel(struct regulator_dev *rdev,

difference = (new_selector - old_selector) * desc->step / 1000;
if (difference > 0)
return difference / ((val & 0x0f) + 1);
return DIV_ROUND_UP(difference, (val & 0x0f) + 1);

return 0;
}
Expand Down

0 comments on commit 81d0a6a

Please sign in to comment.