]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
soc/tegra: pmc: Pass PMC context via sys-off callback data
authorThierry Reding <treding@nvidia.com>
Mon, 3 Feb 2025 13:41:45 +0000 (14:41 +0100)
committerThierry Reding <treding@nvidia.com>
Sun, 18 Jan 2026 07:48:29 +0000 (08:48 +0100)
To avoid relying on global variables, use the sys-off callback data to
store a reference to the PMC context structure.

Signed-off-by: Thierry Reding <treding@nvidia.com>
drivers/soc/tegra/pmc.c

index 9ec033d539e9ab17f8ae2bd5caadeddceac53db5..cd7c557c886b5c5887109baac806d1f5f465d884 100644 (file)
@@ -1138,7 +1138,7 @@ static int tegra_pmc_reboot_notify(struct notifier_block *this,
        return NOTIFY_DONE;
 }
 
-static void tegra_pmc_restart(void)
+static void tegra_pmc_restart(struct tegra_pmc *pmc)
 {
        u32 value;
 
@@ -1150,13 +1150,17 @@ static void tegra_pmc_restart(void)
 
 static int tegra_pmc_restart_handler(struct sys_off_data *data)
 {
-       tegra_pmc_restart();
+       struct tegra_pmc *pmc = data->cb_data;
+
+       tegra_pmc_restart(pmc);
 
        return NOTIFY_DONE;
 }
 
 static int tegra_pmc_power_off_handler(struct sys_off_data *data)
 {
+       struct tegra_pmc *pmc = data->cb_data;
+
        /*
         * Reboot Nexus 7 into special bootloader mode if USB cable is
         * connected in order to display battery status and power off.
@@ -1166,7 +1170,7 @@ static int tegra_pmc_power_off_handler(struct sys_off_data *data)
                const u32 go_to_charger_mode = 0xa5a55a5a;
 
                tegra_pmc_writel(pmc, go_to_charger_mode, PMC_SCRATCH37);
-               tegra_pmc_restart();
+               tegra_pmc_restart(pmc);
        }
 
        return NOTIFY_DONE;
@@ -3011,7 +3015,8 @@ static int tegra_pmc_probe(struct platform_device *pdev)
        err = devm_register_sys_off_handler(&pdev->dev,
                                            SYS_OFF_MODE_RESTART,
                                            SYS_OFF_PRIO_LOW,
-                                           tegra_pmc_restart_handler, NULL);
+                                           tegra_pmc_restart_handler,
+                                           pmc);
        if (err) {
                dev_err(&pdev->dev, "failed to register sys-off handler: %d\n",
                        err);
@@ -3025,7 +3030,8 @@ static int tegra_pmc_probe(struct platform_device *pdev)
        err = devm_register_sys_off_handler(&pdev->dev,
                                            SYS_OFF_MODE_POWER_OFF,
                                            SYS_OFF_PRIO_FIRMWARE,
-                                           tegra_pmc_power_off_handler, NULL);
+                                           tegra_pmc_power_off_handler,
+                                           pmc);
        if (err) {
                dev_err(&pdev->dev, "failed to register sys-off handler: %d\n",
                        err);