From: Wolfram Sang <w.sang@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/3] net: miidev: Refactor timeout for aneg
Date: Wed, 21 Mar 2012 12:18:44 +0100 [thread overview]
Message-ID: <1332328725-29753-3-git-send-email-w.sang@pengutronix.de> (raw)
In-Reply-To: <1332328725-29753-1-git-send-email-w.sang@pengutronix.de>
First check the status at least once, then do timeout checks. Minor
cleanups also.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
---
drivers/net/miidev.c | 17 ++++++-----------
1 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/net/miidev.c b/drivers/net/miidev.c
index 83b6fe9..16a3461 100644
--- a/drivers/net/miidev.c
+++ b/drivers/net/miidev.c
@@ -91,27 +91,22 @@ int miidev_restart_aneg(struct mii_device *mdev)
int miidev_wait_aneg(struct mii_device *mdev)
{
- uint64_t start;
int status;
+ uint64_t start = get_time_ns();
if (mdev->flags & MIIDEV_FORCE_LINK)
return 0;
- /*
- * Wait for AN completion
- */
- start = get_time_ns();
do {
+ status = mii_read(mdev, mdev->address, MII_BMSR);
+ if (status < 0)
+ return status;
+
if (is_timeout(start, 5 * SECOND)) {
printf("%s: Autonegotiation timeout\n", mdev->cdev.name);
- return -1;
+ return -ETIMEDOUT;
}
- status = mii_read(mdev, mdev->address, MII_BMSR);
- if (status < 0) {
- printf("%s: Autonegotiation failed. status: 0x%04x\n", mdev->cdev.name, status);
- return -1;
- }
} while (!(status & BMSR_LSTATUS));
return 0;
--
1.7.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-03-21 11:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-21 11:18 [PATCH 0/3] miidev: improve phy initialization Wolfram Sang
2012-03-21 11:18 ` [PATCH 1/3] net: miidev: check for errors when accessing bus in restart_aneg Wolfram Sang
2012-03-21 11:18 ` Wolfram Sang [this message]
2012-03-21 11:18 ` [PATCH 3/3] net: miidev: properly check for MII reset Wolfram Sang
2012-03-23 7:23 ` [PATCH 0/3] miidev: improve phy initialization Sascha Hauer
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=1332328725-29753-3-git-send-email-w.sang@pengutronix.de \
--to=w.sang@pengutronix.de \
--cc=barebox@lists.infradead.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