Sometimes execution of a function has to be delayed, for example when a backlight can only be turned on when the picture has stabilized. To help in such situations add a convenience function around the poller stuff to call a function after a delay. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
44 lines
814 B
C
44 lines
814 B
C
/*
|
|
* Copyright (C) 2010 Marc Kleine-Budde <mkl@pengutronix.de>
|
|
*
|
|
* This file is released under the GPLv2
|
|
*
|
|
*/
|
|
|
|
#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;
|
|
};
|
|
|
|
int poller_register(struct poller_struct *poller);
|
|
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 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 */
|