diff options
| author | Paul Mackerras <paulus@samba.org> | 2006-03-28 21:24:50 -0500 |
|---|---|---|
| committer | Paul Mackerras <paulus@samba.org> | 2006-03-28 21:24:50 -0500 |
| commit | bac30d1a78d0f11c613968fc8b351a91ed465386 (patch) | |
| tree | e52f3c876522a2f6047a6ec1c27df2e8a79486b8 /include/linux/notifier.h | |
| parent | e8222502ee6157e2713da9e0792c21f4ad458d50 (diff) | |
| parent | ca9ba4471c1203bb6e759b76e83167fec54fe590 (diff) | |
Merge ../linux-2.6
Diffstat (limited to 'include/linux/notifier.h')
| -rw-r--r-- | include/linux/notifier.h | 96 |
1 files changed, 89 insertions, 7 deletions
diff --git a/include/linux/notifier.h b/include/linux/notifier.h index 5937dd6053c3..51dbab9710c7 100644 --- a/include/linux/notifier.h +++ b/include/linux/notifier.h | |||
| @@ -10,25 +10,107 @@ | |||
| 10 | #ifndef _LINUX_NOTIFIER_H | 10 | #ifndef _LINUX_NOTIFIER_H |
| 11 | #define _LINUX_NOTIFIER_H | 11 | #define _LINUX_NOTIFIER_H |
| 12 | #include <linux/errno.h> | 12 | #include <linux/errno.h> |
| 13 | #include <linux/mutex.h> | ||
| 14 | #include <linux/rwsem.h> | ||
| 13 | 15 | ||
| 14 | struct notifier_block | 16 | /* |
| 15 | { | 17 | * Notifier chains are of three types: |
| 16 | int (*notifier_call)(struct notifier_block *self, unsigned long, void *); | 18 | * |
| 19 | * Atomic notifier chains: Chain callbacks run in interrupt/atomic | ||
| 20 | * context. Callouts are not allowed to block. | ||
| 21 | * Blocking notifier chains: Chain callbacks run in process context. | ||
| 22 | * Callouts are allowed to block. | ||
| 23 | * Raw notifier chains: There are no restrictions on callbacks, | ||
| 24 | * registration, or unregistration. All locking and protection | ||
| 25 | * must be provided by the caller. | ||
| 26 | * | ||
| 27 | * atomic_notifier_chain_register() may be called from an atomic context, | ||
| 28 | * but blocking_notifier_chain_register() must be called from a process | ||
| 29 | * context. Ditto for the corresponding _unregister() routines. | ||
| 30 | * | ||
| 31 | * atomic_notifier_chain_unregister() and blocking_notifier_chain_unregister() | ||
| 32 | * _must not_ be called from within the call chain. | ||
| 33 | */ | ||
| 34 | |||
| 35 | struct notifier_block { | ||
| 36 | int (*notifier_call)(struct notifier_block *, unsigned long, void *); | ||
| 17 | struct notifier_block *next; | 37 | struct notifier_block *next; |
| 18 | int priority; | 38 | int priority; |
| 19 | }; | 39 | }; |
| 20 | 40 | ||
| 41 | struct atomic_notifier_head { | ||
| 42 | spinlock_t lock; | ||
| 43 | struct notifier_block *head; | ||
| 44 | }; | ||
| 45 | |||
| 46 | struct blocking_notifier_head { | ||
| 47 | struct rw_semaphore rwsem; | ||
| 48 | struct notifier_block *head; | ||
| 49 | }; | ||
| 50 | |||
| 51 | struct raw_notifier_head { | ||
| 52 | struct notifier_block *head; | ||
| 53 | }; | ||
| 54 | |||
| 55 | #define ATOMIC_INIT_NOTIFIER_HEAD(name) do { \ | ||
| 56 | spin_lock_init(&(name)->lock); \ | ||
| 57 | (name)->head = NULL; \ | ||
| 58 | } while (0) | ||
| 59 | #define BLOCKING_INIT_NOTIFIER_HEAD(name) do { \ | ||
| 60 | init_rwsem(&(name)->rwsem); \ | ||
| 61 | (name)->head = NULL; \ | ||
| 62 | } while (0) | ||
| 63 | #define RAW_INIT_NOTIFIER_HEAD(name) do { \ | ||
| 64 | (name)->head = NULL; \ | ||
| 65 | } while (0) | ||
| 66 | |||
| 67 | #define ATOMIC_NOTIFIER_INIT(name) { \ | ||
| 68 | .lock = SPIN_LOCK_UNLOCKED, \ | ||
| 69 | .head = NULL } | ||
| 70 | #define BLOCKING_NOTIFIER_INIT(name) { \ | ||
| 71 | .rwsem = __RWSEM_INITIALIZER((name).rwsem), \ | ||
| 72 | .head = NULL } | ||
| 73 | #define RAW_NOTIFIER_INIT(name) { \ | ||
| 74 | .head = NULL } | ||
| 75 | |||
| 76 | #define ATOMIC_NOTIFIER_HEAD(name) \ | ||
| 77 | struct atomic_notifier_head name = \ | ||
| 78 | ATOMIC_NOTIFIER_INIT(name) | ||
| 79 | #define BLOCKING_NOTIFIER_HEAD(name) \ | ||
| 80 | struct blocking_notifier_head name = \ | ||
| 81 | BLOCKING_NOTIFIER_INIT(name) | ||
| 82 | #define RAW_NOTIFIER_HEAD(name) \ | ||
| 83 | struct raw_notifier_head name = \ | ||
| 84 | RAW_NOTIFIER_INIT(name) | ||
| 21 | 85 | ||
| 22 | #ifdef __KERNEL__ | 86 | #ifdef __KERNEL__ |
| 23 | 87 | ||
| 24 | extern int notifier_chain_register(struct notifier_block **list, struct notifier_block *n); | 88 | extern int atomic_notifier_chain_register(struct atomic_notifier_head *, |
| 25 | extern int notifier_chain_unregister(struct notifier_block **nl, struct notifier_block *n); | 89 | struct notifier_block *); |
| 26 | extern int notifier_call_chain(struct notifier_block **n, unsigned long val, void *v); | 90 | extern int blocking_notifier_chain_register(struct blocking_notifier_head *, |
| 91 | struct notifier_block *); | ||
| 92 | extern int raw_notifier_chain_register(struct raw_notifier_head *, | ||
| 93 | struct notifier_block *); | ||
| 94 | |||
| 95 | extern int atomic_notifier_chain_unregister(struct atomic_notifier_head *, | ||
| 96 | struct notifier_block *); | ||
| 97 | extern int blocking_notifier_chain_unregister(struct blocking_notifier_head *, | ||
| 98 | struct notifier_block *); | ||
| 99 | extern int raw_notifier_chain_unregister(struct raw_notifier_head *, | ||
| 100 | struct notifier_block *); | ||
| 101 | |||
| 102 | extern int atomic_notifier_call_chain(struct atomic_notifier_head *, | ||
| 103 | unsigned long val, void *v); | ||
| 104 | extern int blocking_notifier_call_chain(struct blocking_notifier_head *, | ||
| 105 | unsigned long val, void *v); | ||
| 106 | extern int raw_notifier_call_chain(struct raw_notifier_head *, | ||
| 107 | unsigned long val, void *v); | ||
| 27 | 108 | ||
| 28 | #define NOTIFY_DONE 0x0000 /* Don't care */ | 109 | #define NOTIFY_DONE 0x0000 /* Don't care */ |
| 29 | #define NOTIFY_OK 0x0001 /* Suits me */ | 110 | #define NOTIFY_OK 0x0001 /* Suits me */ |
| 30 | #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ | 111 | #define NOTIFY_STOP_MASK 0x8000 /* Don't call further */ |
| 31 | #define NOTIFY_BAD (NOTIFY_STOP_MASK|0x0002) /* Bad/Veto action */ | 112 | #define NOTIFY_BAD (NOTIFY_STOP_MASK|0x0002) |
| 113 | /* Bad/Veto action */ | ||
| 32 | /* | 114 | /* |
| 33 | * Clean way to return from the notifier and stop further calls. | 115 | * Clean way to return from the notifier and stop further calls. |
| 34 | */ | 116 | */ |
