diff mbox series

[2/7] backports: Add DEFINE_SHOW_ATTRIBUTE macro

Message ID 20190126220033.27634-3-hauke@hauke-m.de (mailing list archive)
State Accepted
Headers show
Series backport: update to Linux 5.0-rc3 | expand

Commit Message

Hauke Mehrtens Jan. 26, 2019, 10 p.m. UTC
This was introduced in Linux commit a08f06bb7a07 ("seq_file: Introduce
DEFINE_SHOW_ATTRIBUTE() helper macro" and is used by the cw1200 and the
wil6210 driver.

Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
---
 backport/backport-include/linux/seq_file.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/backport/backport-include/linux/seq_file.h b/backport/backport-include/linux/seq_file.h
index ad1bded5..5b88f6f8 100644
--- a/backport/backport-include/linux/seq_file.h
+++ b/backport/backport-include/linux/seq_file.h
@@ -48,4 +48,20 @@  void seq_hex_dump(struct seq_file *m, const char *prefix_str, int prefix_type,
 		  bool ascii);
 #endif
 
+#ifndef DEFINE_SHOW_ATTRIBUTE
+#define DEFINE_SHOW_ATTRIBUTE(__name)					\
+static int __name ## _open(struct inode *inode, struct file *file)	\
+{									\
+	return single_open(file, __name ## _show, inode->i_private);	\
+}									\
+									\
+static const struct file_operations __name ## _fops = {			\
+	.owner		= THIS_MODULE,					\
+	.open		= __name ## _open,				\
+	.read		= seq_read,					\
+	.llseek		= seq_lseek,					\
+	.release	= single_release,				\
+}
+#endif /* DEFINE_SHOW_ATTRIBUTE */
+
 #endif /* __BACKPORT_SEQ_FILE_H */