From: Uwe Kleine-König > Sent: 06 October 2020 13:46 ... > > > +static void i2c_imx_clear_irq(struct imx_i2c_struct *i2c_imx, unsigned int bits) > > > +{ > > > + unsigned int temp; > > > + > > > + /* > > > + * i2sr_clr_opcode is the value to clear all interrupts. > > > + * Here we want to clear only <bits>, so we write > > > + * ~i2sr_clr_opcode with just <bits> toggled. > > > + */ > > > + temp = ~i2c_imx->hwdata->i2sr_clr_opcode ^ bits; > > > + imx_i2c_write_reg(temp, i2c_imx, IMX_I2C_I2SR); > > > +} > > > > That looks either wrong or maybe just overcomplicated. > > Why isn't: > > imx_i2c_write_reg(bits, i2c_imx, IMX_I2C_I2SR); > > enough? > > Your question suggests you either didn't read the comment or the comment > is not good enough. Maybe once you understood the complication (see > Christian's mail) you could suggest a better wording? Maybe we have to > mention that this handles both W1C and W0C. Yes, the comment should just say that some devices are W1C and other W0C. It isn't obvious from that code fragment at all. Now for the 3rd variant which zeros the bits when they are read :-) David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)