[PATCH v2 2/3] drivers: use common min/max macros
Ajit Khaparde
ajit.khaparde at broadcom.com
Mon Feb 19 03:13:03 CET 2024
On Fri, Feb 16, 2024 at 2:25 AM David Marchand
<david.marchand at redhat.com> wrote:
>
> Use newly introduced macro.
>
> Signed-off-by: David Marchand <david.marchand at redhat.com>
Acked-by: Ajit Khaparde <ajit.khaparde at broadcom.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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4218 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mails.dpdk.org/archives/dev/attachments/20240218/bcde295f/attachment.bin>
More information about the dev
mailing list