[PATCH] uml: Use ARRAY_SIZE more assiduously
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / arch / um / kernel / reboot.c
CommitLineData
1da177e4
LT
1/*
2 * Copyright (C) 2000, 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#include "linux/module.h"
7#include "linux/sched.h"
72e55257 8#include "asm/smp.h"
1da177e4
LT
9#include "user_util.h"
10#include "kern_util.h"
11#include "kern.h"
12#include "os.h"
13#include "mode.h"
14#include "choose-mode.h"
15
5e38291d
EB
16void (*pm_power_off)(void);
17
1da177e4
LT
18#ifdef CONFIG_SMP
19static void kill_idlers(int me)
20{
21#ifdef CONFIG_MODE_TT
22 struct task_struct *p;
23 int i;
24
91b165c0 25 for(i = 0; i < ARRAY_SIZE(idle_threads); i++){
1da177e4
LT
26 p = idle_threads[i];
27 if((p != NULL) && (p->thread.mode.tt.extern_pid != me))
28 os_kill_process(p->thread.mode.tt.extern_pid, 0);
29 }
30#endif
31}
32#endif
33
34static void kill_off_processes(void)
35{
36 CHOOSE_MODE(kill_off_processes_tt(), kill_off_processes_skas());
37#ifdef CONFIG_SMP
38 kill_idlers(os_getpid());
39#endif
40}
41
42void uml_cleanup(void)
43{
026549d2 44 kmalloc_ok = 0;
1da177e4 45 do_uml_exitcalls();
026549d2 46 kill_off_processes();
1da177e4
LT
47}
48
49void machine_restart(char * __unused)
50{
026549d2 51 uml_cleanup();
1da177e4
LT
52 CHOOSE_MODE(reboot_tt(), reboot_skas());
53}
54
1da177e4
LT
55void machine_power_off(void)
56{
026549d2 57 uml_cleanup();
1da177e4
LT
58 CHOOSE_MODE(halt_tt(), halt_skas());
59}
60
1da177e4
LT
61void machine_halt(void)
62{
63 machine_power_off();
64}