Skip to content

Commit c22fca4

Browse files
Linus Walleijsre
authored andcommitted
power: ab8500_chargalg: Use CLOCK_MONOTONIC
The HRTimer in the AB8500 charging code is using CLOCK_REALTIME to set an alarm some hours forward in time +/- 5 min for a safety timer. I have observed that this will sometimes fire sporadically early when charging a battery with the result that charging stops. As CLOCK_REALTIME can be subject to adjustments of time from sources such as NTP, this cannot be trusted and will likely for example fire events if the clock is set forward some hours by say NTP. Use CLOCK_MONOTONIC as indicated in other instances and the problem goes away. Also initialize the timer to REL mode as this is what will be used later. Fixes: 257107a ("ab8500-chargalg: Use hrtimer") Cc: Lee Jones <lee.jones@linaro.org> Suggested-by: Matti Vaittinen <mazziesaccount@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
1 parent 7585340 commit c22fca4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/power/supply/ab8500_chargalg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,11 +1775,11 @@ static int ab8500_chargalg_probe(struct platform_device *pdev)
17751775
psy_cfg.drv_data = di;
17761776

17771777
/* Initilialize safety timer */
1778-
hrtimer_init(&di->safety_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
1778+
hrtimer_init(&di->safety_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
17791779
di->safety_timer.function = ab8500_chargalg_safety_timer_expired;
17801780

17811781
/* Initilialize maintenance timer */
1782-
hrtimer_init(&di->maintenance_timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
1782+
hrtimer_init(&di->maintenance_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
17831783
di->maintenance_timer.function =
17841784
ab8500_chargalg_maintenance_timer_expired;
17851785

0 commit comments

Comments
 (0)