forked from Minki/linux
kernel/reboot: Add kernel_can_power_off()
Add kernel_can_power_off() helper that replaces open-coded checks of the global pm_power_off variable. This is a necessary step towards supporting chained power-off handlers. Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
5d34b41aa4
commit
0e2110d2e9
@ -149,6 +149,7 @@ extern void kernel_restart_prepare(char *cmd);
|
||||
extern void kernel_restart(char *cmd);
|
||||
extern void kernel_halt(void);
|
||||
extern void kernel_power_off(void);
|
||||
extern bool kernel_can_power_off(void);
|
||||
|
||||
extern int C_A_D; /* for sysctl */
|
||||
void ctrl_alt_del(void);
|
||||
|
@ -523,6 +523,18 @@ void do_kernel_power_off(void)
|
||||
atomic_notifier_call_chain(&power_off_handler_list, 0, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* kernel_can_power_off - check whether system can be powered off
|
||||
*
|
||||
* Returns true if power-off handler is registered and system can be
|
||||
* powered off, false otherwise.
|
||||
*/
|
||||
bool kernel_can_power_off(void)
|
||||
{
|
||||
return !atomic_notifier_call_chain_is_empty(&power_off_handler_list);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(kernel_can_power_off);
|
||||
|
||||
/**
|
||||
* kernel_power_off - power_off the system
|
||||
*
|
||||
@ -581,7 +593,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
|
||||
/* Instead of trying to make the power_off code look like
|
||||
* halt when pm_power_off is not set do it the easy way.
|
||||
*/
|
||||
if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
|
||||
if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !kernel_can_power_off())
|
||||
cmd = LINUX_REBOOT_CMD_HALT;
|
||||
|
||||
mutex_lock(&system_transition_mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user