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)
committerJens Axboe <axboe@kernel.dk>
Tue, 1 Mar 2022 17:52:31 +0000 (10:52 -0700)
commit8b15d38bbf69a605dbf77335423d6dee90a9f8b7
tree78f157f781eb679c5af443c16f91edcd11fa8f8d
parentb6aae4277be80f758532dee78b003a7ce7ec9e87
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