XenevaOS
Loading...
Searching...
No Matches
XenevaOS
BaseHdr
linux
notifier.h
Go to the documentation of this file.
1
/* DCL <linux/notifier.h> -- notifier chain types, not chains.
2
*
3
* mainline keeps the full atomic/blocking/raw/SRCU chain machinery here.
4
* The drm core that DCL vendors only ever carries a struct notifier_block
5
* around -- drm_connector embeds one for the privacy screen, and the
6
* registration call behind it is the IS_ENABLED() inline stub in
7
* drm_privacy_screen_consumer.h -- so what this header owes is the block,
8
* the callback type and the NOTIFY_* vocabulary the stubs still spell.
9
* No chain register/call surface is exported: nothing in the build calls
10
* one, and the SRCU notifier head it would take is exactly the surface
11
* that made the real port cost more than it bought.
12
*/
13
#ifndef _LINUX_NOTIFIER_H
14
#define _LINUX_NOTIFIER_H
15
16
/*
17
* <linux/mutex.h> -- for struct mutex, which this header's types do not
18
* mention at all and which is the reason it is included anyway.
19
*
20
* mainline's own notifier.h reaches the type by a chain rather than naming
21
* it: notifier.h -> <linux/rwsem.h> -> <linux/ww_mutex.h> ->
22
* <linux/mutex.h>. DCL has all four of those headers and ww_mutex.h:21 does
23
* include mutex.h, but DCL's rwsem.h does not pull ww_mutex.h in, so the
24
* chain stops one link short here and the last one is named directly.
25
*
26
* The consumer is <drm/drm_connector.h>, which embeds `struct mutex` in
27
* struct drm_connector at five sites (:1891, :1960, :1977, :2043, :2289) and
28
* includes this header at :30. A field of an incomplete type is an error at
29
* the point of declaration, so the definition has to be in scope before that
30
* header is parsed -- it cannot be deferred to the .c that uses it.
31
*
32
* Not a leaf, unlike everything else in this header: mutex.h brings
33
* kernel.h, cleanup.h, atomic.h and lockdep.h, and kernel.h is the
34
* aggregator -- its subtree runs on through virtio.h and completion.h to
35
* <linux/sched.h>, which redefines the word `current` as a macro. That is
36
* the trap <linux/fcntl.h> documented at the bottom of its own file, and
37
* the exposure is narrower here than it sounds: this header is included by
38
* exactly one other file in the tree, <drm/drm_connector.h> (checked by
39
* grep), and every source that parses that header is a drm one. None of
40
* them includes <Fs/vfs.h>, whose `uint64_t current` member is the only
41
* thing the macro has ever broken.
42
*/
43
#include <
linux/mutex.h
>
44
45
struct
notifier_block
;
46
47
typedef
int (*
notifier_fn_t
)(
struct
notifier_block
*nb,
48
unsigned
long
action,
void
*
data
);
49
50
struct
notifier_block
{
51
notifier_fn_t
notifier_call
;
52
struct
notifier_block
*
next
;
53
int
priority
;
54
};
55
56
#define NOTIFY_DONE 0x0000
/* Don't care */
57
#define NOTIFY_OK 0x0001
/* Suits me */
58
#define NOTIFY_STOP_MASK 0x8000
/* Don't call further */
59
#define NOTIFY_BAD (NOTIFY_STOP_MASK|0x0002)
/* Bad/Veto action */
60
#define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK)
61
62
/* Encapsulate (negative) errno value (in particular, NOTIFY_BAD <=> EPERM). */
63
static
inline
int
notifier_from_errno(
int
err)
64
{
65
if
(err)
66
return
NOTIFY_STOP_MASK
| (
NOTIFY_OK
- err);
67
return
NOTIFY_OK
;
68
}
69
70
/* Restore (negative) errno value from notify return value. */
71
static
inline
int
notifier_to_errno(
int
ret)
72
{
73
ret &= ~NOTIFY_STOP_MASK;
74
return
ret >
NOTIFY_OK
?
NOTIFY_OK
- ret : 0;
75
}
76
77
#endif
/* _LINUX_NOTIFIER_H */
data
void * data
Definition
kthread.h:30
mutex.h
NOTIFY_OK
#define NOTIFY_OK
Definition
notifier.h:57
notifier_fn_t
int(* notifier_fn_t)(struct notifier_block *nb, unsigned long action, void *data)
Definition
notifier.h:47
NOTIFY_STOP_MASK
#define NOTIFY_STOP_MASK
Definition
notifier.h:58
notifier_block
Definition
notifier.h:50
notifier_block::notifier_call
notifier_fn_t notifier_call
Definition
notifier.h:51
notifier_block::priority
int priority
Definition
notifier.h:53
notifier_block::next
struct notifier_block * next
Definition
notifier.h:52
Generated by
1.9.8