diff options
Diffstat (limited to 'include/linux/notifier.h')
-rw-r--r-- | include/linux/notifier.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/linux/notifier.h b/include/linux/notifier.h index be3f2bb6fcf3..fad7ff17e468 100644 --- a/include/linux/notifier.h +++ b/include/linux/notifier.h | |||
@@ -157,6 +157,19 @@ extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh, | |||
157 | */ | 157 | */ |
158 | #define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK) | 158 | #define NOTIFY_STOP (NOTIFY_OK|NOTIFY_STOP_MASK) |
159 | 159 | ||
160 | /* Encapsulate (negative) errno value (in particular, NOTIFY_BAD <=> EPERM). */ | ||
161 | static inline int notifier_from_errno(int err) | ||
162 | { | ||
163 | return NOTIFY_STOP_MASK | (NOTIFY_OK - err); | ||
164 | } | ||
165 | |||
166 | /* Restore (negative) errno value from notify return value. */ | ||
167 | static inline int notifier_to_errno(int ret) | ||
168 | { | ||
169 | ret &= ~NOTIFY_STOP_MASK; | ||
170 | return ret > NOTIFY_OK ? NOTIFY_OK - ret : 0; | ||
171 | } | ||
172 | |||
160 | /* | 173 | /* |
161 | * Declared notifiers so far. I can imagine quite a few more chains | 174 | * Declared notifiers so far. I can imagine quite a few more chains |
162 | * over time (eg laptop power reset chains, reboot chain (to clean | 175 | * over time (eg laptop power reset chains, reboot chain (to clean |