Ejemplo n.º 1
0
static int param_write_proc_debug(struct file *file, const char *buffer,
					unsigned long count, void *data)
{
	char *buf;

	if (count < 1)
		return -EINVAL;

	buf = kmalloc(count, GFP_KERNEL);
	if (!buf)
		return -ENOMEM;

	if (copy_from_user(buf, buffer, count)) {
		kfree(buf);
		return -EFAULT;
	}

	switch(buf[0]) {
		case '0':
			param_show_info();
			break;
		case '1':
			param_set_default();
			save_lfs_param_value();
			klogi("Parameters have been set as DEFAULT values...");
			param_show_info();
			break;
		case '2':
			param_run_test();
			break;
		case '3':
			param_lfs_run_test();
			break;
		default:
			kfree(buf);
			return -EINVAL;			
	}

	kfree(buf);
	return count;
}
Ejemplo n.º 2
0
static int param_init(void)
{
	int ret;

#ifdef PARAM_USE_INIT_BUFFER
	param_buf = kmalloc(PARAM_LEN, GFP_KERNEL);
	if (!param_buf) {
		kloge("Unable to alloc param_buf!");
		return -ENOMEM;
	}

	image_buf = kmalloc(IMAGE_LEN, GFP_KERNEL);
	if (!image_buf) {
		kloge("Unable to alloc image_buf!");
		kfree(param_buf);
		return -ENOMEM;
	}
#endif

#ifdef PARAM_PROCFS_DEBUG
	struct proc_dir_entry *ent;

	/* Creats '/proc/param' directory */
	param_dir = proc_mkdir("param", NULL);
	if (param_dir == NULL) {
		kloge("Unable to create /proc/param directory\n");
		return -ENOMEM;
	}

	/* Creats RW '/proc/param/sleep/debug' entry */
	ent = create_proc_entry("debug", 0, param_dir);
	if (ent == NULL) {
		kloge("Unable to create /proc/param/debug entry");
		ret = -ENOMEM;
		goto fail;
	}
	ent->read_proc = param_read_proc_debug;
	ent->write_proc = param_write_proc_debug;
#endif

	klogi("param_init");

#if 0
	ret = load_param_value();
#else
	ret = load_lfs_param_value();
#endif
	if (ret < 0) {
		kloge("Loading parameters failed. Parameters have been initialized as default.");
		param_set_default();
	}

	sec_set_param_value = set_param_value;
	sec_get_param_value = get_param_value;

	return 0;

#ifdef PARAM_PROCFS_DEBUG
fail:
	remove_proc_entry("param", 0);

#ifdef PARAM_USE_INIT_BUFFER
	kfree(param_buf);
	kfree(image_buf);
#endif
	
	return ret;
#endif
}
Ejemplo n.º 3
0
/*
 * Only run this once, or mountain trolls may carry you off to the
 * wilderness.
 */
static void set_defaults(void)
{
	spew.state = 0;
	assert(param_set_default(PARAM_ALL, P_STATE_DEFAULT));
}