[PATCH v1 09/14] net/zxdh: implement tables initialization
Stephen Hemminger
stephen at networkplumber.org
Mon Feb 10 18:40:15 CET 2025
On Mon, 10 Feb 2025 09:50:12 +0800
Bingbin Chen <chen.bingbin at zte.com.cn> wrote:
> +static inline void
> +zxdh_np_comm_uint32_write_bits(uint32_t *_dst_, uint32_t _src_,
> + uint32_t _start_pos_, uint32_t _len_)
> +{
> + (*_dst_) =
> + ((*_dst_) & ~(ZXDH_COMM_GET_BIT_MASK(uint32_t, (_len_)) << (_start_pos_))) |
> + (((_src_) & ZXDH_COMM_GET_BIT_MASK(uint32_t, (_len_))) << (_start_pos_));
> +}
> +
Would be more readable if mask computed once.
Don't need _ on function args
static inline void
zxdh_np_comm_uint32_write_bits(uint32_t *dst, uint32_t src,
uint32_t start_pos, uint32_t len)
{
uint32_t mask = ZXDH_COMM_GET_BIT_MASK(uint32_t, len) << start_pos;
*dst = (*dst & mask) | (src & mask);
}
More information about the dev
mailing list