From patchwork Tue Feb 13 15:37:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Marchand X-Patchwork-Id: 136646 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2C63943B08; Tue, 13 Feb 2024 16:37:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B67DB409FA; Tue, 13 Feb 2024 16:37:50 +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 459FF402D8 for ; Tue, 13 Feb 2024 16:37:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707838668; 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; bh=Y/JdMX8CfJ8/nHdZ3/wu/WXGoimjqilj7JIpTR4ugFo=; b=aW8+1wuZbBjFh+ibDAMHS72/tzLCe0v+rQd8D3n8xBLT4b58kj7eOURX3YG0Yj3kF8jaA6 +9AiUu88LKySHuTNJpORE5c+RCfRlAtOn+MRJ0rcofE2GcFADF/OByakUjCKnK27Pl75w8 /GrGONAD+yid+ESo2d8448Hvwhs9BPA= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-61-1xCIiuaHOXOxykWNoqgI6A-1; Tue, 13 Feb 2024 10:37:45 -0500 X-MC-Unique: 1xCIiuaHOXOxykWNoqgI6A-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 26CEE1C0982F; Tue, 13 Feb 2024 15:37:45 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.225.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 369831C05DB7; Tue, 13 Feb 2024 15:37:44 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: Rahul Lakkireddy , Yuying Zhang , Rosen Xu Subject: [PATCH] drivers: use common container_of macro Date: Tue, 13 Feb 2024 16:37:41 +0100 Message-ID: <20240213153741.2133915-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 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org rte_common.h provides container_of if none is defined. The drivers headers touched by this commit either already include rte_common.h or use some other common macro defined in rte_common.h. As a consequence, it seems safe to assume that container_of is always available for includers of those headers. Signed-off-by: David Marchand Reviewed-by: Tyler Retzlaff Acked-by: Chengwen Feng --- drivers/net/cxgbe/cxgbe_compat.h | 6 ------ drivers/net/i40e/i40e_rxtx.h | 5 ----- drivers/raw/ifpga/base/ifpga_compat.h | 5 ----- 3 files changed, 16 deletions(-) diff --git a/drivers/net/cxgbe/cxgbe_compat.h b/drivers/net/cxgbe/cxgbe_compat.h index 0b02eb62a9..e74d476f6d 100644 --- a/drivers/net/cxgbe/cxgbe_compat.h +++ b/drivers/net/cxgbe/cxgbe_compat.h @@ -135,12 +135,6 @@ typedef uint64_t dma_addr_t; */ #define cxgbe_roundup(_p, _s) (((unsigned long)(_p) + (_s - 1)) & ~(_s - 1)) -#ifndef container_of -#define container_of(ptr, type, member) ({ \ - typeof(((type *)0)->member)(*__mptr) = (ptr); \ - (type *)((char *)__mptr - offsetof(type, member)); }) -#endif - #define ARRAY_SIZE(arr) RTE_DIM(arr) #define cpu_to_be16(o) rte_cpu_to_be_16(o) diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h index b191f23e1f..a3a53ffce4 100644 --- a/drivers/net/i40e/i40e_rxtx.h +++ b/drivers/net/i40e/i40e_rxtx.h @@ -45,11 +45,6 @@ #define I40E_RX_DESC_EXT_STATUS_FLEXBL_MASK 0x03 #define I40E_RX_DESC_EXT_STATUS_FLEXBL_FLEX 0x01 -#undef container_of -#define container_of(ptr, type, member) ({ \ - typeof(((type *)0)->member)(*__mptr) = (ptr); \ - (type *)((char *)__mptr - offsetof(type, member)); }) - #define I40E_TD_CMD (I40E_TX_DESC_CMD_ICRC |\ I40E_TX_DESC_CMD_EOP) diff --git a/drivers/raw/ifpga/base/ifpga_compat.h b/drivers/raw/ifpga/base/ifpga_compat.h index cdeca70ca5..8a624d174f 100644 --- a/drivers/raw/ifpga/base/ifpga_compat.h +++ b/drivers/raw/ifpga/base/ifpga_compat.h @@ -7,11 +7,6 @@ #include "opae_osdep.h" -#undef container_of -#define container_of(ptr, type, member) ({ \ - typeof(((type *)0)->member)(*__mptr) = (ptr); \ - (type *)((char *)__mptr - offsetof(type, member)); }) - #define IFPGA_PAGE_SHIFT 12 #define IFPGA_PAGE_SIZE (1 << IFPGA_PAGE_SHIFT) #define IFPGA_PAGE_MASK (~(IFPGA_PAGE_SIZE - 1))