From: H Hartley Sweeten <hartleys@visionengravers.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: [PATCH] seq_file.h: introduce DECLARE_SEQ_FOPS_{RO,RW}
Date: Mon, 6 Jun 2011 13:19:45 -0700 [thread overview]
Message-ID: <201106061319.45855.hartleys@visionengravers.com> (raw)
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@visionengravers.com>
---
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
next reply other threads:[~2011-06-06 20:20 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-06 20:19 H Hartley Sweeten [this message]
2011-06-06 21:07 ` [PATCH] seq_file.h: introduce DECLARE_SEQ_FOPS_{RO,RW} Al Viro
2011-06-06 21:18 ` Alexey Dobriyan
2011-06-06 21:19 ` H Hartley Sweeten
2011-06-06 21:22 ` Al Viro
2011-06-06 21:26 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201106061319.45855.hartleys@visionengravers.com \
--to=hartleys@visionengravers.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox