Received: by 2002:a05:7412:f584:b0:e2:908c:2ebd with SMTP id eh4csp1147756rdb; Mon, 4 Sep 2023 04:46:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHG3lQTsY4NPLFsJV+Tg5Khu0G9FD1ePgnLqbrmjvC7H4TSkvqnG7ggQr4eeVtx7TqwA53z X-Received: by 2002:a05:6a20:4295:b0:14a:b444:dcce with SMTP id o21-20020a056a20429500b0014ab444dccemr14142640pzj.4.1693828016612; Mon, 04 Sep 2023 04:46:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693828016; cv=none; d=google.com; s=arc-20160816; b=Geq8di9zTtJGzx4BhbZTKG+UwdSgrNsyf7tnAJkJlEKGJLA5dPG7m7nY36LhghBnqU wmokFcgpPaSkQVcqpwvSQIZOEQD9+vjTQxMhxlplpRqWkHU9uiAr90OL1b7OwMSA9ijs br9BFa51y+cbs3/1JbncmQESIEc0qyS4cZLaeKZBR+wQF1WNvi+i9T8+cExsL5bbUBPf KNECcsD1GOFdm6ArjhWdXEdyUvAEc7aYl5qBkEagto6zrNLf8j2t4MjkBGE6CQdxeUHm 6a2M1ZaXHvYxGlClzvYxvGGEeGfWFOqo/ryihwZpEs9FuGzdFCFXyU/ALGxnYVKzWxda Vv+A== 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=IKKEGGSC6ZgNrQAOMKHMdPM6B7bOhHEQJrpY6T66/TE=; fh=m7og4B5eYCctrLkxc9cSjvs8cj9BT5n6qf42E8IHCpg=; b=cW8O/E9Zzt5IUFt3i1N35org4LlwGMQLkHUA1ovbycAM/RxlEqGJ0kxHW3K4MvjJto rtBuz4/oJDeh5tICj4HOvmBOFyMSRjpWS2s0WSOF38sGOLW6L1PgsKbWzSwtMEEGmXBL Y6N4+pnN4tKL3qOqz+RNdcrmu9mT3pT9kivm03ryriTQlVVmOevPhFP8Ldpe7E9inu8r tRKUgTFDkHfWY9CbbAfCP4AoPfGR6RETj1Xs4gNJg/TyK3a27tDkYnOzAT6m9PGUNKLw JT6xwt6T0OtR0VjlDLYk2HyYoXUA24WcJrOSmW90VvKIwW7CtPhLvo/4QrbfksFvv3AP kgJg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id br12-20020a056a00440c00b00687480b7b2csi7649465pfb.105.2023.09.04.04.46.44; Mon, 04 Sep 2023 04:46:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352625AbjIDI47 (ORCPT + 99 others); Mon, 4 Sep 2023 04:56:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238563AbjIDI45 (ORCPT ); Mon, 4 Sep 2023 04:56:57 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01B67131; Mon, 4 Sep 2023 01:56:54 -0700 (PDT) Received: from dggpemm500012.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RfMsQ4lCtzrSSZ; Mon, 4 Sep 2023 16:55:06 +0800 (CST) Received: from localhost.localdomain (10.50.163.32) by dggpemm500012.china.huawei.com (7.185.36.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Mon, 4 Sep 2023 16:56:52 +0800 From: Xingui Yang To: , , , CC: , , , , , , , , , , , , , , , , Subject: [PATCH v5 2/3] scsi: hisi_sas: Use DEFINE_SHOW_STORE_ATTRIBUTE helper for debugfs Date: Mon, 4 Sep 2023 08:48:03 +0000 Message-ID: <20230904084804.39564-3-yangxingui@huawei.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230904084804.39564-1-yangxingui@huawei.com> References: <20230904084804.39564-1-yangxingui@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500012.china.huawei.com (7.185.36.89) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use DEFINE_SHOW_STORE_ATTRIBUTE helper for read-write file to reduce some duplicated code. Signed-off-by: Luo Jiaxing Signed-off-by: Xingui Yang --- drivers/scsi/hisi_sas/hisi_sas_v3_hw.c | 137 ++----------------------- 1 file changed, 9 insertions(+), 128 deletions(-) diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c index bbb64ee6afd7..5bb35c3ea4e5 100644 --- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c @@ -3990,22 +3990,7 @@ static ssize_t debugfs_bist_linkrate_v3_hw_write(struct file *filp, return count; } - -static int debugfs_bist_linkrate_v3_hw_open(struct inode *inode, - struct file *filp) -{ - return single_open(filp, debugfs_bist_linkrate_v3_hw_show, - inode->i_private); -} - -static const struct file_operations debugfs_bist_linkrate_v3_hw_fops = { - .open = debugfs_bist_linkrate_v3_hw_open, - .read = seq_read, - .write = debugfs_bist_linkrate_v3_hw_write, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_linkrate_v3_hw); static const struct { int value; @@ -4080,22 +4065,7 @@ static ssize_t debugfs_bist_code_mode_v3_hw_write(struct file *filp, return count; } - -static int debugfs_bist_code_mode_v3_hw_open(struct inode *inode, - struct file *filp) -{ - return single_open(filp, debugfs_bist_code_mode_v3_hw_show, - inode->i_private); -} - -static const struct file_operations debugfs_bist_code_mode_v3_hw_fops = { - .open = debugfs_bist_code_mode_v3_hw_open, - .read = seq_read, - .write = debugfs_bist_code_mode_v3_hw_write, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_code_mode_v3_hw); static ssize_t debugfs_bist_phy_v3_hw_write(struct file *filp, const char __user *buf, @@ -4129,22 +4099,7 @@ static int debugfs_bist_phy_v3_hw_show(struct seq_file *s, void *p) return 0; } - -static int debugfs_bist_phy_v3_hw_open(struct inode *inode, - struct file *filp) -{ - return single_open(filp, debugfs_bist_phy_v3_hw_show, - inode->i_private); -} - -static const struct file_operations debugfs_bist_phy_v3_hw_fops = { - .open = debugfs_bist_phy_v3_hw_open, - .read = seq_read, - .write = debugfs_bist_phy_v3_hw_write, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_phy_v3_hw); static ssize_t debugfs_bist_cnt_v3_hw_write(struct file *filp, const char __user *buf, @@ -4177,22 +4132,7 @@ static int debugfs_bist_cnt_v3_hw_show(struct seq_file *s, void *p) return 0; } - -static int debugfs_bist_cnt_v3_hw_open(struct inode *inode, - struct file *filp) -{ - return single_open(filp, debugfs_bist_cnt_v3_hw_show, - inode->i_private); -} - -static const struct file_operations debugfs_bist_cnt_v3_hw_ops = { - .open = debugfs_bist_cnt_v3_hw_open, - .read = seq_read, - .write = debugfs_bist_cnt_v3_hw_write, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_cnt_v3_hw); static const struct { int value; @@ -4256,22 +4196,7 @@ static ssize_t debugfs_bist_mode_v3_hw_write(struct file *filp, return count; } - -static int debugfs_bist_mode_v3_hw_open(struct inode *inode, - struct file *filp) -{ - return single_open(filp, debugfs_bist_mode_v3_hw_show, - inode->i_private); -} - -static const struct file_operations debugfs_bist_mode_v3_hw_fops = { - .open = debugfs_bist_mode_v3_hw_open, - .read = seq_read, - .write = debugfs_bist_mode_v3_hw_write, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_mode_v3_hw); static ssize_t debugfs_bist_enable_v3_hw_write(struct file *filp, const char __user *buf, @@ -4309,22 +4234,7 @@ static int debugfs_bist_enable_v3_hw_show(struct seq_file *s, void *p) return 0; } - -static int debugfs_bist_enable_v3_hw_open(struct inode *inode, - struct file *filp) -{ - return single_open(filp, debugfs_bist_enable_v3_hw_show, - inode->i_private); -} - -static const struct file_operations debugfs_bist_enable_v3_hw_fops = { - .open = debugfs_bist_enable_v3_hw_open, - .read = seq_read, - .write = debugfs_bist_enable_v3_hw_write, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_bist_enable_v3_hw); static const struct { char *name; @@ -4362,21 +4272,7 @@ static int debugfs_v3_hw_show(struct seq_file *s, void *p) return 0; } - -static int debugfs_v3_hw_open(struct inode *inode, struct file *filp) -{ - return single_open(filp, debugfs_v3_hw_show, - inode->i_private); -} - -static const struct file_operations debugfs_v3_hw_fops = { - .open = debugfs_v3_hw_open, - .read = seq_read, - .write = debugfs_v3_hw_write, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_v3_hw); static ssize_t debugfs_phy_down_cnt_v3_hw_write(struct file *filp, const char __user *buf, @@ -4407,22 +4303,7 @@ static int debugfs_phy_down_cnt_v3_hw_show(struct seq_file *s, void *p) return 0; } - -static int debugfs_phy_down_cnt_v3_hw_open(struct inode *inode, - struct file *filp) -{ - return single_open(filp, debugfs_phy_down_cnt_v3_hw_show, - inode->i_private); -} - -static const struct file_operations debugfs_phy_down_cnt_v3_hw_fops = { - .open = debugfs_phy_down_cnt_v3_hw_open, - .read = seq_read, - .write = debugfs_phy_down_cnt_v3_hw_write, - .llseek = seq_lseek, - .release = single_release, - .owner = THIS_MODULE, -}; +DEFINE_SHOW_STORE_ATTRIBUTE(debugfs_phy_down_cnt_v3_hw); enum fifo_dump_mode_v3_hw { FIFO_DUMP_FORVER = (1U << 0), @@ -4832,7 +4713,7 @@ static void debugfs_bist_init_v3_hw(struct hisi_hba *hisi_hba) hisi_hba, &debugfs_bist_phy_v3_hw_fops); debugfs_create_file("cnt", 0600, hisi_hba->debugfs_bist_dentry, - hisi_hba, &debugfs_bist_cnt_v3_hw_ops); + hisi_hba, &debugfs_bist_cnt_v3_hw_fops); debugfs_create_file("loopback_mode", 0600, hisi_hba->debugfs_bist_dentry, -- 2.17.1