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 1EF2643B30;
	Fri, 16 Feb 2024 11:25:16 +0100 (CET)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id CF79C42F29;
	Fri, 16 Feb 2024 11:25:13 +0100 (CET)
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 1050B42F29
 for <dev@dpdk.org>; Fri, 16 Feb 2024 11:25:11 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1708079111;
 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=RmGcgynceyVAVZNSHK7JRf5ys+p306YSG4DcNnOCzU0=;
 b=iaEj+WuBBOgW6aEiCvYWJTVJFrKUtzoIOVlJ1zuOi21o8W9Iu+fr5wFHI6cMw3bR2mAipo
 agNNax9VePeX7keVob27mdb23W81QeTEk+7MAPwRoClWMN4Fpl26DL1r+iiyK9JE+YnzZY
 G1fN6IQF1JG2pv7GuOfa+T8O1jQa7H8=
Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com
 [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS
 (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id
 us-mta-433-YayEDhICOvqm2jg0J_DJ4g-1; Fri, 16 Feb 2024 05:25:08 -0500
X-MC-Unique: YayEDhICOvqm2jg0J_DJ4g-1
Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com
 [10.11.54.7])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256)
 (No client certificate requested)
 by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1052485A58B;
 Fri, 16 Feb 2024 10:25:08 +0000 (UTC)
Received: from dmarchan.redhat.com (unknown [10.45.225.53])
 by smtp.corp.redhat.com (Postfix) with ESMTP id CDF681C06890;
 Fri, 16 Feb 2024 10:25:06 +0000 (UTC)
From: David Marchand <david.marchand@redhat.com>
To: dev@dpdk.org
Cc: Ajit Khaparde <ajit.khaparde@broadcom.com>,
 Somnath Kotur <somnath.kotur@broadcom.com>,
 Devendra Singh Rawat <dsinghrawat@marvell.com>,
 Alok Prasad <palok@marvell.com>, Rosen Xu <rosen.xu@intel.com>
Subject: [PATCH v2 2/3] drivers: use common min/max macros
Date: Fri, 16 Feb 2024 11:24:53 +0100
Message-ID: <20240216102454.4156609-3-david.marchand@redhat.com>
In-Reply-To: <20240216102454.4156609-1-david.marchand@redhat.com>
References: <1700089378-26197-1-git-send-email-roretzla@linux.microsoft.com>
 <20240216102454.4156609-1-david.marchand@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7
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

Use newly introduced macro.

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/bnxt/bnxt_ethdev.c                   | 12 +-----------
 drivers/net/qede/base/bcm_osal.h                 |  6 ++----
 drivers/raw/ifpga/base/osdep_rte/osdep_generic.h | 11 ++---------
 3 files changed, 5 insertions(+), 24 deletions(-)

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 45d840d7af..8cc012206a 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -4867,17 +4867,7 @@ static void bnxt_free_ctx_mem(struct bnxt *bp)
 
 #define bnxt_roundup(x, y)   ((((x) + ((y) - 1)) / (y)) * (y))
 
-#define min_t(type, x, y) ({                    \
-	type __min1 = (x);                      \
-	type __min2 = (y);                      \
-	__min1 < __min2 ? __min1 : __min2; })
-
-#define max_t(type, x, y) ({                    \
-	type __max1 = (x);                      \
-	type __max2 = (y);                      \
-	__max1 > __max2 ? __max1 : __max2; })
-
-#define clamp_t(type, _x, min, max)     min_t(type, max_t(type, _x, min), max)
+#define clamp_t(type, _x, min, max) RTE_MIN_T(RTE_MAX_T(_x, min, type), max, type)
 
 int bnxt_alloc_ctx_mem(struct bnxt *bp)
 {
diff --git a/drivers/net/qede/base/bcm_osal.h b/drivers/net/qede/base/bcm_osal.h
index 11019b5623..7869103c63 100644
--- a/drivers/net/qede/base/bcm_osal.h
+++ b/drivers/net/qede/base/bcm_osal.h
@@ -443,10 +443,8 @@ u32 qede_osal_log2(u32);
 #define OSAL_IOMEM volatile
 #define OSAL_UNUSED    __rte_unused
 #define OSAL_UNLIKELY(x)  __builtin_expect(!!(x), 0)
-#define OSAL_MIN_T(type, __min1, __min2)	\
-	((type)(__min1) < (type)(__min2) ? (type)(__min1) : (type)(__min2))
-#define OSAL_MAX_T(type, __max1, __max2)	\
-	((type)(__max1) > (type)(__max2) ? (type)(__max1) : (type)(__max2))
+#define OSAL_MIN_T(type, __min1, __min2) RTE_MIN_T(__min1, __min2, type)
+#define OSAL_MAX_T(type, __max1, __max2) RTE_MAX_T(__max1, __max2, type)
 
 void qede_get_mcp_proto_stats(struct ecore_dev *, enum ecore_mcp_protocol_type,
 			      union ecore_mcp_protocol_stats *);
diff --git a/drivers/raw/ifpga/base/osdep_rte/osdep_generic.h b/drivers/raw/ifpga/base/osdep_rte/osdep_generic.h
index 62c5666ca9..427793a578 100644
--- a/drivers/raw/ifpga/base/osdep_rte/osdep_generic.h
+++ b/drivers/raw/ifpga/base/osdep_rte/osdep_generic.h
@@ -44,15 +44,8 @@ extern int ifpga_rawdev_logtype;
 #define min(a, b) RTE_MIN(a, b)
 #define max(a, b) RTE_MAX(a, b)
 
-#define min_t(type, x, y) ({                    \
-	type __min1 = (x);                      \
-	type __min2 = (y);                      \
-	__min1 < __min2 ? __min1 : __min2; })
-
-#define max_t(type, x, y) ({                    \
-	type __max1 = (x);                      \
-	type __max2 = (y);                      \
-	__max1 > __max2 ? __max1 : __max2; })
+#define min_t(type, x, y) RTE_MIN_T(x, y, type)
+#define max_t(type, x, y) RTE_MAX_T(x, y, type)
 
 #define spinlock_t rte_spinlock_t
 #define spinlock_init(x) rte_spinlock_init(x)
-- 
2.43.0