From patchwork Tue May 15 18:20:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Salil Mehta X-Patchwork-Id: 135916 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1371476lji; Tue, 15 May 2018 11:21:23 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpCM37N95fKgsHCuinpsmbvf2z3ojM0Zayoq+B0WpFh3bCT7FxZT1+5Af0QW9PsbU2uc3J3 X-Received: by 2002:a17:902:125:: with SMTP id 34-v6mr15865337plb.42.1526408483275; Tue, 15 May 2018 11:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526408483; cv=none; d=google.com; s=arc-20160816; b=wRVku3w6zfpAoQ7IQ3ESgjMybdOe15D+f4pp+WrR1H8Z+/W1lrErRl7zrro9lUWS1s CEtczz+QLTWK/+15zQ9+fqy6WlhqlJCVBx/AMdGDe14VrG6L6icKHlf1fgKYDsDjb5GF Owq/OfQDYY75nShMiKwI+zO+7Ou9Zq97r0vjuAK4KCNjZIgO0lLwMQu2a3pVMOyVfLWL k/Co76J/cBsbht1W1ghJwHZZpJzYG4HiRn1HW1kRvrmZ7rSmYihowhEnUAAdX93htx32 P9OtvTAFW/jMnxImspP3LH13UShuDPSBHREDf5RYVsajgjnGf0ZG+vdTK3F9KN3sWyd7 amRA== 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 s12-v6si455531pgq.616.2018.05.15.11.21.23; Tue, 15 May 2018 11:21:23 -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 S1753364AbeEOSVS (ORCPT + 29 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 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(-) -- 2.7.4 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))