From 48b7f802fb78f6f13c771c03fd6329c8a88e6991 Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Mon, 3 Feb 2025 14:38:24 +0100 Subject: [PATCH] soc/tegra: pmc: Embed reboot notifier in PMC context 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 --- drivers/soc/tegra/pmc.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c index ec364dda9f754..9ec033d539e9a 100644 --- a/drivers/soc/tegra/pmc.c +++ b/drivers/soc/tegra/pmc.c @@ -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", -- 2.47.3