netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] net: stmmac: use msleep instead of udelay for gpio reset
@ 2015-04-18 15:02 Michael Trimarchi
  2015-04-18 17:37 ` Fabio Estevam
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Trimarchi @ 2015-04-18 15:02 UTC (permalink / raw)
  To: Michael Trimarchi, Giuseppe Cavallaro; +Cc: 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.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
index b735fa2..009a86a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
@@ -157,15 +157,15 @@ int stmmac_mdio_reset(struct mii_bus *bus)
 		}
 
 		reset_gpio = data->reset_gpio;
-		active_low = data->active_low;
+		active_low = !!data->active_low;
 
 		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]);
+			gpio_direction_output(reset_gpio, active_low);
+			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] 3+ messages in thread

end of thread, other threads:[~2015-04-20 13:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-18 15:02 [RFC][PATCH] net: stmmac: use msleep instead of udelay for gpio reset Michael Trimarchi
2015-04-18 17:37 ` Fabio Estevam
     [not found]   ` <CAOf5uw=0dw-4kHTCgiN143f33YxpZLsqsHyTcDfxnKCW5aDpzw@mail.gmail.com>
2015-04-20 13:11     ` Giuseppe CAVALLARO

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