netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] net: stmmac: use msleep instead of udelay for gpio reset
@ 2015-04-21 11:16 Michael Trimarchi
  2015-04-21 21:35 ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Trimarchi @ 2015-04-21 11:16 UTC (permalink / raw)
  To: Giuseppe Cavallaro; +Cc: Michael Trimarchi, Fabio Estevam, netdev

Reset delay values are expressed in microsecond but most of the
time the delay is more then 2ms and up to 100ms. Use udelay
is wrong for large sleep period. This function is not used
in interrupt context according to the documentation.

Cc: Fabio Estevam <festevam@gmail.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>

---
Changes v1 -> v2:
  - remove unreleated changes
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index b735fa2..c843fbe 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -161,11 +161,11 @@ int stmmac_mdio_reset(struct mii_bus *bus)
 
 		if (!gpio_request(reset_gpio, "mdio-reset")) {
 			gpio_direction_output(reset_gpio, active_low ? 1 : 0);
-			udelay(data->delays[0]);
-			gpio_set_value(reset_gpio, active_low ? 0 : 1);
-			udelay(data->delays[1]);
-			gpio_set_value(reset_gpio, active_low ? 1 : 0);
-			udelay(data->delays[2]);
+			msleep(max(1U, data->delays[0] / 1000));
+			gpio_set_value(reset_gpio, !active_low);
+			msleep(max(1U, data->delays[1] / 1000));
+			gpio_set_value(reset_gpio, active_low);
+			msleep(max(1U, data->delays[2] / 1000));
 		}
 	}
 #endif
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-04-22  0:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-21 11:16 [PATCH V2] net: stmmac: use msleep instead of udelay for gpio reset Michael Trimarchi
2015-04-21 21:35 ` David Miller
2015-04-21 23:13   ` Michael Trimarchi
2015-04-22  0:31     ` David Miller
2015-04-22  0:55       ` Michael Trimarchi

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).