[PATCH 1/2] net: fec_imx: ensure constant timeout in fec_halt
Hubert Feurstein
h.feurstein at gmail.com
Thu Feb 21 04:21:13 EST 2013
Signed-off-by: Hubert Feurstein <h.feurstein at gmail.com>
---
drivers/net/fec_imx.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/net/fec_imx.c b/drivers/net/fec_imx.c
index 2378a19..6dfb093 100644
--- a/drivers/net/fec_imx.c
+++ b/drivers/net/fec_imx.c
@@ -425,15 +425,20 @@ static int fec_open(struct eth_device *edev)
static void fec_halt(struct eth_device *dev)
{
struct fec_priv *fec = (struct fec_priv *)dev->priv;
- int counter = 0xffff;
+ uint64_t tmo;
/* issue graceful stop command to the FEC transmitter if necessary */
writel(readl(fec->regs + FEC_X_CNTRL) | FEC_ECNTRL_RESET,
fec->regs + FEC_X_CNTRL);
/* wait for graceful stop to register */
- while ((counter--) && (!(readl(fec->regs + FEC_IEVENT) & FEC_IEVENT_GRA)))
- ; /* FIXME ensure time */
+ tmo = get_time_ns();
+ while (!(readl(fec->regs + FEC_IEVENT) & FEC_IEVENT_GRA)) {
+ if (is_timeout(tmo, 1 * SECOND)) {
+ printf("graceful stop timeout\n");
+ break;
+ }
+ }
/* Disable SmartDMA tasks */
fec_tx_task_disable(fec);
--
1.8.1.3
More information about the barebox
mailing list