diff mbox series

[25/30] headers: Add DEFINE_SEQ_ATTRIBUTE

Message ID 20201201220415.30582-26-hauke@hauke-m.de (mailing list archive)
State New, archived
Headers show
Series backports: Update to match kernel 5.10-rc6 | expand

Commit Message

Hauke Mehrtens Dec. 1, 2020, 10:04 p.m. UTC
Add the DEFINE_SEQ_ATTRIBUTE which was added in commit d2c0e6e91c79
("include/linux/seq_file.h: introduce DEFINE_SEQ_ATTRIBUTE() helper
macro") in kernel 5.8. This is used by ath5k.

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

Patch

diff --git a/backport/backport-include/linux/seq_file.h b/backport/backport-include/linux/seq_file.h
index 5b88f6f8..1d78bbbd 100644
--- a/backport/backport-include/linux/seq_file.h
+++ b/backport/backport-include/linux/seq_file.h
@@ -64,4 +64,25 @@  static const struct file_operations __name ## _fops = {			\
 }
 #endif /* DEFINE_SHOW_ATTRIBUTE */
 
+#ifndef DEFINE_SEQ_ATTRIBUTE
+#define DEFINE_SEQ_ATTRIBUTE(__name)					\
+static int __name ## _open(struct inode *inode, struct file *file)	\
+{									\
+	int ret = seq_open(file, &__name ## _sops);			\
+	if (!ret && inode->i_private) {					\
+		struct seq_file *seq_f = file->private_data;		\
+		seq_f->private = inode->i_private;			\
+	}								\
+	return ret;							\
+}									\
+									\
+static const struct file_operations __name ## _fops = {			\
+	.owner		= THIS_MODULE,					\
+	.open		= __name ## _open,				\
+	.read		= seq_read,					\
+	.llseek		= seq_lseek,					\
+	.release	= seq_release,					\
+}
+#endif /* DEFINE_SEQ_ATTRIBUTE */
+
 #endif /* __BACKPORT_SEQ_FILE_H */