[PATCH 03/12] notifier: change notifier_from_errno(0) to return NOTIFY_OK

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Akinobu Mita
Date: Thursday, March 18, 2010 - 2:05 am

This changes notifier_from_errno(0) to be NOTIFY_OK instead of
NOTIFY_STOP_MASK | NOTIFY_OK.

Currently, the notifiers which return encapsulated errno value have to
do something like this:

	err = do_something(); // returns -errno
	if (err)
		return notifier_from_errno(err);
	else
		return NOTIFY_OK;

This change makes the above code simple:

	err = do_something(); // returns -errno

	return return notifier_from_errno(err);

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
---
 include/linux/notifier.h |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index fee6c2f..9e4831d 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -164,7 +164,10 @@ extern int __srcu_notifier_call_chain(struct srcu_notifier_head *nh,
 /* Encapsulate (negative) errno value (in particular, NOTIFY_BAD <=> EPERM). */
 static inline int notifier_from_errno(int err)
 {
-	return NOTIFY_STOP_MASK | (NOTIFY_OK - err);
+	if (err)
+		return NOTIFY_STOP_MASK | (NOTIFY_OK - err);
+
+	return NOTIFY_OK;
 }
 
 /* Restore (negative) errno value from notify return value. */
-- 
1.6.0.6

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 03/12] notifier: change notifier_from_errno(0) to r ..., Akinobu Mita, (Thu Mar 18, 2:05 am)
[PATCH 12/12] add CPU notifier error injection module, Akinobu Mita, (Thu Mar 18, 2:05 am)
Re: [PATCH 12/12] add CPU notifier error injection module, Andrew Morton, (Mon Mar 22, 2:48 pm)
Re: [PATCH 09/12] ehca: convert cpu notifier to return enc ..., Alexander Schmidt, (Mon Mar 29, 1:47 am)