On Tue, 29 Apr 2025 11:07:04 +0200 Paolo Abeni <pabeni@xxxxxxxxxx> wrote: > On 4/22/25 4:56 PM, Kory Maincent wrote: > > +/* Convert interrupt events to 0xff to be aligned with the chan > > + * number. > > + */ > > +static u8 tps23881_irq_export_chans_helper(u16 reg_val, u8 field_offset) > > +{ > > + u8 val; > > + > > + val = (reg_val >> (4 + field_offset) & 0xf0) | > > + (reg_val >> field_offset & 0x0f); > > I'm probably low on coffee but I don't see why the above could not be > replaced with: > > return reg_val >> field_offset; > > (given that the return type is u8) Shift takes precedence to bit operation. So the calculation is like: val = ((reg_val >> (4 + field_offset)) & 0xf0) | ((reg_val >> field_offset) & 0x0f) Supposing reg_val = 0xabcd; - If field_offset = 0, we return 0xbd; - If field_offset = 4, we return 0xac Regards -- Köry Maincent, Bootlin Embedded Linux and kernel engineering https://bootlin.com