summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Reding <treding@nvidia.com>2025-02-03 16:38:24 +0300
committerThierry Reding <treding@nvidia.com>2026-01-18 10:48:29 +0300
commit48b7f802fb78f6f13c771c03fd6329c8a88e6991 (patch)
tree94478b5685fd8bd54e71bd003bc60dd1f2f9540f
parent0732dffeb093064b7954a48362ec83a25262878b (diff)
downloadlinux-48b7f802fb78f6f13c771c03fd6329c8a88e6991.tar.xz
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 <treding@nvidia.com>
-rw-r--r--drivers/soc/tegra/pmc.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index ec364dda9f75..9ec033d539e9 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",