Skip to content
Commit a256ae22 authored by Luo Jie's avatar Luo Jie Committed by Yury Norov
Browse files

bitfield: Add FIELD_MODIFY() helper



Add a helper for replacing the contents of bitfield in memory
with the specified value.

Even though a helper xxx_replace_bits() is available, it is not
well documented, and only reports errors at the run time, which
will not be helpful to catch possible overflow errors due to
incorrect parameter types used.

FIELD_MODIFY(REG_FIELD_C, &reg, c) is the wrapper to the code below.

	reg &= ~REG_FIELD_C;
	reg |= FIELD_PREP(REG_FIELD_C, c);

Yury: trim commit message, align backslashes.

Signed-off-by: default avatarLuo Jie <quic_luoj@quicinc.com>
Signed-off-by: default avatarYury Norov <yury.norov@gmail.com>
parent 89a44a80
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment