From 069c5dbf40f8b9b3fee2e315381881f5ce7eff39 Mon Sep 17 00:00:00 2001 From: Dmitry Osipenko <dmitry.osipenko@collabora.com> Date: Thu, 7 Oct 2021 05:43:50 +0300 Subject: [PATCH] reboot: Make unique priority requirement mandatory for sys-off handlers There are no power-off/restart handlers left in kernel that use conflicting priorities. Make the unique priority requirement mandatory for sys-off handlers. Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> --- kernel/reboot.c | 40 ++++------------------------------------ 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/kernel/reboot.c b/kernel/reboot.c index 687de1a72034b..ceca51aed998d 100644 --- a/kernel/reboot.c +++ b/kernel/reboot.c @@ -170,27 +170,11 @@ static ATOMIC_NOTIFIER_HEAD(restart_handler_list); * hardware is expected to register with low priority to ensure that * it only runs if no other means to restart the system is available. * - * Currently always returns zero, as atomic_notifier_chain_register() - * always returns zero. + * Returns zero on success, -EBUSY otherwise. */ static int register_restart_handler(struct notifier_block *nb) { - int ret; - - ret = atomic_notifier_chain_register_unique_prio(&restart_handler_list, nb); - if (ret != -EBUSY) - return ret; - - /* - * Handler must have unique priority. Otherwise call order is - * determined by registration order, which is unreliable. - * - * This requirement will become mandatory once all drivers - * will be converted to use new sys-off API. - */ - pr_err("failed to register restart handler using unique priority\n"); - - return atomic_notifier_chain_register(&restart_handler_list, nb); + return atomic_notifier_chain_register_unique_prio(&restart_handler_list, nb); } /** @@ -329,27 +313,11 @@ static BLOCKING_NOTIFIER_HEAD(power_off_handler_list); * that it only runs if no other means to power off the system is * available. * - * Currently always returns zero, as blocking_notifier_chain_register() - * always returns zero. + * Returns zero on success, -EBUSY otherwise. */ static int register_power_off_handler(struct notifier_block *nb) { - int ret; - - ret = blocking_notifier_chain_register_unique_prio(&power_off_handler_list, nb); - if (ret != -EBUSY) - return ret; - - /* - * Handler must have unique priority. Otherwise call order is - * determined by registration order, which is unreliable. - * - * This requirement will become mandatory once all drivers - * will be converted to use new sys-off API. - */ - pr_err("failed to register power-off handler using unique priority\n"); - - return blocking_notifier_chain_register(&power_off_handler_list, nb); + return blocking_notifier_chain_register_unique_prio(&power_off_handler_list, nb); } static int unregister_power_off_handler(struct notifier_block *nb) -- GitLab