drivers: use common container_of macro
Checks
Commit Message
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 <david.marchand@redhat.com>
---
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(-)
Comments
On Tue, Feb 13, 2024 at 04:37:41PM +0100, David Marchand wrote:
> 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 <david.marchand@redhat.com>
> ---
Reviewed-by: Tyler Retzlaff <roretzla@linux.microsoft.com>
Acked-by: Chengwen Feng <fengchengwen@huawei.com>
On 2024/2/13 23:37, David Marchand wrote:
> 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<david.marchand@redhat.com>
> ---
> 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))
On Tue, Feb 13, 2024 at 4:38 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> 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 <david.marchand@redhat.com>
Applied, thanks.
@@ -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)
@@ -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)
@@ -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))