Example #1
0
		machine_restart(NULL);

	restore_toi_state(orig_state);
	if (continue_req)
		set_toi_state(TOI_CONTINUE_REQ);
}
EXPORT_SYMBOL_GPL(toi_early_boot_message);
#undef say

/*
 * User interface specific /sys/power/tuxonice entries.
 */

static struct toi_sysfs_data sysfs_params[] = {
#if defined(CONFIG_NET) && defined(CONFIG_SYSFS)
	SYSFS_INT("default_console_level", SYSFS_RW,
			&toi_bkd.toi_default_console_level, 0, 7, 0, NULL),
	SYSFS_UL("debug_sections", SYSFS_RW, &toi_bkd.toi_debug_state, 0,
			1 << 30, 0),
	SYSFS_BIT("log_everything", SYSFS_RW, &toi_bkd.toi_action, TOI_LOGALL,
			0)
#endif
};

static struct toi_module_ops userui_ops = {
	.type				= MISC_HIDDEN_MODULE,
	.name				= "printk ui",
	.directory			= "user_interface",
	.module				= THIS_MODULE,
	.sysfs_data			= sysfs_params,
	.num_sysfs_entries		= sizeof(sysfs_params) /
		sizeof(struct toi_sysfs_data),
							CHECKSUM_SIZE)) {
			toi_message(TOI_IO, TOI_VERBOSE, 0, "Resaving %ld.",
					pfn);
			SetPageResave(pfn_to_page(pfn));
			toi_num_resaved++;
			if (test_action_state(TOI_ABORT_ON_RESAVE_NEEDED))
				set_abort_result(TOI_RESAVE_NEEDED);
		}

		index++;
	}
	toi_message(TOI_IO, TOI_VERBOSE, 0, "Checksum verification complete.");
}

static struct toi_sysfs_data sysfs_params[] = {
	SYSFS_INT("enabled", SYSFS_RW, &toi_checksum_ops.enabled, 0, 1, 0,
			NULL),
	SYSFS_BIT("abort_if_resave_needed", SYSFS_RW, &toi_bkd.toi_action,
			TOI_ABORT_ON_RESAVE_NEEDED, 0)
};

/*
 * Ops structure.
 */
static struct toi_module_ops toi_checksum_ops = {
	.type			= MISC_MODULE,
	.name			= "checksumming",
	.directory		= "checksum",
	.module			= THIS_MODULE,
	.initialise		= toi_checksum_initialise,
	.cleanup		= toi_checksum_cleanup,
	.print_debug_info	= toi_checksum_print_debug_stats,
				/* Set new wakeup time. */
				write_alarm_file(since_epoch + wake_delay);
			}
		}
	}

	__toi_power_down(toi_poweroff_method);

	toi_check_resleep();
}
EXPORT_SYMBOL_GPL(toi_power_down);

static struct toi_sysfs_data sysfs_params[] = {
#if defined(CONFIG_ACPI)
	SYSFS_STRING("lid_file", SYSFS_RW, lid_state_file, 256, 0, NULL),
	SYSFS_INT("wake_delay", SYSFS_RW, &wake_delay, 0, INT_MAX, 0, NULL),
	SYSFS_STRING("wake_alarm_dir", SYSFS_RW, wake_alarm_dir, 256, 0, NULL),
	SYSFS_INT("post_wake_state", SYSFS_RW, &post_wake_state, -1, 5, 0,
			NULL),
#endif
	SYSFS_UL("powerdown_method", SYSFS_RW, &toi_poweroff_method, 0, 5, 0),
	SYSFS_INT("did_suspend_to_both", SYSFS_READONLY, &did_suspend_to_both,
		0, 0, 0, NULL)
};

static struct toi_module_ops powerdown_ops = {
	.type				= MISC_HIDDEN_MODULE,
	.name				= "poweroff",
	.initialise			= powerdown_init,
	.cleanup			= powerdown_cleanup,
	.directory			= "[ROOT]",
	for (i = 0; i < TOI_ALLOC_PATHS; i++) {
		atomic_set(&toi_alloc_count[i], 0);
		atomic_set(&toi_free_count[i], 0);
		atomic_set(&toi_test_count[i], 0);
		atomic_set(&toi_fail_count[i], 0);
		toi_cur_allocd[i] = 0;
		toi_max_allocd[i] = 0;
	};

	max_allocd = 0;
	cur_allocd = 0;
	return 0;
}

static struct toi_sysfs_data sysfs_params[] = {
	SYSFS_INT("failure_test", SYSFS_RW, &toi_fail_num, 0, 99, 0, NULL),
	SYSFS_INT("trace", SYSFS_RW, &toi_trace_allocs, 0, TOI_ALLOC_PATHS, 0,
			NULL),
	SYSFS_BIT("find_max_mem_allocated", SYSFS_RW, &toi_bkd.toi_action,
			TOI_GET_MAX_MEM_ALLOCD, 0),
	SYSFS_INT("enabled", SYSFS_RW, &toi_alloc_ops.enabled, 0, 1, 0,
			NULL)
};

static struct toi_module_ops toi_alloc_ops = {
	.type					= MISC_HIDDEN_MODULE,
	.name					= "allocation debugging",
	.directory				= "alloc",
	.module					= THIS_MODULE,
	.early					= 1,
	.initialise				= toi_alloc_initialise,
	if (storage_manager_action)
		toi_prepare_usm();
	else
		toi_cleanup_usm();

	storage_manager_last_action = storage_manager_action;
}

/*
 * User interface specific /sys/power/tuxonice entries.
 */

static struct toi_sysfs_data sysfs_params[] = {
	SYSFS_NONE("simulate_atomic_copy", storage_manager_simulate),
	SYSFS_INT("enabled", SYSFS_RW, &usm_ops.enabled, 0, 1, 0, NULL),
	SYSFS_STRING("program", SYSFS_RW, usm_helper_data.program, 254, 0,
		     NULL),
	SYSFS_INT("activate_storage", SYSFS_RW, &storage_manager_action, 0, 1,
		  0, storage_manager_activate)
};

static struct toi_module_ops usm_ops = {
	.type = MISC_MODULE,
	.name = "usm",
	.directory = "storage_manager",
	.module = THIS_MODULE,
	.storage_needed = usm_storage_needed,
	.save_config_info = usm_save_config_info,
	.load_config_info = usm_load_config_info,
	.memory_needed = usm_memory_needed,