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

Commit 44414d82 authored by Christoph Hellwig's avatar Christoph Hellwig
Browse files

proc: introduce proc_create_seq_private



Variant of proc_create_data that directly take a struct seq_operations
argument + a private state size and drastically reduces the boilerplate
code in the callers.

All trivial callers converted over.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent fddda2b7
Loading
Loading
Loading
Loading
+2 −14
Original line number Diff line number Diff line
@@ -2788,22 +2788,10 @@ static const struct seq_operations locks_seq_operations = {
	.show	= locks_show,
};

static int locks_open(struct inode *inode, struct file *filp)
{
	return seq_open_private(filp, &locks_seq_operations,
					sizeof(struct locks_iterator));
}

static const struct file_operations proc_locks_operations = {
	.open		= locks_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= seq_release_private,
};

static int __init proc_locks_init(void)
{
	proc_create("locks", 0, NULL, &proc_locks_operations);
	proc_create_seq_private("locks", 0, NULL, &locks_seq_operations,
			sizeof(struct locks_iterator), NULL);
	return 0;
}
fs_initcall(proc_locks_init);
+6 −3
Original line number Diff line number Diff line
@@ -560,6 +560,8 @@ static int proc_seq_open(struct inode *inode, struct file *file)
{
	struct proc_dir_entry *de = PDE(inode);

	if (de->state_size)
		return seq_open_private(file, de->seq_ops, de->state_size);
	return seq_open(file, de->seq_ops);
}

@@ -570,9 +572,9 @@ static const struct file_operations proc_seq_fops = {
	.release	= seq_release,
};

struct proc_dir_entry *proc_create_seq_data(const char *name, umode_t mode,
struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode,
		struct proc_dir_entry *parent, const struct seq_operations *ops,
		void *data)
		unsigned int state_size, void *data)
{
	struct proc_dir_entry *p;

@@ -581,9 +583,10 @@ struct proc_dir_entry *proc_create_seq_data(const char *name, umode_t mode,
		return NULL;
	p->proc_fops = &proc_seq_fops;
	p->seq_ops = ops;
	p->state_size = state_size;
	return proc_register(parent, p);
}
EXPORT_SYMBOL(proc_create_seq_data);
EXPORT_SYMBOL(proc_create_seq_private);

void proc_set_size(struct proc_dir_entry *de, loff_t size)
{
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@ struct proc_dir_entry {
	const struct file_operations *proc_fops;
	const struct seq_operations *seq_ops;
	void *data;
	unsigned int state_size;
	unsigned int low_ino;
	nlink_t nlink;
	kuid_t uid;
+6 −1
Original line number Diff line number Diff line
@@ -145,7 +145,12 @@ extern rwlock_t atalk_interfaces_lock;

extern struct atalk_route atrtr_default;

extern const struct file_operations atalk_seq_arp_fops;
struct aarp_iter_state {
	int bucket;
	struct aarp_entry **table;
};

extern const struct seq_operations aarp_seq_ops;

extern int sysctl_aarp_expiry_time;
extern int sysctl_aarp_tick_time;
+6 −3
Original line number Diff line number Diff line
@@ -25,11 +25,13 @@ extern struct proc_dir_entry *proc_mkdir_mode(const char *, umode_t,
					      struct proc_dir_entry *);
struct proc_dir_entry *proc_create_mount_point(const char *name);

struct proc_dir_entry *proc_create_seq_data(const char *name, umode_t mode,
struct proc_dir_entry *proc_create_seq_private(const char *name, umode_t mode,
		struct proc_dir_entry *parent, const struct seq_operations *ops,
		void *data);
		unsigned int state_size, void *data);
#define proc_create_seq_data(name, mode, parent, ops, data) \
	proc_create_seq_private(name, mode, parent, ops, 0, data)
#define proc_create_seq(name, mode, parent, ops) \
	proc_create_seq_data(name, mode, parent, ops, NULL)
	proc_create_seq_private(name, mode, parent, ops, 0, NULL)
 
extern struct proc_dir_entry *proc_create_data(const char *, umode_t,
					       struct proc_dir_entry *,
@@ -64,6 +66,7 @@ static inline struct proc_dir_entry *proc_mkdir_data(const char *name,
	umode_t mode, struct proc_dir_entry *parent, void *data) { return NULL; }
static inline struct proc_dir_entry *proc_mkdir_mode(const char *name,
	umode_t mode, struct proc_dir_entry *parent) { return NULL; }
#define proc_create_seq_private(name, mode, parent, ops, 0, data) ({NULL;})
#define proc_create_seq_data(name, mode, parent, ops, data) ({NULL;})
#define proc_create_seq(name, mode, parent, ops) ({NULL;})
#define proc_create(name, mode, parent, proc_fops) ({NULL;})
Loading