1
0
Fork 0

kernel/sys.c: clean up sys_shutdown exit path

Impact: cleanup, fix

Clean up sys_shutdown() exit path.  Factor out common code.  Return
correct error code instead of always 0 on failure.

Signed-off-by: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
wifi-calibration
Andi Kleen 2009-04-13 14:40:08 -07:00 committed by Linus Torvalds
parent 4cafbd0b94
commit 3d26dcf767
1 changed files with 9 additions and 15 deletions

View File

@ -360,6 +360,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
void __user *, arg) void __user *, arg)
{ {
char buffer[256]; char buffer[256];
int ret = 0;
/* We only trust the superuser with rebooting the system. */ /* We only trust the superuser with rebooting the system. */
if (!capable(CAP_SYS_BOOT)) if (!capable(CAP_SYS_BOOT))
@ -397,7 +398,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
kernel_halt(); kernel_halt();
unlock_kernel(); unlock_kernel();
do_exit(0); do_exit(0);
break; panic("cannot halt");
case LINUX_REBOOT_CMD_POWER_OFF: case LINUX_REBOOT_CMD_POWER_OFF:
kernel_power_off(); kernel_power_off();
@ -417,29 +418,22 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
#ifdef CONFIG_KEXEC #ifdef CONFIG_KEXEC
case LINUX_REBOOT_CMD_KEXEC: case LINUX_REBOOT_CMD_KEXEC:
{ ret = kernel_kexec();
int ret; break;
ret = kernel_kexec();
unlock_kernel();
return ret;
}
#endif #endif
#ifdef CONFIG_HIBERNATION #ifdef CONFIG_HIBERNATION
case LINUX_REBOOT_CMD_SW_SUSPEND: case LINUX_REBOOT_CMD_SW_SUSPEND:
{ ret = hibernate();
int ret = hibernate(); break;
unlock_kernel();
return ret;
}
#endif #endif
default: default:
unlock_kernel(); ret = -EINVAL;
return -EINVAL; break;
} }
unlock_kernel(); unlock_kernel();
return 0; return ret;
} }
static void deferred_cad(struct work_struct *dummy) static void deferred_cad(struct work_struct *dummy)