lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1604406584-53926-2-git-send-email-luojiaxing@huawei.com>
Date:   Tue, 3 Nov 2020 20:29:40 +0800
From:   Luo Jiaxing <luojiaxing@...wei.com>
To:     <akpm@...ux-foundation.org>, <viro@...iv.linux.org.uk>,
        <andriy.shevchenko@...ux.intel.com>
CC:     <linux-kernel@...r.kernel.org>, <martin.petersen@...cle.com>,
        <john.garry@...wei.com>, <himanshu.madhani@...ium.com>,
        <felipe.balbi@...ux.intel.com>, <gregkh@...uxfoundation.org>,
        <uma.shankar@...el.com>, <anshuman.gupta@...el.com>,
        <animesh.manna@...el.com>, <linux-usb@...r.kernel.org>,
        <linux-scsi@...r.kernel.org>, <linuxarm@...wei.com>
Subject: [PATCH v3 1/5] seq_file: Introduce DEFINE_SHOW_STORE_ATTRIBUTE() helper macro

We already own DEFINE_SHOW_ATTRIBUTE() helper macro for defining attribute
for read-only file, but many of drivers want a helper macro for read-write
file too.

So we make one to decrease code duplication.

Signed-off-by: Luo Jiaxing <luojiaxing@...wei.com>
---
 include/linux/seq_file.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
index 813614d..8a474c8 100644
--- a/include/linux/seq_file.h
+++ b/include/linux/seq_file.h
@@ -191,6 +191,21 @@ static const struct proc_ops __name ## _proc_ops = {			\
 	.proc_release	= single_release,				\
 }
 
+#define DEFINE_SHOW_STORE_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,					\
+	.write		= __name ## _write,				\
+	.llseek		= seq_lseek,					\
+	.release	= single_release,				\
+}
+
 static inline struct user_namespace *seq_user_ns(struct seq_file *seq)
 {
 #ifdef CONFIG_USER_NS
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ