diff options
author | Lennart Sorensen <lsorense@csclub.uwaterloo.ca> | 2014-10-31 13:28:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-31 16:16:42 -0400 |
commit | 35532c211b1feda52078685bef0bf9b5f3b0991c (patch) | |
tree | d35fd25f0fdce665a75d7b6134172b0d097ae3dd | |
parent | 0089b745df2e1b0bee0b1bb1a7f62a7cec961066 (diff) |
drivers: net: cpsw: Fix broken loop condition in switch mode
0d961b3b52f566f823070ce2366511a7f64b928c (drivers: net: cpsw: fix buggy
loop condition) accidentally fixed a loop comparison in too many places
while fixing a real bug.
It was correct to fix the dual_emac mode section since there 'i' is used
as an index into priv->slaves which is a 0 based array.
However the other two changes (which are only used in switch mode)
are wrong since there 'i' is actually the ALE port number, and port 0
is the host port, while port 1 and up are the slave ports.
Putting the loop condition back in the switch mode section fixes it.
A comment has been added to point out the intent clearly to avoid future
confusion. Also a comment is fixed that said the opposite of what was
actually happening.
Signed-off-by: Len Sorensen <lsorense@csclub.uwaterloo.ca>
Acked-by: Heiko Schocher <hs@denx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/ti/cpsw.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 952e1e4764b7..4683196c6592 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c | |||
@@ -591,8 +591,8 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable) | |||
591 | if (enable) { | 591 | if (enable) { |
592 | unsigned long timeout = jiffies + HZ; | 592 | unsigned long timeout = jiffies + HZ; |
593 | 593 | ||
594 | /* Disable Learn for all ports */ | 594 | /* Disable Learn for all ports (host is port 0 and slaves are port 1 and up */ |
595 | for (i = 0; i < priv->data.slaves; i++) { | 595 | for (i = 0; i <= priv->data.slaves; i++) { |
596 | cpsw_ale_control_set(ale, i, | 596 | cpsw_ale_control_set(ale, i, |
597 | ALE_PORT_NOLEARN, 1); | 597 | ALE_PORT_NOLEARN, 1); |
598 | cpsw_ale_control_set(ale, i, | 598 | cpsw_ale_control_set(ale, i, |
@@ -616,11 +616,11 @@ static void cpsw_set_promiscious(struct net_device *ndev, bool enable) | |||
616 | cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 1); | 616 | cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 1); |
617 | dev_dbg(&ndev->dev, "promiscuity enabled\n"); | 617 | dev_dbg(&ndev->dev, "promiscuity enabled\n"); |
618 | } else { | 618 | } else { |
619 | /* Flood All Unicast Packets to Host port */ | 619 | /* Don't Flood All Unicast Packets to Host port */ |
620 | cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 0); | 620 | cpsw_ale_control_set(ale, 0, ALE_P0_UNI_FLOOD, 0); |
621 | 621 | ||
622 | /* Enable Learn for all ports */ | 622 | /* Enable Learn for all ports (host is port 0 and slaves are port 1 and up */ |
623 | for (i = 0; i < priv->data.slaves; i++) { | 623 | for (i = 0; i <= priv->data.slaves; i++) { |
624 | cpsw_ale_control_set(ale, i, | 624 | cpsw_ale_control_set(ale, i, |
625 | ALE_PORT_NOLEARN, 0); | 625 | ALE_PORT_NOLEARN, 0); |
626 | cpsw_ale_control_set(ale, i, | 626 | cpsw_ale_control_set(ale, i, |