reboot: Introduce kernel pre restart handler call chain

This patch renames kernel_i2c_restart to kernel_pre_restart
for general purpose.

This call chain is expected to be executed before kernel_restart
to do something before reset system. such as, i2c restart,
boot mode config.

Change-Id: I67c80c297ca5de83deb4736b5dab0f2c9c8543a6
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
This commit is contained in:
Sugar Zhang
2021-01-05 18:33:46 +08:00
committed by Tao Huang
parent 385f6d70a7
commit e656a9a56a
5 changed files with 16 additions and 16 deletions

View File

@@ -141,7 +141,7 @@ void machine_restart(char *cmd)
local_irq_disable();
smp_send_stop();
do_kernel_i2c_restart(cmd);
do_kernel_pre_restart(cmd);
if (arm_pm_restart)
arm_pm_restart(reboot_mode, cmd);

View File

@@ -164,7 +164,7 @@ void machine_restart(char *cmd)
local_irq_disable();
smp_send_stop();
do_kernel_i2c_restart(cmd);
do_kernel_pre_restart(cmd);
/*
* UpdateCapsule() depends on the system being reset via

View File

@@ -1315,7 +1315,7 @@ static int rk3x_i2c_probe(struct platform_device *pdev)
i2c->i2c_restart_nb.notifier_call = rk3x_i2c_restart_notify;
i2c->i2c_restart_nb.priority = 128;
ret = register_i2c_restart_handler(&i2c->i2c_restart_nb);
ret = register_pre_restart_handler(&i2c->i2c_restart_nb);
if (ret) {
dev_err(&pdev->dev, "failed to setup i2c restart handler.\n");
return ret;
@@ -1446,7 +1446,7 @@ static int rk3x_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(&i2c->adap);
clk_notifier_unregister(i2c->clk, &i2c->clk_rate_nb);
unregister_i2c_restart_handler(&i2c->i2c_restart_nb);
unregister_pre_restart_handler(&i2c->i2c_restart_nb);
clk_unprepare(i2c->pclk);
clk_unprepare(i2c->clk);

View File

@@ -49,9 +49,9 @@ extern int register_restart_handler(struct notifier_block *);
extern int unregister_restart_handler(struct notifier_block *);
extern void do_kernel_restart(char *cmd);
extern int register_i2c_restart_handler(struct notifier_block *);
extern int unregister_i2c_restart_handler(struct notifier_block *);
extern void do_kernel_i2c_restart(char *cmd);
extern int register_pre_restart_handler(struct notifier_block *);
extern int unregister_pre_restart_handler(struct notifier_block *);
extern void do_kernel_pre_restart(char *cmd);
/*
* Architecture-specific implementations of sys_reboot commands.

View File

@@ -213,23 +213,23 @@ void do_kernel_restart(char *cmd)
atomic_notifier_call_chain(&restart_handler_list, reboot_mode, cmd);
}
static ATOMIC_NOTIFIER_HEAD(i2c_restart_handler_list);
static ATOMIC_NOTIFIER_HEAD(pre_restart_handler_list);
int register_i2c_restart_handler(struct notifier_block *nb)
int register_pre_restart_handler(struct notifier_block *nb)
{
return atomic_notifier_chain_register(&i2c_restart_handler_list, nb);
return atomic_notifier_chain_register(&pre_restart_handler_list, nb);
}
EXPORT_SYMBOL(register_i2c_restart_handler);
EXPORT_SYMBOL(register_pre_restart_handler);
int unregister_i2c_restart_handler(struct notifier_block *nb)
int unregister_pre_restart_handler(struct notifier_block *nb)
{
return atomic_notifier_chain_unregister(&i2c_restart_handler_list, nb);
return atomic_notifier_chain_unregister(&pre_restart_handler_list, nb);
}
EXPORT_SYMBOL(unregister_i2c_restart_handler);
EXPORT_SYMBOL(unregister_pre_restart_handler);
void do_kernel_i2c_restart(char *cmd)
void do_kernel_pre_restart(char *cmd)
{
atomic_notifier_call_chain(&i2c_restart_handler_list, reboot_mode, cmd);
atomic_notifier_call_chain(&pre_restart_handler_list, reboot_mode, cmd);
}
void migrate_to_reboot_cpu(void)