For LSB bits, I dont think this is an issue. I expect it to work, for example:
#define CONTROL_LSB_MASK GENMASK(2, 0)
foo |= u32_encode_bits(control, CONTROL_LSB_MASK);
would mask the control value and program that in specific bitfeild.
But for MSB bits, I am not sure above will work so, you may need to extract
the bits and then use, for example:
#define CONTROL_MSB_BITS GENMASK(5, 3)
#define CONTROL_MSB_MASK GENMASK(17, 15)
control = FIELD_GET(CONTROL_MSB_BITS, control);
foo |= u32_encode_bits(control, CONTROL_MSB_MASK);
If you have a better suggestion that the FIELD_PREP/FIELD_GET use, I am all
ears. At the end of the day, the mapping is pre-defined and we don't have
any degree of freedom. What I do want is that this macro/inline function is
shared by all codec drivers so that we don't have different interpretations
of how the address is constructed.
Absolutely, this need to be defined here and used by everyone else.