xref: /openbsd-src/sys/dev/pci/drm/include/linux/timer.h (revision f005ef32267c16bdb134f0e9fa4477dbe07c263a)
1*f005ef32Sjsg /*	$OpenBSD: timer.h,v 1.9 2024/01/16 23:38:13 jsg Exp $	*/
27f4dd379Sjsg /*
37f4dd379Sjsg  * Copyright (c) 2013, 2014, 2015 Mark Kettenis
47f4dd379Sjsg  *
57f4dd379Sjsg  * Permission to use, copy, modify, and distribute this software for any
67f4dd379Sjsg  * purpose with or without fee is hereby granted, provided that the above
77f4dd379Sjsg  * copyright notice and this permission notice appear in all copies.
87f4dd379Sjsg  *
97f4dd379Sjsg  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
107f4dd379Sjsg  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
117f4dd379Sjsg  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
127f4dd379Sjsg  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
137f4dd379Sjsg  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
147f4dd379Sjsg  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
157f4dd379Sjsg  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
167f4dd379Sjsg  */
177f4dd379Sjsg 
187f4dd379Sjsg #ifndef _LINUX_TIMER_H
197f4dd379Sjsg #define _LINUX_TIMER_H
207f4dd379Sjsg 
217f4dd379Sjsg #include <sys/types.h>
227f4dd379Sjsg #include <sys/param.h>
237f4dd379Sjsg #include <sys/timeout.h>
247f4dd379Sjsg #include <sys/kernel.h>
257f4dd379Sjsg #include <linux/ktime.h>
267f4dd379Sjsg 
2714655f60Sjsg #define del_timer_sync(x)	timeout_del_barrier((x))
28*f005ef32Sjsg #define timer_shutdown_sync(x)	timeout_del_barrier((x))
29c349dbc7Sjsg #define del_timer(x)		timeout_del((x))
307f4dd379Sjsg #define timer_pending(x)	timeout_pending((x))
317f4dd379Sjsg 
322d020a1bSjsg static inline int
mod_timer(struct timeout * to,unsigned long j)332d020a1bSjsg mod_timer(struct timeout *to, unsigned long j)
342d020a1bSjsg {
3567cf64feSjsg 	if (j <= jiffies)
362d020a1bSjsg 		return timeout_add(to, 1);
372d020a1bSjsg 	return timeout_add(to, j - jiffies);
382d020a1bSjsg }
392d020a1bSjsg 
407f4dd379Sjsg static inline unsigned long
round_jiffies_up(unsigned long j)417f4dd379Sjsg round_jiffies_up(unsigned long j)
427f4dd379Sjsg {
437f4dd379Sjsg 	return roundup(j, hz);
447f4dd379Sjsg }
457f4dd379Sjsg 
467f4dd379Sjsg static inline unsigned long
round_jiffies_up_relative(unsigned long j)477f4dd379Sjsg round_jiffies_up_relative(unsigned long j)
487f4dd379Sjsg {
497f4dd379Sjsg 	return roundup(j, hz);
507f4dd379Sjsg }
517f4dd379Sjsg 
527f4dd379Sjsg #endif
53