power: reset: axxia-reset: Use devm_register_sys_off_handler(RESTART)
authorAndrew Davis <afd@ti.com>
Mon, 12 Feb 2024 16:28:20 +0000 (10:28 -0600)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Tue, 13 Feb 2024 01:17:25 +0000 (02:17 +0100)
Use device life-cycle managed register function to simplify probe.

Signed-off-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20240212162831.67838-9-afd@ti.com
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/reset/axxia-reset.c

index 24946766760c387ae2423690b53964e0dfdb9431..797bf6773860ed5da68b3a2df389e517db71742e 100644 (file)
 #define SC_EFUSE_INT_STATUS    0x180c
 #define   EFUSE_READ_DONE      (1<<31)
 
-static struct regmap *syscon;
-
-static int axxia_restart_handler(struct notifier_block *this,
-                                unsigned long mode, void *cmd)
+static int axxia_restart_handler(struct sys_off_data *data)
 {
+       struct regmap *syscon = data->cb_data;
+
        /* Access Key (0xab) */
        regmap_write(syscon, SC_CRIT_WRITE_KEY, 0xab);
        /* Select internal boot from 0xffff0000 */
@@ -44,14 +43,10 @@ static int axxia_restart_handler(struct notifier_block *this,
        return NOTIFY_DONE;
 }
 
-static struct notifier_block axxia_restart_nb = {
-       .notifier_call = axxia_restart_handler,
-       .priority = 128,
-};
-
 static int axxia_reset_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
+       struct regmap *syscon;
        int err;
 
        syscon = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon");
@@ -60,7 +55,8 @@ static int axxia_reset_probe(struct platform_device *pdev)
                return PTR_ERR(syscon);
        }
 
-       err = register_restart_handler(&axxia_restart_nb);
+       err = devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART,
+                                           128, axxia_restart_handler, syscon);
        if (err)
                dev_err(dev, "cannot register restart handler (err=%d)\n", err);