Skip to content

Commit

Permalink
notifier: change notifier_from_errno(0) to return NOTIFY_OK
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Akinobu Mita authored and Linus Torvalds committed May 27, 2010
1 parent e6bde73 commit b957e04
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/linux/notifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down

0 comments on commit b957e04

Please sign in to comment.