Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp143852pxb; Wed, 11 Nov 2020 23:09:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6gyeJBiUmE0S6GixV8YhH7zbJP+7SgbPZTTPQ9KhxsJWQzbSOFRMdGcOIEwDPJFrU/x7l X-Received: by 2002:a17:906:1c84:: with SMTP id g4mr30640196ejh.155.1605164959003; Wed, 11 Nov 2020 23:09:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605164958; cv=none; d=google.com; s=arc-20160816; b=pDsQX5ZXBOM0m0mKM7L+dm5CDJhh3NjOF3HTvlhe1W4qiHHQ0OrvzRJtBZoAiUvu4F 267HL6qu14OtirnCzt8wFYANpBc1mScPwhlHNWkOYBqg9dXBcUDiQ9pMOhLU8JLOuQNb CLMShTIaj+VZ91pDQXn9g+eY/w/xefFezJbbHE+ubRXO26r9hZi36FI8Ikfw3VcSyDdy fjrJEUxeMzvi0sDyjrPvgiCM8FgNyAGp4M2dUGKvcjzbKb8eNa5f9Q62YreTU6oyHGg6 30rvMraRi23j1kj+J6ZpfWKHIsxfJie7l5pQ7T1Ub2s5Cgu0He5z4S2VtEozi9eEnrQx DExg== 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=FnAQNGjPHkdqjGAbsp3dpai/LY/fHCxb38OegjutM87RWMrLhOUMm1/TTnemG6KbAP MRrIlY7X7S1t9QsJ3J8t3sUb/y9W/J0G8wzB7h6GaDnBEvraFUEdDM7yXGxyfdvCeIpC ua0PZpLqgYgjNoGiDdD+ssdS6dcPmiQh+mdrwCUeDBTRHT9i9Dx/X4dyPnx5zZg640Fm yb+qMI8y39nMygD1yyOtnxlHhTfA0jzNfXfm575zSsl8yZ3gMWhmkk2XaomtSb5AnPj1 z4P9qJDByOWI/2Jm3l0sWplSr5QB6pk1cxA8cq3ogwhpZlceVL9Qjrb7xk+utrTbHexr Wzrw== 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 m15si3811115edl.269.2020.11.11.23.08.55; Wed, 11 Nov 2020 23:09:18 -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 S1727085AbgKLHH2 (ORCPT + 99 others); Thu, 12 Nov 2020 02:07:28 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:8068 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbgKLHH1 (ORCPT ); Thu, 12 Nov 2020 02:07:27 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CWt2Q3Sk5zLrGV; Thu, 12 Nov 2020 15:07:10 +0800 (CST) Received: from huawei.com (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Thu, 12 Nov 2020 15:07:14 +0800 From: Luo Jiaxing To: , , CC: , , , , , , , , , , , Subject: [PATCH v4 1/5] seq_file: Introduce DEFINE_SHOW_STORE_ATTRIBUTE() helper macro Date: Thu, 12 Nov 2020 15:07:39 +0800 Message-ID: <1605164864-58944-2-git-send-email-luojiaxing@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605164864-58944-1-git-send-email-luojiaxing@huawei.com> References: <1605164864-58944-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