kernel: Add combined power-off+restart handler call chain API
authorDmitry Osipenko <digetx@gmail.com>
Sun, 30 Jan 2022 23:37:01 +0000 (02:37 +0300)
committerHector Martin <marcan@marcan.st>
Tue, 8 Feb 2022 05:49:05 +0000 (14:49 +0900)
commitd4c326600862cf161d7cd7dbc0bbf7f8cb01b500
tree31c402ea98c54f14ec47db50980705e9bc7523f3
parent83990432e84e28cbb445bfbaa6e05289c8909065
kernel: Add combined power-off+restart handler call chain API

SoC platforms often have multiple ways of how to perform system's
power-off and restart operations. Meanwhile today's kernel is limited to
a single option. Add combined power-off+restart handler call chain API,
which is inspired by the restart API. The new API provides both power-off
and restart functionality.

The old pm_power_off method will be kept around till all users are
converted to the new API.

Current restart API will be replaced by the new unified API since
new API is its superset. The restart functionality of the sys-off handler
API is built upon the existing restart-notifier APIs.

In order to ease conversion to the new API, convenient helpers are added
for the common use-cases. They will reduce amount of boilerplate code and
remove global variables. These helpers preserve old behaviour for cases
where only one power-off handler is expected, this is what all existing
drivers want, and thus, they could be easily converted to the new API.
Users of the new API should explicitly enable power-off chaining by
setting corresponding flag of the power_handler structure.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
include/linux/reboot.h
kernel/power/hibernate.c
kernel/reboot.c