From a56fae1ad5a9c040bcfd3f050db8fee42c6e2a1a Mon Sep 17 00:00:00 2001
From: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Date: Tue, 2 Nov 2021 17:35:20 +0300
Subject: [PATCH] reboot: Remove pm_power_off

All users of pm_power_off() have been converted to new sys-off API.
Remove deprecated pm_power_off().

Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
---
 include/linux/pm.h |  5 -----
 kernel/reboot.c    | 49 +++-------------------------------------------
 2 files changed, 3 insertions(+), 51 deletions(-)

diff --git a/include/linux/pm.h b/include/linux/pm.h
index 6cdf279c7f2fd..627e15f230848 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -17,11 +17,6 @@
 #include <linux/hrtimer.h>
 #include <linux/completion.h>
 
-/*
- * Callbacks for platform drivers to implement.
- */
-extern void (*pm_power_off)(void);
-
 struct device; /* we have a circular dep with device.h */
 #ifdef CONFIG_VT_CONSOLE_SLEEP
 extern void pm_vt_switch_required(struct device *dev, bool required);
diff --git a/kernel/reboot.c b/kernel/reboot.c
index 3053429df024a..687de1a72034b 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -293,19 +293,6 @@ EXPORT_SYMBOL_GPL(kernel_halt);
  */
 static BLOCKING_NOTIFIER_HEAD(power_off_handler_list);
 
-/*
- * Temporary stub that prevents linkage failure while we're in process
- * of removing all uses of legacy pm_power_off() around the kernel.
- */
-void __weak (*pm_power_off)(void);
-
-static void dummy_pm_power_off(void)
-{
-	/* temporary stub until pm_power_off() is gone, see more below */
-}
-
-static struct notifier_block *pm_power_off_nb;
-
 /**
  *	register_power_off_handler - Register function to be called to power off
  *				     the system
@@ -350,12 +337,9 @@ 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 && ret != -EBUSY)
+	if (ret != -EBUSY)
 		return ret;
 
-	if (!ret)
-		goto set_pm_power_off;
-
 	/*
 	 * Handler must have unique priority. Otherwise call order is
 	 * determined by registration order, which is unreliable.
@@ -365,33 +349,11 @@ static int register_power_off_handler(struct notifier_block *nb)
 	 */
 	pr_err("failed to register power-off handler using unique priority\n");
 
-	ret = blocking_notifier_chain_register(&power_off_handler_list, nb);
-	if (ret)
-		return ret;
-
-	/*
-	 * Some drivers check whether pm_power_off was already installed.
-	 * Install dummy callback using new API to preserve old behaviour
-	 * for those drivers during period of transition to the new API.
-	 */
-set_pm_power_off:
-	if (!pm_power_off) {
-		pm_power_off = dummy_pm_power_off;
-		pm_power_off_nb = nb;
-	}
-
-	return 0;
+	return blocking_notifier_chain_register(&power_off_handler_list, nb);
 }
 
 static int unregister_power_off_handler(struct notifier_block *nb)
 {
-	if (nb == pm_power_off_nb) {
-		if (pm_power_off == dummy_pm_power_off)
-			pm_power_off = NULL;
-
-		pm_power_off_nb = NULL;
-	}
-
 	return blocking_notifier_chain_unregister(&power_off_handler_list, nb);
 }
 
@@ -858,10 +820,6 @@ EXPORT_SYMBOL_GPL(unregister_platform_power_off);
  */
 void do_kernel_power_off(void)
 {
-	/* legacy pm_power_off() is unchained and has highest priority */
-	if (pm_power_off && pm_power_off != dummy_pm_power_off)
-		return pm_power_off();
-
 	blocking_notifier_call_chain(&power_off_handler_list, POWEROFF_NORMAL,
 				     NULL);
 }
@@ -891,8 +849,7 @@ EXPORT_SYMBOL_GPL(kernel_power_off);
 
 bool kernel_can_power_off(void)
 {
-	if (!pm_power_off &&
-	    blocking_notifier_call_chain_is_empty(&power_off_handler_list))
+	if (blocking_notifier_call_chain_is_empty(&power_off_handler_list))
 		return false;
 
 	return true;
-- 
GitLab