IB/hfi1: Convert the macro AHG_HEADER_SET into an inline function
AHG_HEADER_SET macro doesn't conform to the coding standards as it can affect the control flow. Convert the macro AHG_HEADER_SET into an inline function ahg_header_set(). Cc: Leon Romanovsky <leon@kernel.org> Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com> Signed-off-by: Harish Chegondi <harish.chegondi@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:

committed by
Doug Ledford

parent
e870b4a1f5
commit
d34ed562ac
@@ -80,15 +80,26 @@
|
||||
#define PBC2LRH(x) ((((x) & 0xfff) << 2) - 4)
|
||||
#define LRH2PBC(x) ((((x) >> 2) + 1) & 0xfff)
|
||||
|
||||
#define AHG_HEADER_SET(arr, idx, dw, bit, width, value) \
|
||||
do { \
|
||||
if ((idx) < ARRAY_SIZE((arr))) \
|
||||
(arr)[(idx++)] = sdma_build_ahg_descriptor( \
|
||||
(__force u16)(value), (dw), (bit), \
|
||||
(width)); \
|
||||
else \
|
||||
return -ERANGE; \
|
||||
} while (0)
|
||||
/**
|
||||
* Build an SDMA AHG header update descriptor and save it to an array.
|
||||
* @arr - Array to save the descriptor to.
|
||||
* @idx - Index of the array at which the descriptor will be saved.
|
||||
* @array_size - Size of the array arr.
|
||||
* @dw - Update index into the header in DWs.
|
||||
* @bit - Start bit.
|
||||
* @width - Field width.
|
||||
* @value - 16 bits of immediate data to write into the field.
|
||||
* Returns -ERANGE if idx is invalid. If successful, returns the next index
|
||||
* (idx + 1) of the array to be used for the next descriptor.
|
||||
*/
|
||||
static inline int ahg_header_set(u32 *arr, int idx, size_t array_size,
|
||||
u8 dw, u8 bit, u8 width, u16 value)
|
||||
{
|
||||
if ((size_t)idx >= array_size)
|
||||
return -ERANGE;
|
||||
arr[idx++] = sdma_build_ahg_descriptor(value, dw, bit, width);
|
||||
return idx;
|
||||
}
|
||||
|
||||
/* Tx request flag bits */
|
||||
#define TXREQ_FLAGS_REQ_ACK BIT(0) /* Set the ACK bit in the header */
|
||||
|
Reference in New Issue
Block a user