PM: Improve error code of pm_notifier_call_chain()
Akinobu Mita [Fri, 8 Jul 2011 18:53:36 +0000 (20:53 +0200)]
This enables pm_notifier_call_chain() to get the actual error code
in the callback rather than always assume -EINVAL by converting all
PM notifier calls to return encapsulate error code with
notifier_from_errno().

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>

drivers/char/apm-emulation.c
drivers/s390/char/vmwatchdog.c
drivers/s390/cio/css.c
kernel/power/main.c

index 548708c..a7346ab 100644 (file)
@@ -606,7 +606,7 @@ static int apm_suspend_notifier(struct notifier_block *nb,
                        return NOTIFY_OK;
 
                /* interrupted by signal */
-               return NOTIFY_BAD;
+               return notifier_from_errno(err);
 
        case PM_POST_SUSPEND:
                /*
index 12ef912..11312f4 100644 (file)
@@ -258,13 +258,13 @@ static int vmwdt_suspend(void)
        if (test_and_set_bit(VMWDT_OPEN, &vmwdt_is_open)) {
                pr_err("The system cannot be suspended while the watchdog"
                        " is in use\n");
-               return NOTIFY_BAD;
+               return notifier_from_errno(-EBUSY);
        }
        if (test_bit(VMWDT_RUNNING, &vmwdt_is_open)) {
                clear_bit(VMWDT_OPEN, &vmwdt_is_open);
                pr_err("The system cannot be suspended while the watchdog"
                        " is running\n");
-               return NOTIFY_BAD;
+               return notifier_from_errno(-EBUSY);
        }
        return NOTIFY_DONE;
 }
index c47b25f..92d7324 100644 (file)
@@ -814,8 +814,8 @@ static int css_power_event(struct notifier_block *this, unsigned long event,
                                mutex_unlock(&css->mutex);
                                continue;
                        }
-                       if (__chsc_do_secm(css, 0))
-                               ret = NOTIFY_BAD;
+                       ret = __chsc_do_secm(css, 0);
+                       ret = notifier_from_errno(ret);
                        mutex_unlock(&css->mutex);
                }
                break;
@@ -831,8 +831,8 @@ static int css_power_event(struct notifier_block *this, unsigned long event,
                                mutex_unlock(&css->mutex);
                                continue;
                        }
-                       if (__chsc_do_secm(css, 1))
-                               ret = NOTIFY_BAD;
+                       ret = __chsc_do_secm(css, 1);
+                       ret = notifier_from_errno(ret);
                        mutex_unlock(&css->mutex);
                }
                /* search for subchannels, which appeared during hibernation */
index 2981af4..6c601f8 100644 (file)
@@ -37,8 +37,9 @@ EXPORT_SYMBOL_GPL(unregister_pm_notifier);
 
 int pm_notifier_call_chain(unsigned long val)
 {
-       return (blocking_notifier_call_chain(&pm_chain_head, val, NULL)
-                       == NOTIFY_BAD) ? -EINVAL : 0;
+       int ret = blocking_notifier_call_chain(&pm_chain_head, val, NULL);
+
+       return notifier_to_errno(ret);
 }
 
 /* If set, devices may be suspended and resumed asynchronously. */