From: Ondrej Zary <linux@rainbow-software.org>
To: Samuel Chessman <chessman@tux.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 08/11] tlan: Add PHY reset timeout
Date: Sat, 21 Jun 2014 16:47:53 +0200 [thread overview]
Message-ID: <1403362076-7777-9-git-send-email-linux@rainbow-software.org> (raw)
In-Reply-To: <1403362076-7777-1-git-send-email-linux@rainbow-software.org>
Add a timeout to prevent infinite loop waiting for PHY to reset.
Signed-off-by: Ondrej Zary <linux@rainbow-software.org>
---
drivers/net/ethernet/ti/tlan.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c
index b4e9dcf..f5af196 100644
--- a/drivers/net/ethernet/ti/tlan.c
+++ b/drivers/net/ethernet/ti/tlan.c
@@ -2569,6 +2569,7 @@ static void tlan_phy_reset(struct net_device *dev)
struct tlan_priv *priv = netdev_priv(dev);
u16 phy;
u16 value;
+ unsigned long timeout = jiffies + HZ;
phy = priv->phy[priv->phy_num];
@@ -2576,9 +2577,13 @@ static void tlan_phy_reset(struct net_device *dev)
tlan_mii_sync(dev->base_addr);
value = MII_GC_LOOPBK | MII_GC_RESET;
tlan_mii_write_reg(dev, phy, MII_GEN_CTL, value);
- tlan_mii_read_reg(dev, phy, MII_GEN_CTL, &value);
- while (value & MII_GC_RESET)
+ do {
tlan_mii_read_reg(dev, phy, MII_GEN_CTL, &value);
+ if (time_after(jiffies, timeout)) {
+ netdev_err(dev, "PHY reset timeout\n");
+ return;
+ }
+ } while (value & MII_GC_RESET);
/* Wait for 500 ms and initialize.
* I don't remember why I wait this long.
--
Ondrej Zary
next prev parent reply other threads:[~2014-06-21 14:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-21 14:47 [PATCH 0/11 v2] tlan: Link handling improvements and Olicom fixes Ondrej Zary
2014-06-21 14:47 ` [PATCH 01/11] tlan: Enable activity LED on Olicom OC-2325 and OC-2326 Ondrej Zary
2014-06-21 14:47 ` [PATCH 02/11] tlan: Enable link monitoring Ondrej Zary
2014-06-21 14:47 ` [PATCH 03/11] tlan: Add ethtool support Ondrej Zary
2014-06-21 14:47 ` [PATCH 04/11] tlan: Fix MAC address byte order on OC-2325/OC-2326 Ondrej Zary
2014-06-21 14:47 ` [PATCH 05/11] tlan: Restart autonegotiation on link loss Ondrej Zary
2014-06-21 17:06 ` Sergei Shtylyov
2014-06-21 14:47 ` [PATCH 06/11] tlan: Don't scream if no link Ondrej Zary
2014-06-21 14:47 ` [PATCH 07/11] tlan: Make autonegotiation faster Ondrej Zary
2014-06-21 14:47 ` Ondrej Zary [this message]
2014-06-21 14:47 ` [PATCH 09/11] tlan: Don't disable internal PHY on cards that use it in 10 Mbps mode Ondrej Zary
2014-06-21 14:47 ` [PATCH 10/11] tlan: Enable device at resume Ondrej Zary
2014-06-21 14:47 ` [PATCH 11/11] tlan: Isolate external PHY when using internal PHY Ondrej Zary
-- strict thread matches above, loose matches on Subject: below --
2014-06-30 16:38 [PATCH 0/11 v3] tlan: Link handling improvements and Olicom fixes Ondrej Zary
2014-06-30 16:38 ` [PATCH 08/11] tlan: Add PHY reset timeout Ondrej Zary
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=1403362076-7777-9-git-send-email-linux@rainbow-software.org \
--to=linux@rainbow-software.org \
--cc=chessman@tux.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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).