Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp445138ybm; Thu, 28 May 2020 06:54:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvNYHajd/xUu6YvkohkIHACQ/oriiGW84CKOM/ZYrFqLy1u4XaksmSdY8o5YLTN+lf6fnR X-Received: by 2002:a17:906:7e03:: with SMTP id e3mr2874373ejr.363.1590674063135; Thu, 28 May 2020 06:54:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590674063; cv=none; d=google.com; s=arc-20160816; b=am6nl0n81tDwmCYOcS1QblX03Drlr+Ld5auRc+GToG2uyS2h6jyVXgdXcIxdKh8Q4+ qZPQE1vxr0+PwobnqzwP4S0gciZ0azfN1PRLOZlyeLkBO4VDMT2njCuvzF3dM3TfNHGM oUv5E6IpfCjf4IGcAsWyJcBbbO4H5PdQYTBlL8jYoYhPoPhjAsks3IG45m38eHuSwlCB nlLkQtJPR5ED6X0gdf2Pt4rHaAnokrXZ4gr5Sr2BKB9e4taXzCgGTlQbaVkuOycwag2y WFb1iuEhDz9J3d7vMlpnBl4XsINRsfWSTXvHDkvvQxbGjS+FOg4wd2Dc1dIcm1lp3ShL qgSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=/PWUAiZcLJU5sQMnDykHnZDikUqmZ1tR3iFrkthHOCg=; b=bYvZt4YRCaBUyKoKkICgiBeWlcuoELBr5RoSxFnLvsOiU0cZGI6o751arkISpLlinD 2if0jinzuYHu1wFJ8DN3bE+pst//FVT32OetxIS6Mv/7l7NHVMpVXGNHGGEdaksmnmH0 PZvOP5jjSBFfzce61GhH70QUVRTEd7U+P5y3zVjuLMfOw0IPfkLG+xFgPiyEdQ6MVhFS DVAMc5w61naizfaGXRaiNxV/aORPJg6Q/eWiASKGiifcqgU612++7/VXp2Ypv/VTyWw6 u6gFvp6b3A5WzOjMz5foS249Vj5/B3HPzuCnlwd3b4NyBd3MAC5D6E1876Z1+DyHI/Dl JRkw== 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 ce20si3815099ejb.748.2020.05.28.06.54.00; Thu, 28 May 2020 06:54: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 S2390705AbgE1Nvm (ORCPT + 99 others); Thu, 28 May 2020 09:51:42 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5377 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2390648AbgE1NvS (ORCPT ); Thu, 28 May 2020 09:51:18 -0400 Received: from DGGEMS413-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 445F2A45B7694D45A70C; Thu, 28 May 2020 21:50:59 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS413-HUB.china.huawei.com (10.3.19.213) with Microsoft SMTP Server id 14.3.487.0; Thu, 28 May 2020 21:50:49 +0800 From: Huazhong Tan To: CC: , , , , , , Huazhong Tan Subject: [PATCH net-next 04/12] net: hns3: refactor hclge_query_bd_num_cmd_send() Date: Thu, 28 May 2020 21:48:11 +0800 Message-ID: <1590673699-63819-5-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1590673699-63819-1-git-send-email-tanhuazhong@huawei.com> References: <1590673699-63819-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order to improve code maintainability and readability, rewrite the process of BDs' initialization in hclge_query_bd_num_cmd_send(). Signed-off-by: Huazhong Tan --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c index 35e5cb8..e9b0e1c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c @@ -10723,16 +10723,19 @@ static int hclge_get_64_bit_regs(struct hclge_dev *hdev, u32 regs_num, int hclge_query_bd_num_cmd_send(struct hclge_dev *hdev, struct hclge_desc *desc) { - /*prepare 4 commands to query DFX BD number*/ - hclge_cmd_setup_basic_desc(&desc[0], HCLGE_OPC_DFX_BD_NUM, true); - desc[0].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT); - hclge_cmd_setup_basic_desc(&desc[1], HCLGE_OPC_DFX_BD_NUM, true); - desc[1].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT); - hclge_cmd_setup_basic_desc(&desc[2], HCLGE_OPC_DFX_BD_NUM, true); - desc[2].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT); - hclge_cmd_setup_basic_desc(&desc[3], HCLGE_OPC_DFX_BD_NUM, true); + int i; + + /* initialize command BD except the last one */ + for (i = 0; i < HCLGE_GET_DFX_REG_TYPE_CNT - 1; i++) { + hclge_cmd_setup_basic_desc(&desc[i], HCLGE_OPC_DFX_BD_NUM, + true); + desc[i].flag |= cpu_to_le16(HCLGE_CMD_FLAG_NEXT); + } + + /* initialize the last command BD */ + hclge_cmd_setup_basic_desc(&desc[i], HCLGE_OPC_DFX_BD_NUM, true); - return hclge_cmd_send(&hdev->hw, desc, 4); + return hclge_cmd_send(&hdev->hw, desc, HCLGE_GET_DFX_REG_TYPE_CNT); } static int hclge_get_dfx_reg_bd_num(struct hclge_dev *hdev, -- 2.7.4