Skip to content

Commit 48b7f80

Browse files
committed
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>
1 parent 0732dff commit 48b7f80

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

drivers/soc/tegra/pmc.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,8 @@ struct tegra_pmc {
470470
unsigned long *wake_type_dual_edge_map;
471471
unsigned long *wake_sw_status_map;
472472
unsigned long *wake_cntrl_level_map;
473+
474+
struct notifier_block reboot_notifier;
473475
struct syscore syscore;
474476

475477
/* Pending wake IRQ processing */
@@ -1103,7 +1105,8 @@ int tegra_pmc_cpu_remove_clamping(unsigned int cpuid)
11031105
return tegra_powergate_remove_clamping(id);
11041106
}
11051107

1106-
static void tegra_pmc_program_reboot_reason(const char *cmd)
1108+
static void tegra_pmc_program_reboot_reason(struct tegra_pmc *pmc,
1109+
const char *cmd)
11071110
{
11081111
u32 value;
11091112

@@ -1127,16 +1130,14 @@ static void tegra_pmc_program_reboot_reason(const char *cmd)
11271130
static int tegra_pmc_reboot_notify(struct notifier_block *this,
11281131
unsigned long action, void *data)
11291132
{
1133+
struct tegra_pmc *pmc = container_of(this, struct tegra_pmc,
1134+
reboot_notifier);
11301135
if (action == SYS_RESTART)
1131-
tegra_pmc_program_reboot_reason(data);
1136+
tegra_pmc_program_reboot_reason(pmc, data);
11321137

11331138
return NOTIFY_DONE;
11341139
}
11351140

1136-
static struct notifier_block tegra_pmc_reboot_notifier = {
1137-
.notifier_call = tegra_pmc_reboot_notify,
1138-
};
1139-
11401141
static void tegra_pmc_restart(void)
11411142
{
11421143
u32 value;
@@ -2995,8 +2996,10 @@ static int tegra_pmc_probe(struct platform_device *pdev)
29952996
* CPU without resetting everything else.
29962997
*/
29972998
if (pmc->scratch) {
2999+
pmc->reboot_notifier.notifier_call = tegra_pmc_reboot_notify;
3000+
29983001
err = devm_register_reboot_notifier(&pdev->dev,
2999-
&tegra_pmc_reboot_notifier);
3002+
&pmc->reboot_notifier);
30003003
if (err) {
30013004
dev_err(&pdev->dev,
30023005
"unable to register reboot notifier, %d\n",

0 commit comments

Comments
 (0)