Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3886693pxu; Mon, 12 Oct 2020 04:05:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAMqg68PWy7yWfK/fijXfac9RM4QwoiT8anLaAFZCRVOE3LUPxSj5ivPgk8kuOi/smXnNH X-Received: by 2002:a05:6402:142a:: with SMTP id c10mr13899217edx.261.1602500723336; Mon, 12 Oct 2020 04:05:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602500723; cv=none; d=google.com; s=arc-20160816; b=zUGuwjuDJ+hN2ZOzs9gsJi/DbNV2g4EVnvcppRVbTEUfSchjZ2K4RQjxh338XhaALJ ABdpKEe34pQfG6yDadyFXK6OhQkVseWdBtli5+uldt9nXYDf1Z2pIFUVBBwEHWCFOfwd h8z+AF1ZeBK0xcVsk2WgL9KgTHOByvgXLKpJ4eG42+KSE3m5qKLzw/sjWDLEHz2nzulq h4Lsp1xtMXTtgZBhHZ4GXjJ+WgZLkmzOBUjTq33VY/1UP7zSu6t0p10NKAaR91pmRLC6 /0OkIJUWdpf619nfzidro14uEQmzBtYUqufoq5nqDwIz6CpZixGT6jb8I7On6lLPVxRo FD4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=sXi8qZeu+qkrd7Ga5gkJVaEfLSaGzXnkiPgB6DygN9c=; b=wJMREtdj7gFUWauYWftkcnDeqJuzvbhbzHVRycnFZ5901a0ZGh6bAoy+dq8wZRJ1Nu d9ZmsdLIIju5Vx3kJdWvnRnpcO2OFb4SLkOX9WSb/xjJQ/Am5xDJNDmnMD9AJRMjXCKd Q5Q/Cg7MEFRqF+84CxUD3JnLn57Ub1HDr03oaeR8EubogtBGciAU3JMBsxiHopQEZstt KXzGfJtbfv7XLX25nje+RvAXRIxiVTANxkhdExnoon4D7dCi7xoY2OlEhdfpl6mon2Qm VYCFCLG2BFgMIjvPxQdVe2YMVlqrcZN8BRsZoM7G4IH2WiXSF2AdixtYrsF0Dt/UepdR 36aQ== 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 md27si11681656ejb.714.2020.10.12.04.05.00; Mon, 12 Oct 2020 04:05:23 -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 S2387749AbgJLLDI (ORCPT + 99 others); Mon, 12 Oct 2020 07:03:08 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:32101 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387693AbgJLLDI (ORCPT ); Mon, 12 Oct 2020 07:03:08 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 4C8wkq4M1Qz9tyxp; Mon, 12 Oct 2020 13:02:59 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id HC-RA1I_1qin; Mon, 12 Oct 2020 13:02:59 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4C8wkq3Gt8z9tyxm; Mon, 12 Oct 2020 13:02:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 389D08B788; Mon, 12 Oct 2020 13:02:57 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id 60P1PKY0it_H; Mon, 12 Oct 2020 13:02:57 +0200 (CEST) Received: from [172.25.230.100] (po15451.idsi0.si.c-s.fr [172.25.230.100]) by messagerie.si.c-s.fr (Postfix) with ESMTP id B5F268B78B; Mon, 12 Oct 2020 13:02:56 +0200 (CEST) Subject: Re: [PATCH -next v2] powerpc/mm: ptdump: Convert to DEFINE_SHOW_ATTRIBUTE To: Qinglang Miao , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <20200919012901.174233-1-miaoqinglang@huawei.com> From: Christophe Leroy Message-ID: <43d67a2b-6e44-9349-e0b5-80d1f50ed000@csgroup.eu> Date: Mon, 12 Oct 2020 13:02:58 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.12.1 MIME-Version: 1.0 In-Reply-To: <20200919012901.174233-1-miaoqinglang@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Le 19/09/2020 à 03:29, Qinglang Miao a écrit : > Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code. > > Signed-off-by: Qinglang Miao > --- > v2: based on linux-next(20200917), and can be applied to > mainline cleanly now. After the removal of powerpc 601, this patch needs to be rebased (as of linux-next 20201012) I think now, bats_show_603() should simply be renamed bats_show() Christophe > > 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 +----------- > 4 files changed, 10 insertions(+), 51 deletions(-) > > diff --git a/arch/powerpc/mm/ptdump/bats.c b/arch/powerpc/mm/ptdump/bats.c > index e29b338d4..a24495e93 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 = seq_read, > - .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 ad6df9a2e..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 = seq_read, > - .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 aca354fb6..6bbf85ff2 100644 > --- a/arch/powerpc/mm/ptdump/ptdump.c > +++ b/arch/powerpc/mm/ptdump/ptdump.c > @@ -413,18 +413,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 = seq_read, > - .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 dde2fe8de..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 = seq_read, > - .llseek = seq_lseek, > - .release = single_release, > -}; > +DEFINE_SHOW_ATTRIBUTE(sr); > > static int __init sr_init(void) > { >