Skip to content

Commit da48b67

Browse files
committed
LoongArch: Cleanup reset routines with new API
Cleanup reset routines by using new do_kernel_power_off() instead of old pm_power_off(), and then simplify the whole file (reset.c) organization by inlining some functions. This cleanup also fix a poweroff error if EFI runtime is disabled. Signed-off-by: Huacai Chen <[email protected]>
1 parent 84e7620 commit da48b67

File tree

2 files changed

+21
-58
lines changed

2 files changed

+21
-58
lines changed

arch/loongarch/include/asm/reboot.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

arch/loongarch/kernel/reset.c

Lines changed: 21 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,16 @@
1515
#include <acpi/reboot.h>
1616
#include <asm/idle.h>
1717
#include <asm/loongarch.h>
18-
#include <asm/reboot.h>
1918

20-
static void default_halt(void)
19+
void (*pm_power_off)(void);
20+
EXPORT_SYMBOL(pm_power_off);
21+
22+
void machine_halt(void)
2123
{
24+
#ifdef CONFIG_SMP
25+
preempt_disable();
26+
smp_send_stop();
27+
#endif
2228
local_irq_disable();
2329
clear_csr_ecfg(ECFG0_IM);
2430

@@ -30,18 +36,29 @@ static void default_halt(void)
3036
}
3137
}
3238

33-
static void default_poweroff(void)
39+
void machine_power_off(void)
3440
{
41+
#ifdef CONFIG_SMP
42+
preempt_disable();
43+
smp_send_stop();
44+
#endif
45+
do_kernel_power_off();
3546
#ifdef CONFIG_EFI
3647
efi.reset_system(EFI_RESET_SHUTDOWN, EFI_SUCCESS, 0, NULL);
3748
#endif
49+
3850
while (true) {
3951
__arch_cpu_idle();
4052
}
4153
}
4254

43-
static void default_restart(void)
55+
void machine_restart(char *command)
4456
{
57+
#ifdef CONFIG_SMP
58+
preempt_disable();
59+
smp_send_stop();
60+
#endif
61+
do_kernel_restart(command);
4562
#ifdef CONFIG_EFI
4663
if (efi_capsule_pending(NULL))
4764
efi_reboot(REBOOT_WARM, NULL);
@@ -55,47 +72,3 @@ static void default_restart(void)
5572
__arch_cpu_idle();
5673
}
5774
}
58-
59-
void (*pm_restart)(void);
60-
EXPORT_SYMBOL(pm_restart);
61-
62-
void (*pm_power_off)(void);
63-
EXPORT_SYMBOL(pm_power_off);
64-
65-
void machine_halt(void)
66-
{
67-
#ifdef CONFIG_SMP
68-
preempt_disable();
69-
smp_send_stop();
70-
#endif
71-
default_halt();
72-
}
73-
74-
void machine_power_off(void)
75-
{
76-
#ifdef CONFIG_SMP
77-
preempt_disable();
78-
smp_send_stop();
79-
#endif
80-
pm_power_off();
81-
}
82-
83-
void machine_restart(char *command)
84-
{
85-
#ifdef CONFIG_SMP
86-
preempt_disable();
87-
smp_send_stop();
88-
#endif
89-
do_kernel_restart(command);
90-
pm_restart();
91-
}
92-
93-
static int __init loongarch_reboot_setup(void)
94-
{
95-
pm_restart = default_restart;
96-
pm_power_off = default_poweroff;
97-
98-
return 0;
99-
}
100-
101-
arch_initcall(loongarch_reboot_setup);

0 commit comments

Comments
 (0)