Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f3942ac authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

proc: introduce proc_create_single{,_data}



Variants of proc_create{,_data} that directly take a seq_file show
callback and drastically reduces the boilerplate code in the callers.

All trivial callers converted over.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 44414d82
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -276,21 +276,9 @@ static int proc_dma_show(struct seq_file *m, void *v)
	return 0;
}

static int proc_dma_open(struct inode *inode, struct file *file)
{
	return single_open(file, proc_dma_show, NULL);
}

static const struct file_operations proc_dma_operations = {
	.open		= proc_dma_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= single_release,
};

static int __init proc_dma_init(void)
{
	proc_create("dma", 0, NULL, &proc_dma_operations);
	proc_create_single("dma", 0, NULL, proc_dma_show);
	return 0;
}

+2 −13
Original line number Diff line number Diff line
@@ -91,18 +91,6 @@ static int proc_status_show(struct seq_file *m, void *v)
		seq_printf(m, "Last process:\t\t%d\n", previous_pid);
	return 0;
}

static int proc_status_open(struct inode *inode, struct file *file)
{
	return single_open(file, proc_status_show, PDE_DATA(inode));
}

static const struct file_operations proc_status_fops = {
	.open		= proc_status_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= single_release,
};
#endif

/*
@@ -260,7 +248,8 @@ static int __init swp_emulation_init(void)
		return 0;

#ifdef CONFIG_PROC_FS
	if (!proc_create("cpu/swp_emulation", S_IRUGO, NULL, &proc_status_fops))
	if (!proc_create_single("cpu/swp_emulation", S_IRUGO, NULL,
			proc_status_show))
		return -ENOMEM;
#endif /* CONFIG_PROC_FS */

+2 −14
Original line number Diff line number Diff line
@@ -657,25 +657,13 @@ static int ecard_devices_proc_show(struct seq_file *m, void *v)
	return 0;
}

static int ecard_devices_proc_open(struct inode *inode, struct file *file)
{
	return single_open(file, ecard_devices_proc_show, NULL);
}

static const struct file_operations bus_ecard_proc_fops = {
	.owner		= THIS_MODULE,
	.open		= ecard_devices_proc_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= single_release,
};

static struct proc_dir_entry *proc_bus_ecard_dir = NULL;

static void ecard_proc_init(void)
{
	proc_bus_ecard_dir = proc_mkdir("bus/ecard", NULL);
	proc_create("devices", 0, proc_bus_ecard_dir, &bus_ecard_proc_fops);
	proc_create_single("devices", 0, proc_bus_ecard_dir,
			ecard_devices_proc_show);
}

#define ec_set_resource(ec,nr,st,sz)				\
+2 −14
Original line number Diff line number Diff line
@@ -920,18 +920,6 @@ static int proc_palinfo_show(struct seq_file *m, void *v)
	return 0;
}

static int proc_palinfo_open(struct inode *inode, struct file *file)
{
	return single_open(file, proc_palinfo_show, PDE_DATA(inode));
}

static const struct file_operations proc_palinfo_fops = {
	.open		= proc_palinfo_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= single_release,
};

static int palinfo_add_proc(unsigned int cpu)
{
	pal_func_cpu_u_t f;
@@ -948,8 +936,8 @@ static int palinfo_add_proc(unsigned int cpu)

	for (j=0; j < NR_PALINFO_ENTRIES; j++) {
		f.func_id = j;
		proc_create_data(palinfo_entries[j].name, 0, cpu_dir,
				 &proc_palinfo_fops, (void *)f.value);
		proc_create_single_data(palinfo_entries[j].name, 0, cpu_dir,
				proc_palinfo_show, (void *)f.value);
	}
	return 0;
}
+14 −28
Original line number Diff line number Diff line
@@ -54,8 +54,6 @@ MODULE_AUTHOR("Jesse Barnes <jbarnes@sgi.com>");
MODULE_DESCRIPTION("/proc interface to IA-64 SAL features");
MODULE_LICENSE("GPL");

static const struct file_operations proc_salinfo_fops;

typedef struct {
	const char		*name;		/* name of the proc entry */
	unsigned long           feature;        /* feature bit */
@@ -578,6 +576,17 @@ static int salinfo_cpu_pre_down(unsigned int cpu)
	return 0;
}

/*
 * 'data' contains an integer that corresponds to the feature we're
 * testing
 */
static int proc_salinfo_show(struct seq_file *m, void *v)
{
	unsigned long data = (unsigned long)v;
	seq_puts(m, (sal_platform_features & data) ? "1\n" : "0\n");
	return 0;
}

static int __init
salinfo_init(void)
{
@@ -593,8 +602,8 @@ salinfo_init(void)

	for (i=0; i < NR_SALINFO_ENTRIES; i++) {
		/* pass the feature bit in question as misc data */
		*sdir++ = proc_create_data(salinfo_entries[i].name, 0, salinfo_dir,
					   &proc_salinfo_fops,
		*sdir++ = proc_create_single_data(salinfo_entries[i].name, 0,
				salinfo_dir, proc_salinfo_show,
				(void *)salinfo_entries[i].feature);
	}

@@ -633,27 +642,4 @@ salinfo_init(void)
	return 0;
}

/*
 * 'data' contains an integer that corresponds to the feature we're
 * testing
 */
static int proc_salinfo_show(struct seq_file *m, void *v)
{
	unsigned long data = (unsigned long)v;
	seq_puts(m, (sal_platform_features & data) ? "1\n" : "0\n");
	return 0;
}

static int proc_salinfo_open(struct inode *inode, struct file *file)
{
	return single_open(file, proc_salinfo_show, PDE_DATA(inode));
}

static const struct file_operations proc_salinfo_fops = {
	.open		= proc_salinfo_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= single_release,
};

module_init(salinfo_init);
Loading