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>
Sat, 19 Feb 2022 08:06:38 +0000 (17:06 +0900)
commit2599b92d41a2eb2df24752bf6cb2802f80920a52
treef9bef95f875ff15ba17596632552749bfd891b0b
parentb506696f368cfa424873b8bf7b73e394f806b548
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