From nobody Sat Sep 21 13:56:50 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B63C9C6FA83 for ; Tue, 27 Sep 2022 10:46:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231451AbiI0Kp6 (ORCPT ); Tue, 27 Sep 2022 06:45:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231167AbiI0Kpx (ORCPT ); Tue, 27 Sep 2022 06:45:53 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2953A59BB; Tue, 27 Sep 2022 03:45:51 -0700 (PDT) Received: from dggpemm500023.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4McGQ71VzSz1P6p6; Tue, 27 Sep 2022 18:41:35 +0800 (CST) Received: from dggpemm100009.china.huawei.com (7.185.36.113) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 27 Sep 2022 18:45:49 +0800 Received: from huawei.com (10.175.113.32) by dggpemm100009.china.huawei.com (7.185.36.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 27 Sep 2022 18:45:49 +0800 From: Liu Shixin To: Jakub Kicinski , Felix Fietkau , "John Crispin" , Sean Wang , Mark Lee , "David S. Miller" , "Eric Dumazet" , Paolo Abeni , "Matthias Brugger" CC: , , , , "Liu Shixin" Subject: [PATCH net-next v2] net: ethernet: mtk_eth_soc: use DEFINE_SHOW_ATTRIBUTE to simplify code Date: Tue, 27 Sep 2022 19:19:25 +0800 Message-ID: <20220927111925.2424100-1-liushixin2@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.113.32] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm100009.china.huawei.com (7.185.36.113) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Use DEFINE_SHOW_ATTRIBUTE helper macro to simplify the code. No functional change. Signed-off-by: Liu Shixin --- v1->v2: Rebase on net-next. .../net/ethernet/mediatek/mtk_ppe_debugfs.c | 36 ++++--------------- 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c b/drivers/net/= ethernet/mediatek/mtk_ppe_debugfs.c index ec49829ab32d..391b071bcff3 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c @@ -162,52 +162,28 @@ mtk_ppe_debugfs_foe_show(struct seq_file *m, void *pr= ivate, bool bind) } =20 static int -mtk_ppe_debugfs_foe_show_all(struct seq_file *m, void *private) +mtk_ppe_debugfs_foe_all_show(struct seq_file *m, void *private) { return mtk_ppe_debugfs_foe_show(m, private, false); } +DEFINE_SHOW_ATTRIBUTE(mtk_ppe_debugfs_foe_all); =20 static int -mtk_ppe_debugfs_foe_show_bind(struct seq_file *m, void *private) +mtk_ppe_debugfs_foe_bind_show(struct seq_file *m, void *private) { return mtk_ppe_debugfs_foe_show(m, private, true); } - -static int -mtk_ppe_debugfs_foe_open_all(struct inode *inode, struct file *file) -{ - return single_open(file, mtk_ppe_debugfs_foe_show_all, - inode->i_private); -} - -static int -mtk_ppe_debugfs_foe_open_bind(struct inode *inode, struct file *file) -{ - return single_open(file, mtk_ppe_debugfs_foe_show_bind, - inode->i_private); -} +DEFINE_SHOW_ATTRIBUTE(mtk_ppe_debugfs_foe_bind); =20 int mtk_ppe_debugfs_init(struct mtk_ppe *ppe, int index) { - static const struct file_operations fops_all =3D { - .open =3D mtk_ppe_debugfs_foe_open_all, - .read =3D seq_read, - .llseek =3D seq_lseek, - .release =3D single_release, - }; - static const struct file_operations fops_bind =3D { - .open =3D mtk_ppe_debugfs_foe_open_bind, - .read =3D seq_read, - .llseek =3D seq_lseek, - .release =3D single_release, - }; struct dentry *root; =20 snprintf(ppe->dirname, sizeof(ppe->dirname), "ppe%d", index); =20 root =3D debugfs_create_dir(ppe->dirname, NULL); - debugfs_create_file("entries", S_IRUGO, root, ppe, &fops_all); - debugfs_create_file("bind", S_IRUGO, root, ppe, &fops_bind); + debugfs_create_file("entries", S_IRUGO, root, ppe, &mtk_ppe_debugfs_foe_a= ll_fops); + debugfs_create_file("bind", S_IRUGO, root, ppe, &mtk_ppe_debugfs_foe_bind= _fops); =20 return 0; } --=20 2.25.1