* [PATCH] ATM: misplaced parentheses?
@ 2009-02-15 16:07 Roel Kluin
2009-02-16 22:02 ` Chas Williams (CONTRACTOR)
0 siblings, 1 reply; 5+ messages in thread
From: Roel Kluin @ 2009-02-15 16:07 UTC (permalink / raw)
To: chas; +Cc: netdev, Andrew Morton
I think below is what was intended? otherwise we could as well have written:
tmp = (lanai->conf1 & ~CONFIG1_PROMDATA) ||
(data & i) ? CONFIG1_PROMDATA : 0;
Does this fix the parsing of the EEPROM?
please review.
-------------------------->8------------------8<---------------------------
Fix misplaced parentheses
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index 144a49f..317fb5a 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -901,7 +901,7 @@ static int __devinit eeprom_read(struct lanai_dev *lanai)
clock_l(); udelay(5);
for (i = 128; i != 0; i >>= 1) { /* write command out */
tmp = (lanai->conf1 & ~CONFIG1_PROMDATA) |
- (data & i) ? CONFIG1_PROMDATA : 0;
+ (data & i ? CONFIG1_PROMDATA : 0);
if (lanai->conf1 != tmp) {
set_config1(tmp);
udelay(5); /* Let new data settle */
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ATM: misplaced parentheses?
2009-02-15 16:07 [PATCH] ATM: misplaced parentheses? Roel Kluin
@ 2009-02-16 22:02 ` Chas Williams (CONTRACTOR)
2009-02-16 22:30 ` Al Viro
0 siblings, 1 reply; 5+ messages in thread
From: Chas Williams (CONTRACTOR) @ 2009-02-16 22:02 UTC (permalink / raw)
To: Roel Kluin; +Cc: netdev, Andrew Morton
that doesnt seem to make sense either. the original code
is:
for (i = 128; i != 0; i >>= 1) { /* write command out */
...
tmp = (lanai->conf1 & ~CONFIG1_PROMDATA) |
(data & i) ? CONFIG1_PROMDATA : 0;
since i is always positive here, you wouldnt need the ?: if your suggested
fix is the original intent. it looks like setting CONFIG1_PROMDATA
means '1' and not setting it means '0' when writing the value of data
to the register.
In message <49983DB0.6040008@gmail.com>,Roel Kluin writes:
>I think below is what was intended? otherwise we could as well have written:
>
>tmp = (lanai->conf1 & ~CONFIG1_PROMDATA) ||
> (data & i) ? CONFIG1_PROMDATA : 0;
>
>Does this fix the parsing of the EEPROM?
>
>please review.
>-------------------------->8------------------8<---------------------------
>Fix misplaced parentheses
>
>Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
>---
>diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
>index 144a49f..317fb5a 100644
>--- a/drivers/atm/lanai.c
>+++ b/drivers/atm/lanai.c
>@@ -901,7 +901,7 @@ static int __devinit eeprom_read(struct lanai_dev *lanai)
> clock_l(); udelay(5);
> for (i = 128; i != 0; i >>= 1) { /* write command out */
> tmp = (lanai->conf1 & ~CONFIG1_PROMDATA) |
>- (data & i) ? CONFIG1_PROMDATA : 0;
>+ (data & i ? CONFIG1_PROMDATA : 0);
> if (lanai->conf1 != tmp) {
> set_config1(tmp);
> udelay(5); /* Let new data settle */
>--
>To unsubscribe from this list: send the line "unsubscribe netdev" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ATM: misplaced parentheses?
2009-02-16 22:02 ` Chas Williams (CONTRACTOR)
@ 2009-02-16 22:30 ` Al Viro
2009-02-17 9:59 ` Roel Kluin
0 siblings, 1 reply; 5+ messages in thread
From: Al Viro @ 2009-02-16 22:30 UTC (permalink / raw)
To: chas3; +Cc: Roel Kluin, netdev, Andrew Morton
On Mon, Feb 16, 2009 at 05:02:36PM -0500, Chas Williams (CONTRACTOR) wrote:
> that doesnt seem to make sense either. the original code
> is:
>
> for (i = 128; i != 0; i >>= 1) { /* write command out */
> ...
> tmp = (lanai->conf1 & ~CONFIG1_PROMDATA) |
> (data & i) ? CONFIG1_PROMDATA : 0;
>
> since i is always positive here, you wouldnt need the ?: if your suggested
> fix is the original intent. it looks like setting CONFIG1_PROMDATA
> means '1' and not setting it means '0' when writing the value of data
> to the register.
What the hell does it have to do with i being positive? || variant is,
of course, silly; it's very obvious what's going on here. Garden-variety
bit-banging, IOW
tmp = (lanai->conf1 & ~CONFIG1_PROMDATA) |
((data & i) ? CONFIG1_PROMDATA : 0);
and while you technically only need parens around ?:, in this case it's
better to keep it fully parenthesised - more readable that way.
The lack of parens around ?: in the current tree is an obvious bug.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ATM: misplaced parentheses?
2009-02-16 22:30 ` Al Viro
@ 2009-02-17 9:59 ` Roel Kluin
2009-02-19 1:41 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Roel Kluin @ 2009-02-17 9:59 UTC (permalink / raw)
To: Al Viro; +Cc: chas3, netdev, Andrew Morton
Al Viro wrote:
> while you technically only need parens around ?:, in this case it's
> better to keep it fully parenthesised - more readable that way.
>
> The lack of parens around ?: in the current tree is an obvious bug.
Ok, with extra for clarity:
-------------------------->8------------------8<---------------------------
Add missing parentheses
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index 144a49f..8733a2e 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -901,7 +901,7 @@ static int __devinit eeprom_read(struct lanai_dev *lanai)
clock_l(); udelay(5);
for (i = 128; i != 0; i >>= 1) { /* write command out */
tmp = (lanai->conf1 & ~CONFIG1_PROMDATA) |
- (data & i) ? CONFIG1_PROMDATA : 0;
+ ((data & i) ? CONFIG1_PROMDATA : 0);
if (lanai->conf1 != tmp) {
set_config1(tmp);
udelay(5); /* Let new data settle */
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ATM: misplaced parentheses?
2009-02-17 9:59 ` Roel Kluin
@ 2009-02-19 1:41 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2009-02-19 1:41 UTC (permalink / raw)
To: roel.kluin; +Cc: viro, chas3, netdev, akpm
From: Roel Kluin <roel.kluin@gmail.com>
Date: Tue, 17 Feb 2009 10:59:36 +0100
> Add missing parentheses
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-02-19 1:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-15 16:07 [PATCH] ATM: misplaced parentheses? Roel Kluin
2009-02-16 22:02 ` Chas Williams (CONTRACTOR)
2009-02-16 22:30 ` Al Viro
2009-02-17 9:59 ` Roel Kluin
2009-02-19 1:41 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).