netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Trimarchi <michael@amarulasolutions.com>
To: Michael Trimarchi <michael@amarulasolutions.com>,
	Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: netdev@vger.kernel.org
Subject: [RFC][PATCH] net: stmmac: use msleep instead of udelay for gpio reset
Date: Sat, 18 Apr 2015 17:02:39 +0200	[thread overview]
Message-ID: <1429369359-8204-1-git-send-email-michael@amarulasolutions.com> (raw)

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

             reply	other threads:[~2015-04-18 15:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-18 15:02 Michael Trimarchi [this message]
2015-04-18 17:37 ` [RFC][PATCH] net: stmmac: use msleep instead of udelay for gpio reset Fabio Estevam
     [not found]   ` <CAOf5uw=0dw-4kHTCgiN143f33YxpZLsqsHyTcDfxnKCW5aDpzw@mail.gmail.com>
2015-04-20 13:11     ` Giuseppe CAVALLARO

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1429369359-8204-1-git-send-email-michael@amarulasolutions.com \
    --to=michael@amarulasolutions.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).