From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id C8D67A0547;
	Mon,  5 Sep 2022 10:39:53 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 7553B427F2;
	Mon,  5 Sep 2022 10:39:49 +0200 (CEST)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [170.10.129.124])
 by mails.dpdk.org (Postfix) with ESMTP id 5DED7427F6
 for <dev@dpdk.org>; Mon,  5 Sep 2022 10:39:47 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1662367186;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=ov8223pnVCudrwM3ulRY8LJCoOF3gG81hcVUI/2th6c=;
 b=adrDMExA6T08KaMC8VHwO0lvxcldULSgzpvE3DEP0SHNQC08gFuFmBFHWAnT85t/FFuL77
 0T65TiQ4wW9GhQ9iqol7cQRlieFdVSB0qbn6sIvi4BAkgtshSjWRM1cUm2r/mx1+B+X1ZK
 grc2S4KocWVy80wvvsmErU+q8jI8BsU=
Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com
 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS
 (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id
 us-mta-615-GZ69chs0Or2VNeJ7oM7Txg-1; Mon, 05 Sep 2022 04:39:46 -0400
X-MC-Unique: GZ69chs0Or2VNeJ7oM7Txg-1
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com
 [10.11.54.3])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8C6451C0BC6E;
 Mon,  5 Sep 2022 08:39:45 +0000 (UTC)
Received: from fchome.redhat.com (unknown [10.40.193.251])
 by smtp.corp.redhat.com (Postfix) with ESMTP id 7CB781121314;
 Mon,  5 Sep 2022 08:39:44 +0000 (UTC)
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, bruce.richardson@intel.com,
 Matan Azrad <matan@nvidia.com>,
 Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Subject: [PATCH v5 02/27] common/mlx5: rework check on driver registration
Date: Mon,  5 Sep 2022 10:39:08 +0200
Message-Id: <20220905083933.2506819-3-david.marchand@redhat.com>
In-Reply-To: <20220905083933.2506819-1-david.marchand@redhat.com>
References: <20220628144643.1213026-1-david.marchand@redhat.com>
 <20220905083933.2506819-1-david.marchand@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="US-ASCII"; x-default=true
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

Rely on a local flag rather than dereference a bus object.
This will help next commits.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/common/mlx5/linux/mlx5_common_auxiliary.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/common/mlx5/linux/mlx5_common_auxiliary.c b/drivers/common/mlx5/linux/mlx5_common_auxiliary.c
index 6584aeb18e..a182a8bdde 100644
--- a/drivers/common/mlx5/linux/mlx5_common_auxiliary.c
+++ b/drivers/common/mlx5/linux/mlx5_common_auxiliary.c
@@ -179,14 +179,20 @@ static struct rte_auxiliary_driver mlx5_auxiliary_driver = {
 	.dma_unmap = mlx5_common_auxiliary_dma_unmap,
 };
 
+static bool mlx5_common_auxiliary_initialized;
+
 void mlx5_common_auxiliary_init(void)
 {
-	if (mlx5_auxiliary_driver.bus == NULL)
+	if (!mlx5_common_auxiliary_initialized) {
 		rte_auxiliary_register(&mlx5_auxiliary_driver);
+		mlx5_common_auxiliary_initialized = true;
+	}
 }
 
 RTE_FINI(mlx5_common_auxiliary_driver_finish)
 {
-	if (mlx5_auxiliary_driver.bus != NULL)
+	if (mlx5_common_auxiliary_initialized) {
 		rte_auxiliary_unregister(&mlx5_auxiliary_driver);
+		mlx5_common_auxiliary_initialized = false;
+	}
 }
-- 
2.37.2