Skip to content

Commit a9f822b

Browse files
committed
soc/tegra: pmc: Pass PMC context via sys-off callback data
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>
1 parent 48b7f80 commit a9f822b

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

drivers/soc/tegra/pmc.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,7 @@ static int tegra_pmc_reboot_notify(struct notifier_block *this,
11381138
return NOTIFY_DONE;
11391139
}
11401140

1141-
static void tegra_pmc_restart(void)
1141+
static void tegra_pmc_restart(struct tegra_pmc *pmc)
11421142
{
11431143
u32 value;
11441144

@@ -1150,13 +1150,17 @@ static void tegra_pmc_restart(void)
11501150

11511151
static int tegra_pmc_restart_handler(struct sys_off_data *data)
11521152
{
1153-
tegra_pmc_restart();
1153+
struct tegra_pmc *pmc = data->cb_data;
1154+
1155+
tegra_pmc_restart(pmc);
11541156

11551157
return NOTIFY_DONE;
11561158
}
11571159

11581160
static int tegra_pmc_power_off_handler(struct sys_off_data *data)
11591161
{
1162+
struct tegra_pmc *pmc = data->cb_data;
1163+
11601164
/*
11611165
* Reboot Nexus 7 into special bootloader mode if USB cable is
11621166
* 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)
11661170
const u32 go_to_charger_mode = 0xa5a55a5a;
11671171

11681172
tegra_pmc_writel(pmc, go_to_charger_mode, PMC_SCRATCH37);
1169-
tegra_pmc_restart();
1173+
tegra_pmc_restart(pmc);
11701174
}
11711175

11721176
return NOTIFY_DONE;
@@ -3011,7 +3015,8 @@ static int tegra_pmc_probe(struct platform_device *pdev)
30113015
err = devm_register_sys_off_handler(&pdev->dev,
30123016
SYS_OFF_MODE_RESTART,
30133017
SYS_OFF_PRIO_LOW,
3014-
tegra_pmc_restart_handler, NULL);
3018+
tegra_pmc_restart_handler,
3019+
pmc);
30153020
if (err) {
30163021
dev_err(&pdev->dev, "failed to register sys-off handler: %d\n",
30173022
err);
@@ -3025,7 +3030,8 @@ static int tegra_pmc_probe(struct platform_device *pdev)
30253030
err = devm_register_sys_off_handler(&pdev->dev,
30263031
SYS_OFF_MODE_POWER_OFF,
30273032
SYS_OFF_PRIO_FIRMWARE,
3028-
tegra_pmc_power_off_handler, NULL);
3033+
tegra_pmc_power_off_handler,
3034+
pmc);
30293035
if (err) {
30303036
dev_err(&pdev->dev, "failed to register sys-off handler: %d\n",
30313037
err);

0 commit comments

Comments
 (0)