/* This is common code that is called for each state that we're entering. Run suspend notifiers, allocate a console and stop all processes.  */
static int suspend_prepare(void)
/* This is common code that is called for each state that we're entering. Run suspend notifiers, allocate a console and stop all processes.  */
static int suspend_prepare(void)
{
	int error;
	if (!suspend_ops || !suspend_ops->enter)
		return -EPERM;
	pm_prepare_console();
	error = pm_notifier_call_chain(PM_SUSPEND_PREPARE);
	if (error)
		goto Finish;
	error = usermodehelper_disable();
	if (error)
		goto Finish;
	error = suspend_freeze_processes();
	if (!error)
		return 0;
	suspend_thaw_processes();
	usermodehelper_enable();
 Finish:
	pm_notifier_call_chain(PM_POST_SUSPEND);
	pm_restore_console();
	return error;
}