Skip to content

Commit 3320648

Browse files
Christoph Hellwigpaul-walmsley-sifive
authored andcommitted
riscv: cleanup the default power off implementation
Move the sbi poweroff to a separate function and file that is only compiled if CONFIG_SBI is set. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Anup Patel <[email protected]> Reviewed-by: Atish Patra <[email protected]> [[email protected]: split the WFI fix into a separate patch] Signed-off-by: Paul Walmsley <[email protected]>
1 parent 3b03ac6 commit 3320648

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

arch/riscv/kernel/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ obj-$(CONFIG_DYNAMIC_FTRACE) += mcount-dyn.o
4141
obj-$(CONFIG_PERF_EVENTS) += perf_event.o
4242
obj-$(CONFIG_PERF_EVENTS) += perf_callchain.o
4343
obj-$(CONFIG_HAVE_PERF_REGS) += perf_regs.o
44+
obj-$(CONFIG_RISCV_SBI) += sbi.o
4445

4546
clean:

arch/riscv/kernel/reset.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55

66
#include <linux/reboot.h>
77
#include <linux/pm.h>
8-
#include <asm/sbi.h>
98

109
static void default_power_off(void)
1110
{
12-
sbi_shutdown();
1311
while (1)
1412
wait_for_interrupt();
1513
}

arch/riscv/kernel/sbi.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
3+
#include <linux/init.h>
4+
#include <linux/pm.h>
5+
#include <asm/sbi.h>
6+
7+
static void sbi_power_off(void)
8+
{
9+
sbi_shutdown();
10+
}
11+
12+
static int __init sbi_init(void)
13+
{
14+
pm_power_off = sbi_power_off;
15+
return 0;
16+
}
17+
early_initcall(sbi_init);

0 commit comments

Comments
 (0)