summaryrefslogtreecommitdiffstats
path: root/include/timer.h
blob: 5ff9033db0cd62833f0bded6d68faded2514ef13 (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
41
42
43
44
45
/*
 * libdect timer handling
 *
 * Copyright (c) 2009-2010 Patrick McHardy <kaber@trash.net>
 */

#ifndef _LIBDECT_TIMER_H
#define _LIBDECT_TIMER_H

#include <utils.h>

struct dect_handle;

enum dect_timer_state {
	DECT_TIMER_STOPPED,
	DECT_TIMER_RUNNING,
};

/**
 * struct dect_timer - libdect timer
 *
 * @callback:		callback to invoke on timer expiry
 * @data:		libdect internal data
 * @state:		libdect internal state
 * @priv:		libdect user private timer storage
 */
struct dect_timer {
	void			(*callback)(struct dect_handle *,
					    struct dect_timer *);
	void			*data;
	enum dect_timer_state	state;
	uint8_t			priv[] __aligned(__alignof__(uint64_t));
};

extern struct dect_timer *dect_timer_alloc(const struct dect_handle *dh);
extern void dect_timer_free(const struct dect_handle *dh, struct dect_timer *timer);
extern void dect_timer_setup(struct dect_timer *timer,
			     void (*cb)(struct dect_handle *, struct dect_timer *),
			     void *data);
extern void dect_timer_start(const struct dect_handle *dh,
			     struct dect_timer *timer, unsigned int timeout);
extern void dect_timer_stop(const struct dect_handle *dh, struct dect_timer *timer);
extern bool dect_timer_running(const struct dect_timer *timer);

#endif /* _LIBDECT_TIMER_H */