summaryrefslogtreecommitdiffstats
path: root/include/poller.h
blob: 886557252b69adeb05925fdf2429e743423b1b92 (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
46
/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (C) 2010 Marc Kleine-Budde <mkl@pengutronix.de>
 */

#ifndef POLLER_H
#define POLLER_H

#include <linux/list.h>

struct poller_struct {
	void (*func)(struct poller_struct *poller);
	int registered;
	struct list_head list;
	char *name;
};

int poller_register(struct poller_struct *poller, const char *name);
int poller_unregister(struct poller_struct *poller);

struct poller_async;

struct poller_async {
	struct poller_struct poller;
	void (*fn)(void *);
	void *ctx;
	uint64_t end;
	int active;
};

int poller_async_register(struct poller_async *pa, const char *name);
int poller_async_unregister(struct poller_async *pa);

int poller_call_async(struct poller_async *pa, uint64_t delay_ns,
		void (*fn)(void *), void *ctx);
int poller_async_cancel(struct poller_async *pa);

#ifdef CONFIG_POLLER
void poller_call(void);
#else
static inline void poller_call(void)
{
}
#endif	/* CONFIG_POLLER */

#endif	/* !POLLER_H */