Thread (17 messages) flat view 17 messages, 4 authors, 2020-10-06

RE: [PATCH v3 1/3] i2c: imx: Fix reset of I2SR_IAL flag

From: David Laight <hidden>
Date: 2020-10-06 12:52:19
Also in: linux-i2c, lkml, stable

From: Uwe Kleine-König
Sent: 06 October 2020 13:46
...
quoted
quoted
+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)


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help