summaryrefslogtreecommitdiffstats
path: root/drivers/staging/csr/oska/timer.h
blob: 3045fc3b98b7067038a5cff21f11895fea6f0883 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * OSKA Linux implementation -- timers.
 *
 * Copyright (C) 2009 Cambridge Silicon Radio Ltd.
 *
 * Refer to LICENSE.txt included with this source code for details on
 * the license terms.
 */
#ifndef __OSKA_LINUX_TIMER_H
#define __OSKA_LINUX_TIMER_H

#include <linux/kernel.h>
#include <linux/timer.h>

typedef void (*os_timer_func_t)(void *arg);

typedef struct {
    os_timer_func_t func;
    void *arg;
    struct timer_list timer;
} os_timer_t;

void os_timer_init(os_timer_t *timer, os_timer_func_t func, void *arg);

static inline void os_timer_destroy(os_timer_t *timer)
{
    del_timer_sync(&timer->timer);
}

static inline void os_timer_set(os_timer_t *timer, unsigned long expires_ms)
{
    mod_timer(&timer->timer, jiffies + msecs_to_jiffies(expires_ms));
}

static inline void os_timer_cancel(os_timer_t *timer)
{
    del_timer(&timer->timer);
}

#endif /* #ifndef __OSKA_LINUX_TIMER_H */