On Tue, Jan 17, 2023 at 05:58:54PM +0200, Andy Shevchenko wrote: > On Tue, Jan 17, 2023 at 04:24:35PM +0100, Mårten Lindahl wrote: ... > > + val = ret; > > + > > + if (dir == IIO_EV_DIR_RISING) > > + val = state ? (val | VCNL4040_PS_IF_AWAY) : > > + (val & ~VCNL4040_PS_IF_AWAY); > > + else > > + val = state ? (val | VCNL4040_PS_IF_CLOSE) : > > + (val & ~VCNL4040_PS_IF_CLOSE); > > > Wouldn't be better > > uXX val, mask; > > > if (dir == IIO_EV_DIR_RISING) > mask = VCNL4040_PS_IF_AWAY; > else > mask = VCNL4040_PS_IF_CLOSE; > > val = state ? (val | mask) : (val & ~mask); Of course I meant val = state ? (ret | mask) : (ret & ~mask); > ? -- With Best Regards, Andy Shevchenko