Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp466635pxb; Tue, 3 Nov 2020 04:31:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxPUCj6biUB6oFImsjtinwt6tUFEcWBajo/At0zCn66PsXo7TF3U+pYiH86bEIqt7GO5Ont X-Received: by 2002:a05:6402:a53:: with SMTP id bt19mr11053299edb.26.1604406667983; Tue, 03 Nov 2020 04:31:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604406667; cv=none; d=google.com; s=arc-20160816; b=DDvJY18TIulPt6NFRpw3Mue2YPhsIf0sUEAl64y2KBjr+Nze0M71xr+VCJ/m/+8yEc fKHaeevR9vKyRdIrfCHGKmgsVMks+nDLw5X0x34VK/N2W0bkyhBmXEt4NI6oRsiOotDh V8Pl6Zaj3cAweJcQA/asxbgXK/QtcG59WakcfqtZFTIEA7/ldyPRJWMWdhJSY66iaNOv W2TICjfDIVVSte5PyIE6n6u8gQxdY4a56rJNtDXpQAtq4nALQTaNR4UyCPuFJMhDB/TA zE+MRhH9iIKO3S9Ea/4dvVxKN+ec2XX0uhkNIUxSIbfpqhow4bKjwr59I00m5CjxJuba GVcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Fh1Jdr76OswfEN1BXkF4j7q545N4m+Ui5s7x/ZgEMSI=; b=Xw7FvXDj0IJNs1GV68wUGZwFW2kIxW8RGj+71HaJ73xCGZT1pV7aI1T3nIPED629J7 A3yn4E7rGR2752rRSUlS+wdJUFew019aXj2mBLmWtHubH4iF6F5jmxvhVRIKgQ7CaXdI iOMpo2ENpx3ExQsoNnGrEDH21ZfkZeVLqOyFR+LRocDodiYyIH+rhmFGA+NIMChqxC51 0Q80ClHYgbvG6ZfsaD7tkBiE2Z/ICYU7Af6JlzbtGXtvM7hYwKiz0IkXXFsie23gabGX 436yxvfxOpxc2+hnuz+nf7iA5CuUHayG4ClkgJTWDttRW+k8KfFYhUDcXGpxSIThV2Tc hViw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qn24si4457048ejb.680.2020.11.03.04.30.44; Tue, 03 Nov 2020 04:31:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729057AbgKCM3Z (ORCPT + 99 others); Tue, 3 Nov 2020 07:29:25 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:7586 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728918AbgKCM3W (ORCPT ); Tue, 3 Nov 2020 07:29:22 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CQTcB2JtyzLt75; Tue, 3 Nov 2020 20:29:14 +0800 (CST) Received: from huawei.com (10.69.192.56) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Tue, 3 Nov 2020 20:29:09 +0800 From: Luo Jiaxing To: , , CC: , , , , , , , , , , , Subject: [PATCH v3 1/5] seq_file: Introduce DEFINE_SHOW_STORE_ATTRIBUTE() helper macro Date: Tue, 3 Nov 2020 20:29:40 +0800 Message-ID: <1604406584-53926-2-git-send-email-luojiaxing@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604406584-53926-1-git-send-email-luojiaxing@huawei.com> References: <1604406584-53926-1-git-send-email-luojiaxing@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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