Skip to content
Snippets Groups Projects
Commit 368ac411 authored by Dmitry Osipenko's avatar Dmitry Osipenko
Browse files

riscv: sbi: Use sys-off handler


Replace restart handler with sys-off handler. Restart handler might
deprecated once all users are switched to sys-off handler, this allows
removes some boilerplate code and provides more features.

Signed-off-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
parent 83fe95a8
No related branches found
No related tags found
No related merge requests found
...@@ -559,24 +559,26 @@ static void sbi_srst_reset(unsigned long type, unsigned long reason) ...@@ -559,24 +559,26 @@ static void sbi_srst_reset(unsigned long type, unsigned long reason)
__func__, type, reason); __func__, type, reason);
} }
static int sbi_srst_reboot(struct notifier_block *this, static void sbi_srst_reboot(struct restart_data *data)
unsigned long mode, void *cmd)
{ {
sbi_srst_reset((mode == REBOOT_WARM || mode == REBOOT_SOFT) ? sbi_srst_reset((data->mode == REBOOT_WARM || data->mode == REBOOT_SOFT) ?
SBI_SRST_RESET_TYPE_WARM_REBOOT : SBI_SRST_RESET_TYPE_WARM_REBOOT :
SBI_SRST_RESET_TYPE_COLD_REBOOT, SBI_SRST_RESET_TYPE_COLD_REBOOT,
SBI_SRST_RESET_REASON_NONE); SBI_SRST_RESET_REASON_NONE);
return NOTIFY_DONE;
} }
static struct notifier_block sbi_srst_reboot_nb; static void sbi_srst_power_off(struct power_off_data *data)
static void sbi_srst_power_off(void)
{ {
sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN, sbi_srst_reset(SBI_SRST_RESET_TYPE_SHUTDOWN,
SBI_SRST_RESET_REASON_NONE); SBI_SRST_RESET_REASON_NONE);
} }
static struct sys_off_handler sbi_sys_off = {
.power_off_cb = sbi_srst_power_off,
.restart_cb = sbi_srst_reboot,
.restart_priority = RESTART_PRIO_HIGH,
};
/** /**
* sbi_probe_extension() - Check if an SBI extension ID is supported or not. * sbi_probe_extension() - Check if an SBI extension ID is supported or not.
* @extid: The extension ID to be probed. * @extid: The extension ID to be probed.
...@@ -683,10 +685,7 @@ void __init sbi_init(void) ...@@ -683,10 +685,7 @@ void __init sbi_init(void)
if ((sbi_spec_version >= sbi_mk_version(0, 3)) && if ((sbi_spec_version >= sbi_mk_version(0, 3)) &&
(sbi_probe_extension(SBI_EXT_SRST) > 0)) { (sbi_probe_extension(SBI_EXT_SRST) > 0)) {
pr_info("SBI SRST extension detected\n"); pr_info("SBI SRST extension detected\n");
pm_power_off = sbi_srst_power_off; register_sys_off_handler(&sbi_sys_off);
sbi_srst_reboot_nb.notifier_call = sbi_srst_reboot;
sbi_srst_reboot_nb.priority = 192;
register_restart_handler(&sbi_srst_reboot_nb);
} }
} else { } else {
__sbi_set_timer = __sbi_set_timer_v01; __sbi_set_timer = __sbi_set_timer_v01;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment