Thread (60 messages) 60 messages, 12 authors, 2012-11-14
STALE4961d

[PATCH 3/8] i2c: omap: fix error checking

From: Felipe Balbi <hidden>
Date: 2012-10-25 10:48:40
Also in: linux-i2c, linux-omap

Hi,

On Thu, Oct 25, 2012 at 12:33:18PM +0200, Michael Trimarchi wrote:
quoted
quoted
quoted
@@ -587,9 +587,9 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
 		goto err_i2c_init;
 	}
 
-	/* We have an error */
-	if (dev->cmd_err & (OMAP_I2C_STAT_AL | OMAP_I2C_STAT_ROVR |
-			    OMAP_I2C_STAT_XUDF)) {
+	if ((dev->cmd_err & OMAP_I2C_STAT_AL)
+			|| (dev->cmd_err & OMAP_I2C_STAT_ROVR)
+			|| (dev->cmd_err & OMAP_I2C_STAT_XUDF)) {
Sorry, what is the difference? I didn't understand the optimisation
and why now is more clear. Can you just add a comment?
semantically they're not the same, right ? We want to check if each of
those bits are set, not if all of them are set together.

my 2 cents.
You are doing the same thing, but of course is better with just one
I never claimed the contrary. I said *semantically* they're not the
same.
*if* as before . A general rule is: when you have logic expression you
We still have a single *if* and I'm sure compiler will optimize that
expression as much as it likes.
can use undefined states to simplify the logic. 
don't-care is not the same as undefined states.

-- 
balbi
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20121025/cbb6ab32/attachment.sig>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help