Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp943183imm; Tue, 15 May 2018 11:24:53 -0700 (PDT) X-Google-Smtp-Source: AB8JxZokJ/7esNx0/XPfpdXQb5m8oXvl4KS9IkNY+3wXfhATCAaojeCX8+kVJqB5z4eBpEAxV+Rw X-Received: by 2002:a17:902:7283:: with SMTP id d3-v6mr15842254pll.192.1526408693387; Tue, 15 May 2018 11:24:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526408693; cv=none; d=google.com; s=arc-20160816; b=OViROS0v34+t1IxbmRB0K5yvEtPGvW0vEL+ugvV2K0rbNMIY5v4J4wQGzGbTTBytu6 weMcao3NcCD9A5st5F6lGbAEgO4oaHKTKdjj02FfaAmU9IzBnZ3j+9ZeFvAZxMSBXVp6 nyca+2yARvL0lJkdSG+y/Ikj7IMExKYDO90Pd0yjSQg+YebJwZ+H51W67NC1TfiUAaHP f8qNjK/vvDVcFD+hwejYkCuzjsU80I/vXf/CPBYAlnCBb3pp+lrVLuABZBmnA0bMVYLq WhU72o55Htc9y8+SZcWJxbyTvc/lANg4EV4mIa0zrI4OhQWNEMLwJcVYcybT4DoW6YTc gy3Q== 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:arc-authentication-results; bh=TtIbiIn5zLPX2zmL0mPP7A+mhAdEjew6tOCXeF9Ec+c=; b=RNPI1U/V1e21oXTQ+6ht8laCAyfZwS2slkiTjvxA9KHRwUsfYkFwczjSM8HGBAfU1q /uD3+PDBXvtEPor3nqUm9DaaCqRTbPBAzdKUSFa7iUCMGHMOsztVx24evmY+htaI0ZFK oGJHMTBR7xSWygFPvJSm6LInXq7bfQy2tGVBkPCnICyEN4ighm5mDW/bQB7ppKjNsR12 lgc216EtC9iUklpk2lBPMMvn0AKpJwGlIhKuUgS5zOGrZt2BJDNZhpbomqfFUyHTUG2P BLdf3fuoPsnnG1piHMYtfW2eCWPoUgKY42+kwYHazkkVg9k+rVe3fmBy9pNexknsfb8Q 2HXw== 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 t6-v6si364077pgp.594.2018.05.15.11.24.39; Tue, 15 May 2018 11:24:53 -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 S1753335AbeEOSVS (ORCPT + 99 others); Tue, 15 May 2018 14:21:18 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:59461 "EHLO huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1753113AbeEOSVQ (ORCPT ); Tue, 15 May 2018 14:21:16 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 9E8BF1FC0D57D; Wed, 16 May 2018 02:21:11 +0800 (CST) Received: from S00293818-DELL1.china.huawei.com (10.202.227.234) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.382.0; Wed, 16 May 2018 02:21:04 +0800 From: Salil Mehta To: CC: , , , , , , , Fuyun Liang Subject: [PATCH net-next 03/10] net: hns3: Add a check for client instance init state Date: Tue, 15 May 2018 19:20:07 +0100 Message-ID: <20180515182014.42196-4-salil.mehta@huawei.com> X-Mailer: git-send-email 2.8.3 In-Reply-To: <20180515182014.42196-1-salil.mehta@huawei.com> References: <20180515182014.42196-1-salil.mehta@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.202.227.234] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang If the client instance is initializd failed, we do not need to uninit it. This patch adds a state check to check init state of client instance. Fixes: 38caee9d3ee8 ("net: hns3: Add support of the HNAE3 framework") Signed-off-by: Fuyun Liang Signed-off-by: Peng Li Signed-off-by: Salil Mehta --- drivers/net/ethernet/hisilicon/hns3/hnae3.c | 15 ++++++++++++--- drivers/net/ethernet/hisilicon/hns3/hnae3.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.c b/drivers/net/ethernet/hisilicon/hns3/hnae3.c index ab2e72c..21cb0c5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.c +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.c @@ -50,13 +50,22 @@ static int hnae3_match_n_instantiate(struct hnae3_client *client, /* now, (un-)instantiate client by calling lower layer */ if (is_reg) { ret = ae_dev->ops->init_client_instance(client, ae_dev); - if (ret) + if (ret) { dev_err(&ae_dev->pdev->dev, "fail to instantiate client\n"); - return ret; + return ret; + } + + hnae_set_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B, 1); + return 0; + } + + if (hnae_get_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B)) { + ae_dev->ops->uninit_client_instance(client, ae_dev); + + hnae_set_bit(ae_dev->flag, HNAE3_CLIENT_INITED_B, 0); } - ae_dev->ops->uninit_client_instance(client, ae_dev); return 0; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hnae3.h b/drivers/net/ethernet/hisilicon/hns3/hnae3.h index 804ea83..ffec231 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hnae3.h +++ b/drivers/net/ethernet/hisilicon/hns3/hnae3.h @@ -52,6 +52,7 @@ #define HNAE3_DEV_INITED_B 0x0 #define HNAE3_DEV_SUPPORT_ROCE_B 0x1 #define HNAE3_DEV_SUPPORT_DCB_B 0x2 +#define HNAE3_CLIENT_INITED_B 0x3 #define HNAE3_DEV_SUPPORT_ROCE_DCB_BITS (BIT(HNAE3_DEV_SUPPORT_DCB_B) |\ BIT(HNAE3_DEV_SUPPORT_ROCE_B)) -- 2.7.4