Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1644355pxk; Fri, 18 Sep 2020 19:56:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+cNSsWqh/1PyADdAXXN2u/YC0bz5C0mEchS6yaxLNOiYz4GN/BqiM+rTME3tUTWXEjWDY X-Received: by 2002:aa7:d981:: with SMTP id u1mr40862390eds.250.1600484167929; Fri, 18 Sep 2020 19:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600484167; cv=none; d=google.com; s=arc-20160816; b=vJSUSKDeyFoHkAlKMOgGoxl2ofQRNkeEvsc1NpKaUONTRHDAKXNf+0dwNjBkrmShOQ r8jvvgP3uB/cY5v1DpVnPUoAy4gd9AyRLx4OX1AMEezoaXYeGwPB1tAIyZCSBarl0WA/ KiddwXP2cTd33wynOzRBtkYz4cF2PNxzx/3gpRZ2wkvu71uEp4FnFdmdRnpLdCAAcokd ysHW7n85Xm2MmA6D9Dux6759KsERhIfvdZaCKlhsr1UcrnprNFrkUBeswVJBAnXP3hwP wBLpXXaJyF/wMYOfj295abLEle0NnoT7AZE9ek3rkxZqmWw9huAJjH12EIkjZVUJAXRe LL4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=nDXtoEbm6oyuxSWS7bdMoiqm9QVwr/uFdj82IgcelYU=; b=ZGjnyVMuGF7AfMyvVlZZmOvdeYuIgqYaQ8H+bWhCzB4V30xI8ys/CHV4MYeMonh6mD d3O25dYGpTE6jbsawZ96vkkbVqItCvRVJKPcaissDiOHbuhh8bRieEDMZ+SggVlmM+Nf k260d/JPMzVcnUqKN7RPwYU9UEufDh+1l9kK/zc6xxmdav054HdSxj18V+6dvgYzcDxa ZXVumTJi+X2EshSkZILd9ulMWiDyN8nq2Dww5ZeW1REx5wOuhcwrk080rDyNLNk4p24/ sX2fjqYXK9DeI6P28CyuDgGzRZSLQxMeiXNOaeI1IUKqfs8VBaW/ZM3W2hCsUynRv7kB EzeQ== 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 v6si3415250edt.456.2020.09.18.19.55.43; Fri, 18 Sep 2020 19:56:07 -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 S1726484AbgISCwE (ORCPT + 99 others); Fri, 18 Sep 2020 22:52:04 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:51396 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726368AbgISCvm (ORCPT ); Fri, 18 Sep 2020 22:51:42 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 232E1E11E9FB619E256E; Sat, 19 Sep 2020 10:51:40 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Sat, 19 Sep 2020 10:51:30 +0800 From: Qinglang Miao To: Nilesh Javali , , "James E.J. Bottomley" , "Martin K. Petersen" CC: , , "Qinglang Miao" Subject: [PATCH -next v2] scsi: qla2xxx: Convert to DEFINE_SHOW_ATTRIBUTE Date: Sat, 19 Sep 2020 10:52:02 +0800 Message-ID: <20200919025202.17531-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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. drivers/scsi/qla2xxx/qla_dfs.c | 68 ++++------------------------------ 1 file changed, 8 insertions(+), 60 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_dfs.c b/drivers/scsi/qla2xxx/qla_dfs.c index e62b21152..9e49b47f6 100644 --- a/drivers/scsi/qla2xxx/qla_dfs.c +++ b/drivers/scsi/qla2xxx/qla_dfs.c @@ -37,20 +37,7 @@ qla2x00_dfs_tgt_sess_show(struct seq_file *s, void *unused) return 0; } -static int -qla2x00_dfs_tgt_sess_open(struct inode *inode, struct file *file) -{ - scsi_qla_host_t *vha = inode->i_private; - - return single_open(file, qla2x00_dfs_tgt_sess_show, vha); -} - -static const struct file_operations dfs_tgt_sess_ops = { - .open = qla2x00_dfs_tgt_sess_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(qla2x00_dfs_tgt_sess); static int qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused) @@ -106,20 +93,7 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused) return 0; } -static int -qla2x00_dfs_tgt_port_database_open(struct inode *inode, struct file *file) -{ - scsi_qla_host_t *vha = inode->i_private; - - return single_open(file, qla2x00_dfs_tgt_port_database_show, vha); -} - -static const struct file_operations dfs_tgt_port_database_ops = { - .open = qla2x00_dfs_tgt_port_database_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(qla2x00_dfs_tgt_port_database); static int qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused) @@ -154,20 +128,7 @@ qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused) return 0; } -static int -qla_dfs_fw_resource_cnt_open(struct inode *inode, struct file *file) -{ - struct scsi_qla_host *vha = inode->i_private; - - return single_open(file, qla_dfs_fw_resource_cnt_show, vha); -} - -static const struct file_operations dfs_fw_resource_cnt_ops = { - .open = qla_dfs_fw_resource_cnt_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(qla_dfs_fw_resource_cnt); static int qla_dfs_tgt_counters_show(struct seq_file *s, void *unused) @@ -244,20 +205,7 @@ qla_dfs_tgt_counters_show(struct seq_file *s, void *unused) return 0; } -static int -qla_dfs_tgt_counters_open(struct inode *inode, struct file *file) -{ - struct scsi_qla_host *vha = inode->i_private; - - return single_open(file, qla_dfs_tgt_counters_show, vha); -} - -static const struct file_operations dfs_tgt_counters_ops = { - .open = qla_dfs_tgt_counters_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, -}; +DEFINE_SHOW_ATTRIBUTE(qla_dfs_tgt_counters); static int qla2x00_dfs_fce_show(struct seq_file *s, void *unused) @@ -459,19 +407,19 @@ qla2x00_dfs_setup(scsi_qla_host_t *vha) create_nodes: ha->dfs_fw_resource_cnt = debugfs_create_file("fw_resource_count", - S_IRUSR, ha->dfs_dir, vha, &dfs_fw_resource_cnt_ops); + S_IRUSR, ha->dfs_dir, vha, &qla_dfs_fw_resource_cnt_fops); ha->dfs_tgt_counters = debugfs_create_file("tgt_counters", S_IRUSR, - ha->dfs_dir, vha, &dfs_tgt_counters_ops); + ha->dfs_dir, vha, &qla_dfs_tgt_counters_fops); ha->tgt.dfs_tgt_port_database = debugfs_create_file("tgt_port_database", - S_IRUSR, ha->dfs_dir, vha, &dfs_tgt_port_database_ops); + S_IRUSR, ha->dfs_dir, vha, &qla2x00_dfs_tgt_port_database_fops); ha->dfs_fce = debugfs_create_file("fce", S_IRUSR, ha->dfs_dir, vha, &dfs_fce_ops); ha->tgt.dfs_tgt_sess = debugfs_create_file("tgt_sess", - S_IRUSR, ha->dfs_dir, vha, &dfs_tgt_sess_ops); + S_IRUSR, ha->dfs_dir, vha, &qla2x00_dfs_tgt_sess_fops); if (IS_QLA27XX(ha) || IS_QLA83XX(ha) || IS_QLA28XX(ha)) ha->tgt.dfs_naqp = debugfs_create_file("naqp", -- 2.23.0