]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - include/linux/notifier.h
Merge branch 'async-tx-fixes-for-linus' of git://lost.foo-projects.org/~dwillia2...
[linux-2.6-omap-h63xx.git] / include / linux / notifier.h
index be3f2bb6fcf39a6b4b911bb71158d04ef246bdb6..fad7ff17e468ded82fc2e797bc42f6bb4a2f95fe 100644 (file)
@@ -157,6 +157,19 @@ extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
  */
 #define NOTIFY_STOP            (NOTIFY_OK|NOTIFY_STOP_MASK)
 
+/* Encapsulate (negative) errno value (in particular, NOTIFY_BAD <=> EPERM). */
+static inline int notifier_from_errno(int err)
+{
+       return NOTIFY_STOP_MASK | (NOTIFY_OK - err);
+}
+
+/* Restore (negative) errno value from notify return value. */
+static inline int notifier_to_errno(int ret)
+{
+       ret &= ~NOTIFY_STOP_MASK;
+       return ret > NOTIFY_OK ? NOTIFY_OK - ret : 0;
+}
+
 /*
  *     Declared notifiers so far. I can imagine quite a few more chains
  *     over time (eg laptop power reset chains, reboot chain (to clean