18d59ecb2SHans Petter Selasky /*- 28d59ecb2SHans Petter Selasky * Copyright (c) 2010 Isilon Systems, Inc. 38d59ecb2SHans Petter Selasky * Copyright (c) 2010 iX Systems, Inc. 48d59ecb2SHans Petter Selasky * Copyright (c) 2010 Panasas, Inc. 58d59ecb2SHans Petter Selasky * Copyright (c) 2013, 2014 Mellanox Technologies, Ltd. 68d59ecb2SHans Petter Selasky * All rights reserved. 78d59ecb2SHans Petter Selasky * 88d59ecb2SHans Petter Selasky * Redistribution and use in source and binary forms, with or without 98d59ecb2SHans Petter Selasky * modification, are permitted provided that the following conditions 108d59ecb2SHans Petter Selasky * are met: 118d59ecb2SHans Petter Selasky * 1. Redistributions of source code must retain the above copyright 128d59ecb2SHans Petter Selasky * notice unmodified, this list of conditions, and the following 138d59ecb2SHans Petter Selasky * disclaimer. 148d59ecb2SHans Petter Selasky * 2. Redistributions in binary form must reproduce the above copyright 158d59ecb2SHans Petter Selasky * notice, this list of conditions and the following disclaimer in the 168d59ecb2SHans Petter Selasky * documentation and/or other materials provided with the distribution. 178d59ecb2SHans Petter Selasky * 188d59ecb2SHans Petter Selasky * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 198d59ecb2SHans Petter Selasky * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 208d59ecb2SHans Petter Selasky * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 218d59ecb2SHans Petter Selasky * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 228d59ecb2SHans Petter Selasky * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 238d59ecb2SHans Petter Selasky * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 248d59ecb2SHans Petter Selasky * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 258d59ecb2SHans Petter Selasky * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 268d59ecb2SHans Petter Selasky * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 278d59ecb2SHans Petter Selasky * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 288d59ecb2SHans Petter Selasky * 298d59ecb2SHans Petter Selasky * $FreeBSD$ 308d59ecb2SHans Petter Selasky */ 318d59ecb2SHans Petter Selasky #ifndef _LINUX_TIMER_H_ 328d59ecb2SHans Petter Selasky #define _LINUX_TIMER_H_ 338d59ecb2SHans Petter Selasky 348d59ecb2SHans Petter Selasky #include <linux/types.h> 358d59ecb2SHans Petter Selasky 368d59ecb2SHans Petter Selasky #include <sys/param.h> 378d59ecb2SHans Petter Selasky #include <sys/kernel.h> 388d59ecb2SHans Petter Selasky #include <sys/callout.h> 398d59ecb2SHans Petter Selasky 408d59ecb2SHans Petter Selasky struct timer_list { 418d59ecb2SHans Petter Selasky struct callout timer_callout; 428d59ecb2SHans Petter Selasky void (*function) (unsigned long); 438d59ecb2SHans Petter Selasky unsigned long data; 448d59ecb2SHans Petter Selasky unsigned long expires; 458d59ecb2SHans Petter Selasky }; 468d59ecb2SHans Petter Selasky 478d59ecb2SHans Petter Selasky extern unsigned long linux_timer_hz_mask; 488d59ecb2SHans Petter Selasky 498d59ecb2SHans Petter Selasky #define setup_timer(timer, func, dat) \ 508d59ecb2SHans Petter Selasky do { \ 518d59ecb2SHans Petter Selasky (timer)->function = (func); \ 528d59ecb2SHans Petter Selasky (timer)->data = (dat); \ 538d59ecb2SHans Petter Selasky callout_init(&(timer)->timer_callout, 1); \ 548d59ecb2SHans Petter Selasky } while (0) 558d59ecb2SHans Petter Selasky 568d59ecb2SHans Petter Selasky #define init_timer(timer) \ 578d59ecb2SHans Petter Selasky do { \ 588d59ecb2SHans Petter Selasky (timer)->function = NULL; \ 598d59ecb2SHans Petter Selasky (timer)->data = 0; \ 608d59ecb2SHans Petter Selasky callout_init(&(timer)->timer_callout, 1); \ 618d59ecb2SHans Petter Selasky } while (0) 628d59ecb2SHans Petter Selasky 638d59ecb2SHans Petter Selasky extern void mod_timer(struct timer_list *, unsigned long); 648d59ecb2SHans Petter Selasky extern void add_timer(struct timer_list *); 65*def277d3SHans Petter Selasky extern void add_timer_on(struct timer_list *, int cpu); 668d59ecb2SHans Petter Selasky 678d59ecb2SHans Petter Selasky #define del_timer(timer) callout_stop(&(timer)->timer_callout) 688d59ecb2SHans Petter Selasky #define del_timer_sync(timer) callout_drain(&(timer)->timer_callout) 698d59ecb2SHans Petter Selasky #define timer_pending(timer) callout_pending(&(timer)->timer_callout) 708d59ecb2SHans Petter Selasky #define round_jiffies(j) \ 718d59ecb2SHans Petter Selasky ((unsigned long)(((j) + linux_timer_hz_mask) & ~linux_timer_hz_mask)) 728d59ecb2SHans Petter Selasky #define round_jiffies_relative(j) \ 738d59ecb2SHans Petter Selasky round_jiffies(j) 748d59ecb2SHans Petter Selasky 758d59ecb2SHans Petter Selasky #endif /* _LINUX_TIMER_H_ */ 76