diff options
Diffstat (limited to 'include/linux/poll.h')
-rw-r--r-- | include/linux/poll.h | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/include/linux/poll.h b/include/linux/poll.h index cf40010ce0cd..48fe8bc398d1 100644 --- a/include/linux/poll.h +++ b/include/linux/poll.h | |||
@@ -32,21 +32,46 @@ struct poll_table_struct; | |||
32 | */ | 32 | */ |
33 | typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *); | 33 | typedef void (*poll_queue_proc)(struct file *, wait_queue_head_t *, struct poll_table_struct *); |
34 | 34 | ||
35 | /* | ||
36 | * Do not touch the structure directly, use the access functions | ||
37 | * poll_does_not_wait() and poll_requested_events() instead. | ||
38 | */ | ||
35 | typedef struct poll_table_struct { | 39 | typedef struct poll_table_struct { |
36 | poll_queue_proc qproc; | 40 | poll_queue_proc _qproc; |
37 | unsigned long key; | 41 | unsigned long _key; |
38 | } poll_table; | 42 | } poll_table; |
39 | 43 | ||
40 | static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p) | 44 | static inline void poll_wait(struct file * filp, wait_queue_head_t * wait_address, poll_table *p) |
41 | { | 45 | { |
42 | if (p && wait_address) | 46 | if (p && p->_qproc && wait_address) |
43 | p->qproc(filp, wait_address, p); | 47 | p->_qproc(filp, wait_address, p); |
48 | } | ||
49 | |||
50 | /* | ||
51 | * Return true if it is guaranteed that poll will not wait. This is the case | ||
52 | * if the poll() of another file descriptor in the set got an event, so there | ||
53 | * is no need for waiting. | ||
54 | */ | ||
55 | static inline bool poll_does_not_wait(const poll_table *p) | ||
56 | { | ||
57 | return p == NULL || p->_qproc == NULL; | ||
58 | } | ||
59 | |||
60 | /* | ||
61 | * Return the set of events that the application wants to poll for. | ||
62 | * This is useful for drivers that need to know whether a DMA transfer has | ||
63 | * to be started implicitly on poll(). You typically only want to do that | ||
64 | * if the application is actually polling for POLLIN and/or POLLOUT. | ||
65 | */ | ||
66 | static inline unsigned long poll_requested_events(const poll_table *p) | ||
67 | { | ||
68 | return p ? p->_key : ~0UL; | ||
44 | } | 69 | } |
45 | 70 | ||
46 | static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc) | 71 | static inline void init_poll_funcptr(poll_table *pt, poll_queue_proc qproc) |
47 | { | 72 | { |
48 | pt->qproc = qproc; | 73 | pt->_qproc = qproc; |
49 | pt->key = ~0UL; /* all events enabled */ | 74 | pt->_key = ~0UL; /* all events enabled */ |
50 | } | 75 | } |
51 | 76 | ||
52 | struct poll_table_entry { | 77 | struct poll_table_entry { |