]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
power: supply: charger-manager: Switch to alarm_start_timer()
authorThomas Gleixner <tglx@kernel.org>
Wed, 8 Apr 2026 11:54:24 +0000 (13:54 +0200)
committerThomas Gleixner <tglx@kernel.org>
Fri, 1 May 2026 19:36:13 +0000 (21:36 +0200)
The existing alarm_start() interface is replaced with the new
alarm_start_timer() mechanism, which does not longer queue an already
expired timer and returns the state. Adjust the code to utilize this.

No functional change intended.

Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
Link: https://patch.msgid.link/20260408114952.536945376@kernel.org
drivers/power/supply/charger-manager.c

index c49e0e4d02f77a4576bba7eede54e45cbb4eab75..1b0239c591144cceba19de0565db0447d460cf50 100644 (file)
@@ -881,26 +881,22 @@ static bool cm_setup_timer(void)
        mutex_unlock(&cm_list_mtx);
 
        if (timer_req && cm_timer) {
-               ktime_t now, add;
-
                /*
                 * Set alarm with the polling interval (wakeup_ms)
                 * The alarm time should be NOW + CM_RTC_SMALL or later.
                 */
-               if (wakeup_ms == UINT_MAX ||
-                       wakeup_ms < CM_RTC_SMALL * MSEC_PER_SEC)
+               if (wakeup_ms == UINT_MAX || wakeup_ms < CM_RTC_SMALL * MSEC_PER_SEC)
                        wakeup_ms = 2 * CM_RTC_SMALL * MSEC_PER_SEC;
 
                pr_info("Charger Manager wakeup timer: %u ms\n", wakeup_ms);
 
-               now = ktime_get_boottime();
-               add = ktime_set(wakeup_ms / MSEC_PER_SEC,
-                               (wakeup_ms % MSEC_PER_SEC) * NSEC_PER_MSEC);
-               alarm_start(cm_timer, ktime_add(now, add));
-
                cm_suspend_duration_ms = wakeup_ms;
 
-               return true;
+               /*
+                * The timer should always be queued as the timeout is at least
+                * two seconds out. Handle it correctly nevertheless.
+                */
+               return alarm_start_timer(cm_timer, ktime_add_ms(0, wakeup_ms), true);
        }
        return false;
 }