[PATCH] seq_file.h: introduce DECLARE_SEQ_FOPS_{RO,RW}

From: H Hartley Sweeten
Date: Mon Jun 06 2011 - 16:20:29 EST


Many of the procfs and debugfs attribute file_operations in the kernel are
missing the .owner information. Introduce some macro's to fill in the .owner
field as well as the common methods for virtual file file_operations. This
simplifies creating the attributes and makes sure all the fields are properly
initialized.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>

---

diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 03c0232..6a1f991 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -153,4 +153,28 @@ extern struct hlist_node *seq_hlist_start_head_rcu(struct hlist_head *head,
extern struct hlist_node *seq_hlist_next_rcu(void *v,
struct hlist_head *head,
loff_t *ppos);
+
+/*
+ * virtual filesystem attribute files
+ */
+
+#define DECLARE_SEQ_FOPS_RO(name) \
+static const struct file_operations name##_fops = { \
+ .owner = THIS_MODULE, \
+ .llseek = seq_lseek, \
+ .read = seq_read, \
+ .open = name##_open, \
+ .release = single_release, \
+}
+
+#define DECLARE_SEQ_FOPS_RW(name) \
+static const struct file_operations name##_fops = { \
+ .owner = THIS_MODULE, \
+ .llseek = seq_lseek, \
+ .read = seq_read, \
+ .write = name##_write, \
+ .open = name##_open, \
+ .release = single_release, \
+}
+
#endif
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/