On Wed, 5 Feb 2025 15:58:18 +0200 Matti Vaittinen <mazziesaccount@xxxxxxxxx> wrote: > On 31/01/2025 19:41, Jonathan Cameron wrote: > > On Fri, 31 Jan 2025 15:37:48 +0200 > > Matti Vaittinen <mazziesaccount@xxxxxxxxx> wrote: > > > >> The ROHM BD79124 is a 12-bit, 8-channel, SAR ADC. The ADC supports > >> an automatic measurement mode, with an alarm interrupt for out-of-window > >> measurements. The window is configurable for each channel. > >> > > Hi Jonathan, > > I just sent the v2, where I (think I) addressed all comments except ones > below. Just wanted to point out what was not changed and why :) > > ... > > > > >> +struct bd79124_raw { > >> + u8 bit0_3; /* Is set in high bits of the byte */ > >> + u8 bit4_11; > >> +}; > >> +#define BD79124_RAW_TO_INT(r) ((r.bit4_11 << 4) | (r.bit0_3 >> 4)) > > You could do this as an endian conversion and a single shift I think. > > Might be slightly simpler. > > I kept this struct with bytes matching the register spec. Doing the > endian conversion and then shifting would probably have worked, but my > head hurts when I try thinking how the bits settle there. Especially if > this is done on a big-endian machine. I can rework this for v3 if you > feel very strongly about this. The key is that an endian conversion is always the same as OR + SHIFT because that is being done in the system endiannes. Doesn't matter that much, but we may see follow up patches switching this over to the endian handlers.