]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
soc/tegra: pmc: Embed reboot notifier in PMC context
authorThierry Reding <treding@nvidia.com>
Mon, 3 Feb 2025 13:38:24 +0000 (14:38 +0100)
committerThierry Reding <treding@nvidia.com>
Sun, 18 Jan 2026 07:48:29 +0000 (08:48 +0100)
Instead of relying on a global variable to track the PMC context, embed
the reboot notifier into the PMC context so that the latter can be
resolved using container_of().

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

index ec364dda9f7545af15ad4b5e23db30123ad74808..9ec033d539e9ab17f8ae2bd5caadeddceac53db5 100644 (file)
@@ -470,6 +470,8 @@ struct tegra_pmc {
        unsigned long *wake_type_dual_edge_map;
        unsigned long *wake_sw_status_map;
        unsigned long *wake_cntrl_level_map;
+
+       struct notifier_block reboot_notifier;
        struct syscore syscore;
 
        /* Pending wake IRQ processing */
@@ -1103,7 +1105,8 @@ int tegra_pmc_cpu_remove_clamping(unsigned int cpuid)
        return tegra_powergate_remove_clamping(id);
 }
 
-static void tegra_pmc_program_reboot_reason(const char *cmd)
+static void tegra_pmc_program_reboot_reason(struct tegra_pmc *pmc,
+                                           const char *cmd)
 {
        u32 value;
 
@@ -1127,16 +1130,14 @@ static void tegra_pmc_program_reboot_reason(const char *cmd)
 static int tegra_pmc_reboot_notify(struct notifier_block *this,
                                   unsigned long action, void *data)
 {
+       struct tegra_pmc *pmc = container_of(this, struct tegra_pmc,
+                                            reboot_notifier);
        if (action == SYS_RESTART)
-               tegra_pmc_program_reboot_reason(data);
+               tegra_pmc_program_reboot_reason(pmc, data);
 
        return NOTIFY_DONE;
 }
 
-static struct notifier_block tegra_pmc_reboot_notifier = {
-       .notifier_call = tegra_pmc_reboot_notify,
-};
-
 static void tegra_pmc_restart(void)
 {
        u32 value;
@@ -2995,8 +2996,10 @@ static int tegra_pmc_probe(struct platform_device *pdev)
         * CPU without resetting everything else.
         */
        if (pmc->scratch) {
+               pmc->reboot_notifier.notifier_call = tegra_pmc_reboot_notify;
+
                err = devm_register_reboot_notifier(&pdev->dev,
-                                                   &tegra_pmc_reboot_notifier);
+                                                   &pmc->reboot_notifier);
                if (err) {
                        dev_err(&pdev->dev,
                                "unable to register reboot notifier, %d\n",