]> git.baikalelectronics.ru Git - kernel.git/commit
power: ab8500_chargalg: Use CLOCK_MONOTONIC
authorLinus Walleij <linus.walleij@linaro.org>
Tue, 8 Mar 2022 15:44:25 +0000 (16:44 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Mon, 14 Mar 2022 16:24:52 +0000 (17:24 +0100)
commit6a3f34bfbfb47786c0bf56a9593b5e7c3f3c73aa
treeab17a2403269caf0261d4005dc0abb13403bb460
parent15c08018b6d89eaeb1c477fd58391d66003efcfe
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: f26b27d27bc8 ("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>
drivers/power/supply/ab8500_chargalg.c