Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp937463ybl; Wed, 28 Aug 2019 07:27:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqyH18pRK5jiUHW04zm1puR6jObcxpyf5SRKDnztXUGOnLCyXWVAKO9ByUYNw1w4jUEvC5pv X-Received: by 2002:a17:90a:f011:: with SMTP id bt17mr4500733pjb.21.1567002422630; Wed, 28 Aug 2019 07:27:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567002422; cv=none; d=google.com; s=arc-20160816; b=LW9eDW+yM+6JwITDQ6AsPs/rOSK+XaX8ALQDIwZhWtp8fbhzDOojbE4lae9eYKUNA7 kBAO3fDUdcceKJbIPIp1R42jSRGcHsOoMqg4bk11h6mFJyorf2+t7N2jlWvCC6kXJQjo nQBq7X4ZG39lLDZceWzJBwE2D4lZ1dcxrxH+XtBr8g7/YMxb2J7KgVCXU7pn0WheYTqr qm1kOiR5F7kyJj8kd+zkMTBz0AceBkB6kgqgopFzdeQvgsEp9xlbWi/erprvNIEKl3HA 4YzrC+M7sRHtpGgI355vKy2zOmQBbrohJRU5KJDKXFPlzqLoF3AHw4br/28xFA49yIT3 vTqg== 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=Tm/OGYxMG9lmNjmOODZrPIPQnRut4Cz8Ri8G+Pbpgp8=; b=hEWyFslos3j/x5gvd6+OrGWxI0gQkojGQPXak2qn7+lS4fqero/4xNUyV/ZjU6s1bu Yv3c0WUcas/gmhEuS5G5UfLtJJKZtkeYFK//pncSh4Xr+cYeZKzR1w8z7QFpJRULg6XB 3/0JcqF9GObuvkn+UfO4LXVqc8DoN25eB0VLGvg902FXtAgZXSkOkpr0LMEC9viT+VBW sQTCbQbS4+zWkKzN40y4A9CtzVLwSG6mQzveZHNVZXOglJMTMeVfz9gMw98rXL14u4A7 h2XXDuh1y7wqZBVKC2H3cOzEEMOOXJN3lJM57uhfr8jKoyjcOoKYvagtcZ0e9LJ23ZIS IQDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c130si2631330pfc.103.2019.08.28.07.26.46; Wed, 28 Aug 2019 07:27:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727025AbfH1OZt (ORCPT + 99 others); Wed, 28 Aug 2019 10:25:49 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:50216 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726935AbfH1OZp (ORCPT ); Wed, 28 Aug 2019 10:25:45 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 339BC36F8D688E6C83F0; Wed, 28 Aug 2019 22:25:41 +0800 (CST) Received: from localhost.localdomain (10.67.212.132) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.439.0; Wed, 28 Aug 2019 22:25:31 +0800 From: Huazhong Tan To: CC: , , , , , Yonglong Liu , Huazhong Tan Subject: [PATCH net-next 06/12] net: hns3: make some reusable codes into a function Date: Wed, 28 Aug 2019 22:23:10 +0800 Message-ID: <1567002196-63242-7-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1567002196-63242-1-git-send-email-tanhuazhong@huawei.com> References: <1567002196-63242-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.212.132] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yonglong Liu In hclge_dcb.c, these pair of codes: hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT); and hclge_notify_client(hdev, HNAE3_INIT_CLIENT); hclge_notify_client(hdev, HNAE3_UP_CLIENT); are called many times, so make them into a function. Signed-off-by: Yonglong Liu Reviewed-by: Peng Li Signed-off-by: Huazhong Tan --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c | 54 +++++++++++----------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c index 814e0f0..816f920 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_dcb.c @@ -198,6 +198,28 @@ static int hclge_client_setup_tc(struct hclge_dev *hdev) return 0; } +static int hclge_notify_down_uinit(struct hclge_dev *hdev) +{ + int ret; + + ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); + if (ret) + return ret; + + return hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT); +} + +static int hclge_notify_init_up(struct hclge_dev *hdev) +{ + int ret; + + ret = hclge_notify_client(hdev, HNAE3_INIT_CLIENT); + if (ret) + return ret; + + return hclge_notify_client(hdev, HNAE3_UP_CLIENT); +} + static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets) { struct hclge_vport *vport = hclge_get_vport(h); @@ -218,11 +240,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets) if (map_changed) { netif_dbg(h, drv, netdev, "set ets\n"); - ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); - if (ret) - return ret; - - ret = hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT); + ret = hclge_notify_down_uinit(hdev); if (ret) return ret; } @@ -242,11 +260,7 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets) if (ret) goto err_out; - ret = hclge_notify_client(hdev, HNAE3_INIT_CLIENT); - if (ret) - return ret; - - ret = hclge_notify_client(hdev, HNAE3_UP_CLIENT); + ret = hclge_notify_init_up(hdev); if (ret) return ret; } @@ -257,10 +271,8 @@ static int hclge_ieee_setets(struct hnae3_handle *h, struct ieee_ets *ets) if (!map_changed) return ret; - if (hclge_notify_client(hdev, HNAE3_INIT_CLIENT)) - return ret; + hclge_notify_init_up(hdev); - hclge_notify_client(hdev, HNAE3_UP_CLIENT); return ret; } @@ -383,11 +395,7 @@ static int hclge_setup_tc(struct hnae3_handle *h, u8 tc, u8 *prio_tc) if (ret) return -EINVAL; - ret = hclge_notify_client(hdev, HNAE3_DOWN_CLIENT); - if (ret) - return ret; - - ret = hclge_notify_client(hdev, HNAE3_UNINIT_CLIENT); + ret = hclge_notify_down_uinit(hdev); if (ret) return ret; @@ -409,17 +417,11 @@ static int hclge_setup_tc(struct hnae3_handle *h, u8 tc, u8 *prio_tc) else hdev->flag &= ~HCLGE_FLAG_MQPRIO_ENABLE; - ret = hclge_notify_client(hdev, HNAE3_INIT_CLIENT); - if (ret) - return ret; - - return hclge_notify_client(hdev, HNAE3_UP_CLIENT); + return hclge_notify_init_up(hdev); err_out: - if (hclge_notify_client(hdev, HNAE3_INIT_CLIENT)) - return ret; + hclge_notify_init_up(hdev); - hclge_notify_client(hdev, HNAE3_UP_CLIENT); return ret; } -- 2.7.4