mirror of
https://github.com/torvalds/linux.git
synced 2025-11-01 00:58:39 +02:00
Move timer related utilities from i915_utils.[ch] to separate new files i915_timer_util.[ch]. Clean up related includes. Note: Arguably none of this should exist in i915 in the first place. At least isolate it better. Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Link: https://lore.kernel.org/r/0a83d9489626121dcefcd4c1a05317399b5708f3.1757582214.git.jani.nikula@intel.com Signed-off-by: Jani Nikula <jani.nikula@intel.com>
36 lines
799 B
C
36 lines
799 B
C
// SPDX-License-Identifier: MIT
|
|
/* Copyright © 2025 Intel Corporation */
|
|
|
|
#include <linux/jiffies.h>
|
|
|
|
#include "i915_timer_util.h"
|
|
|
|
void cancel_timer(struct timer_list *t)
|
|
{
|
|
if (!timer_active(t))
|
|
return;
|
|
|
|
timer_delete(t);
|
|
WRITE_ONCE(t->expires, 0);
|
|
}
|
|
|
|
void set_timer_ms(struct timer_list *t, unsigned long timeout)
|
|
{
|
|
if (!timeout) {
|
|
cancel_timer(t);
|
|
return;
|
|
}
|
|
|
|
timeout = msecs_to_jiffies(timeout);
|
|
|
|
/*
|
|
* Paranoia to make sure the compiler computes the timeout before
|
|
* loading 'jiffies' as jiffies is volatile and may be updated in
|
|
* the background by a timer tick. All to reduce the complexity
|
|
* of the addition and reduce the risk of losing a jiffy.
|
|
*/
|
|
barrier();
|
|
|
|
/* Keep t->expires = 0 reserved to indicate a canceled timer. */
|
|
mod_timer(t, jiffies + timeout ?: 1);
|
|
}
|