Shutting down (built-in) linux from kernel space

I am working on a modified kernel version 2.6.35 for the Olinuxino platform based on ARM9. I am trying to change the power management driver (part related to architecture).

The processor is Freescale i.MX23. This processor has a β€œspecial” pin called PSWITCH, which triggers an interrupt that is processed by the power management driver. If the switch is pressed, the system goes into standby mode. This is done in the driver by calling pm_suspend(PM_SUSPEND_STANDBY) .

Given my hardware setup, I would like, instead, to shut down the system. So my question is:

What is the preferred way for the kernel-kernel process to start a clean system shutdown / shutdown?

I suppose there is a small little function there, but I could not find it so far.

My kernel code (the file I'm working on is arch / arm / mach-mx23 / pm.c) can be found here: github.com/spairal/linux-for-lobster , although my question requires a general Linux kernel approach.

+7
linux linux-kernel embedded-linux
source share
1 answer

The most common way for your driver is to call shutdown as a helper in user space:

 static const char * const shutdown_argv[] = { "/sbin/shutdown", "-h", "-P", "now", NULL }; call_usermodehelper(shutdown_argv[0], shutdown_argv, NULL, UMH_NO_WAIT); 

(Suppose you installed the binary /sbin/shutdown ). This will completely disable user space, disable file systems, and then ask you to turn the kernel off and on.

However, you can do it better, for example, if you can guarantee that no file systems on the disk have mounted read / write, you could say that the kernel thread calls the kernel_power_off() function (it should not be executed from the interrupt context).

+9
source share

All Articles