Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1065264ybh; Thu, 16 Jul 2020 02:05:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJycFq4W/Y2DmRf5bAQx4aZaYxpbfcpziuK2G6Fu0u64NoT83lzYpTy9GDD6+y62yuEd8yPZ X-Received: by 2002:a17:906:add3:: with SMTP id lb19mr2706255ejb.304.1594890300915; Thu, 16 Jul 2020 02:05:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594890300; cv=none; d=google.com; s=arc-20160816; b=WQADwxGl0LEWfSJe/7ntZHLXNkrkz8f0enGMgo3Mbl+iKA2MFakW6VI5W6RwJBqguM Xlnkd5XChwjDRMs3t1MlPfn5OsJJeoyDMaNLRequax3zPV7bQng1xrkOOjGld50O1FUo UnykLBaIIglK5gwDR334oNsqMqxiTxEUCW3BnoF9jf/F3Q7Lqfaw9LX24KodCNOikxWj Ya0tFYHK2M7mSKmhNZ84LnJWj5s4+S5lfqlTE6hwk9YYJS164eY2fgtubBtrFbqAofxD MrKOZNpt0RDSwBcYGnS5lINDU1OK8HWUKf7FseGW53T8+V0erqaByJGPlP5GbIIry+Bq 2jog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=kuADVkjkRArAb5NcZd5zCOWd7/ocu/AdCSq7Id4zeiE=; b=D5G0EkXle/aX42ppyAwK3myLoBYp2utZVn0L2gXCZcXZ3wprc4PdZndAo5z38zQreL jC7RkhOyFsw+odirPYBN8bbbJm08hW+6zUQkk4BEWKfvqClgvTCRWQKtSG5ra9QSCHdG GdvWYb9/u7uVW74aFNBz98Jx6BGn8SHp7mGKj7Tr2qHiicn3TrKaPZ+z0dKEzH12Dy/Z SnHRA+ck9ASRIG7htGbbvcf1XDhLh6vZCJf4Pp9jb2sUiRW359NxmKRmkFanbdIPY3ko yNI0DBpIFlC4h0018E0OFhj6pHHR0c3lgLSkLouXRqS2OCiHnpdGPWXDhjjvhR9SlhCP j43w== 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 s15si275930edy.608.2020.07.16.02.04.38; Thu, 16 Jul 2020 02:05:00 -0700 (PDT) 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 S1728296AbgGPJDZ (ORCPT + 99 others); Thu, 16 Jul 2020 05:03:25 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:7869 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726350AbgGPJDY (ORCPT ); Thu, 16 Jul 2020 05:03:24 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C89E76DB5867427788A6; Thu, 16 Jul 2020 17:03:21 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.487.0; Thu, 16 Jul 2020 17:03:17 +0800 From: Qinglang Miao To: Greg Kroah-Hartman , Paul Mackerras , Michael Ellerman CC: , , Subject: [PATCH -next] powerpc: Convert to DEFINE_SHOW_ATTRIBUTE Date: Thu, 16 Jul 2020 17:07:12 +0800 Message-ID: <20200716090712.14375-1-miaoqinglang@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chen Huang Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. Signed-off-by: Chen Huang --- arch/powerpc/kvm/book3s_xive_native.c | 12 +----------- arch/powerpc/mm/ptdump/bats.c | 24 +++++++----------------- arch/powerpc/mm/ptdump/hashpagetable.c | 12 +----------- arch/powerpc/mm/ptdump/ptdump.c | 13 +------------ arch/powerpc/mm/ptdump/segment_regs.c | 12 +----------- 5 files changed, 11 insertions(+), 62 deletions(-) diff --git a/arch/powerpc/kvm/book3s_xive_native.c b/arch/powerpc/kvm/book3s_xive_native.c index 02e3cbbea..d0c2db0e0 100644 --- a/arch/powerpc/kvm/book3s_xive_native.c +++ b/arch/powerpc/kvm/book3s_xive_native.c @@ -1227,17 +1227,7 @@ static int xive_native_debug_show(struct seq_file *m, void *private) return 0; } -static int xive_native_debug_open(struct inode *inode, struct file *file) -{ - return single_open(file, xive_native_debug_show, inode->i_private); -} - -static const struct file_operations xive_native_debug_fops = { - .open = xive_native_debug_open, - .read_iter = seq_read_iter, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(xive_native_debug); static void xive_native_debugfs_init(struct kvmppc_xive *xive) { diff --git a/arch/powerpc/mm/ptdump/bats.c b/arch/powerpc/mm/ptdump/bats.c index 7afcdac48..93771af72 100644 --- a/arch/powerpc/mm/ptdump/bats.c +++ b/arch/powerpc/mm/ptdump/bats.c @@ -56,7 +56,7 @@ static void bat_show_601(struct seq_file *m, int idx, u32 lower, u32 upper) #define BAT_SHOW_601(_m, _n, _l, _u) bat_show_601(_m, _n, mfspr(_l), mfspr(_u)) -static int bats_show_601(struct seq_file *m, void *v) +static int bats_601_show(struct seq_file *m, void *v) { seq_puts(m, "---[ Block Address Translation ]---\n"); @@ -113,7 +113,7 @@ static void bat_show_603(struct seq_file *m, int idx, u32 lower, u32 upper, bool #define BAT_SHOW_603(_m, _n, _l, _u, _d) bat_show_603(_m, _n, mfspr(_l), mfspr(_u), _d) -static int bats_show_603(struct seq_file *m, void *v) +static int bats_603_show(struct seq_file *m, void *v) { seq_puts(m, "---[ Instruction Block Address Translation ]---\n"); @@ -144,25 +144,15 @@ static int bats_show_603(struct seq_file *m, void *v) return 0; } -static int bats_open(struct inode *inode, struct file *file) -{ - if (IS_ENABLED(CONFIG_PPC_BOOK3S_601)) - return single_open(file, bats_show_601, NULL); - - return single_open(file, bats_show_603, NULL); -} - -static const struct file_operations bats_fops = { - .open = bats_open, - .read_iter = seq_read_iter, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(bats_601); +DEFINE_SHOW_ATTRIBUTE(bats_603); static int __init bats_init(void) { debugfs_create_file("block_address_translation", 0400, - powerpc_debugfs_root, NULL, &bats_fops); + powerpc_debugfs_root, NULL, + IS_ENABLED(CONFIG_PPC_BOOK3S_601) ? + &bats_601_fops : &bats_603_fops); return 0; } device_initcall(bats_init); diff --git a/arch/powerpc/mm/ptdump/hashpagetable.c b/arch/powerpc/mm/ptdump/hashpagetable.c index 457fcee7e..c7f824d29 100644 --- a/arch/powerpc/mm/ptdump/hashpagetable.c +++ b/arch/powerpc/mm/ptdump/hashpagetable.c @@ -526,17 +526,7 @@ static int ptdump_show(struct seq_file *m, void *v) return 0; } -static int ptdump_open(struct inode *inode, struct file *file) -{ - return single_open(file, ptdump_show, NULL); -} - -static const struct file_operations ptdump_fops = { - .open = ptdump_open, - .read_iter = seq_read_iter, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(ptdump); static int ptdump_init(void) { diff --git a/arch/powerpc/mm/ptdump/ptdump.c b/arch/powerpc/mm/ptdump/ptdump.c index db17e84b5..58b062f1b 100644 --- a/arch/powerpc/mm/ptdump/ptdump.c +++ b/arch/powerpc/mm/ptdump/ptdump.c @@ -398,18 +398,7 @@ static int ptdump_show(struct seq_file *m, void *v) return 0; } - -static int ptdump_open(struct inode *inode, struct file *file) -{ - return single_open(file, ptdump_show, NULL); -} - -static const struct file_operations ptdump_fops = { - .open = ptdump_open, - .read_iter = seq_read_iter, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(ptdump); static void build_pgtable_complete_mask(void) { diff --git a/arch/powerpc/mm/ptdump/segment_regs.c b/arch/powerpc/mm/ptdump/segment_regs.c index 8b15bad5a..9e870d44c 100644 --- a/arch/powerpc/mm/ptdump/segment_regs.c +++ b/arch/powerpc/mm/ptdump/segment_regs.c @@ -41,17 +41,7 @@ static int sr_show(struct seq_file *m, void *v) return 0; } -static int sr_open(struct inode *inode, struct file *file) -{ - return single_open(file, sr_show, NULL); -} - -static const struct file_operations sr_fops = { - .open = sr_open, - .read_iter = seq_read_iter, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(sr); static int __init sr_init(void) { -- 2.17.1