* [PATCH] icplus: mdio_write(), remove unnecessary for loop
@ 2011-11-24 15:39 Patrick Kelle
2011-11-29 23:47 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Patrick Kelle @ 2011-11-24 15:39 UTC (permalink / raw)
To: netdev; +Cc: romieu, sorbica, Patrick Kelle
At this point the variable j is always set to 7 and the code within
the loop has to run only once anyway.
Signed-off-by: Patrick Kelle <patrick.kelle81@gmail.com>
---
drivers/net/ethernet/icplus/ipg.c | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/icplus/ipg.c b/drivers/net/ethernet/icplus/ipg.c
index 8fd80a0..a65d747 100644
--- a/drivers/net/ethernet/icplus/ipg.c
+++ b/drivers/net/ethernet/icplus/ipg.c
@@ -371,15 +371,13 @@ static void mdio_write(struct net_device *dev, int phy_id, int phy_reg, int val)
}
/* The last cycle is a tri-state, so read from the PHY. */
- for (j = 7; j < 8; j++) {
- for (i = 0; i < p[j].len; i++) {
- ipg_write_phy_ctl(ioaddr, IPG_PC_MGMTCLK_LO | polarity);
+ for (i = 0; i < p[j].len; i++) {
+ ipg_write_phy_ctl(ioaddr, IPG_PC_MGMTCLK_LO | polarity);
- p[j].field |= ((ipg_r8(PHY_CTRL) &
- IPG_PC_MGMTDATA) >> 1) << (p[j].len - 1 - i);
+ p[j].field |= ((ipg_r8(PHY_CTRL) &
+ IPG_PC_MGMTDATA) >> 1) << (p[j].len - 1 - i);
- ipg_write_phy_ctl(ioaddr, IPG_PC_MGMTCLK_HI | polarity);
- }
+ ipg_write_phy_ctl(ioaddr, IPG_PC_MGMTCLK_HI | polarity);
}
}
--
1.7.7.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] icplus: mdio_write(), remove unnecessary for loop
2011-11-24 15:39 [PATCH] icplus: mdio_write(), remove unnecessary for loop Patrick Kelle
@ 2011-11-29 23:47 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-11-29 23:47 UTC (permalink / raw)
To: patrick.kelle81; +Cc: netdev, romieu, sorbica
From: Patrick Kelle <patrick.kelle81@gmail.com>
Date: Thu, 24 Nov 2011 16:39:05 +0100
> At this point the variable j is always set to 7 and the code within
> the loop has to run only once anyway.
>
> Signed-off-by: Patrick Kelle <patrick.kelle81@gmail.com>
You can simply this even further since p[7] is what is used here,
and this means len is one, the inner loop therefore executes only
once, and the p[7].field value is not used (it's zero in the table)
and the write to it is completely thrown away.
It all reduces to something like:
ipg_write_phy_ctl(ioaddr, IPG_PC_MGMTCLK_LO | polarity);
ipg_r8(PHY_CTRL);
ipg_write_phy_ctl(ioaddr, IPG_PC_MGMTCLK_HI | polarity);
Which is just asserting the management clock low, then high, and
doing a PHY_CTRL read in between to force the write out, the read
data is not used at all.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-11-29 23:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-24 15:39 [PATCH] icplus: mdio_write(), remove unnecessary for loop Patrick Kelle
2011-11-29 23:47 ` 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).