From 8dfe55a29d7296655b1ac622181ce196ab9fcdc5 Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Wed, 16 Jan 2019 22:13:35 +0800 Subject: [PATCH] net/ice/base: add some helper macros Signed-off-by: Qi Zhang Signed-off-by: Paul M Stillwell Jr Acked-by: Wenzhuo Lu --- drivers/net/ice/base/ice_common.h | 10 ++++++++++ drivers/net/ice/base/ice_osdep.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/drivers/net/ice/base/ice_common.h b/drivers/net/ice/base/ice_common.h index 45d93eb64b..67539ccb74 100644 --- a/drivers/net/ice/base/ice_common.h +++ b/drivers/net/ice/base/ice_common.h @@ -51,6 +51,16 @@ void ice_clear_pxe_mode(struct ice_hw *hw); enum ice_status ice_get_caps(struct ice_hw *hw); +/* Define a macro that will align a pointer to point to the next memory address + * that falls on the given power of 2 (i.e., 2, 4, 8, 16, 32, 64...). For + * example, given the variable pointer = 0x1006, then after the following call: + * + * pointer = ICE_ALIGN(pointer, 4) + * + * ... the value of pointer would equal 0x1008, since 0x1008 is the next + * address after 0x1006 which is divisible by 4. + */ +#define ICE_ALIGN(ptr, align) (((ptr) + ((align) - 1)) & ~((align) - 1)) enum ice_status diff --git a/drivers/net/ice/base/ice_osdep.h b/drivers/net/ice/base/ice_osdep.h index a3351c034f..252c8f4e78 100644 --- a/drivers/net/ice/base/ice_osdep.h +++ b/drivers/net/ice/base/ice_osdep.h @@ -457,6 +457,8 @@ LIST_HEAD(ice_list_head, ice_list_entry); /*Note parameters are swapped*/ #define LIST_FIRST_ENTRY(head, type, field) (type *)((head)->lh_first) +#define LIST_NEXT_ENTRY(entry, type, field) \ + ((type *)(entry)->field.next.le_next) #define LIST_ADD(entry, list_head) LIST_INSERT_HEAD(list_head, entry, next) #define LIST_ADD_AFTER(entry, list_entry) \ LIST_INSERT_AFTER(list_entry, entry, next) -- 2.20.1