@@ -13,6 +13,7 @@
#include <linux/kexec.h>
#include <linux/kmod.h>
#include <linux/kmsg_dump.h>
+#include <linux/pm.h>
#include <linux/reboot.h>
#include <linux/suspend.h>
#include <linux/syscalls.h>
@@ -305,6 +306,17 @@ static void kernel_shutdown_prepare(enum system_states state)
(state == SYSTEM_HALT) ? SYS_HALT : SYS_POWER_OFF, NULL);
system_state = state;
usermodehelper_disable();
+#ifdef CONFIG_HIBERNATE_CALLBACKS
+ if (dpm_suspend_start(PMSG_HIBERNATE))
+ goto resume_devices;
+ if (dpm_suspend_end(PMSG_HIBERNATE))
+ goto resume_devices;
+ return;
+
+resume_devices:
+ pr_emerg("Failed to power off devices, using shutdown instead.\n");
+ dpm_resume_end(PMSG_RESTORE);
+#endif
device_shutdown();
}
/**