From 489cc84f0888c4b1b66883326b889ab37a7f0432 Mon Sep 17 00:00:00 2001 From: Sekilsgs2 Date: Thu, 3 Mar 2016 17:05:23 +0300 Subject: [PATCH] Update lpc178x_eth.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Old code make errors sometimes and phy state go to HALTED (usualy after downloading 30mb and more) //Старый код выдавал ошибки иногда и phy state уходит в HALTED (точнее всегда если скачать больше 30мб, бывает скачаешь и 100мб и начнут ошибки валиться) --- drivers/net/arm/lpc178x_eth.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/net/arm/lpc178x_eth.c b/drivers/net/arm/lpc178x_eth.c index b30ff49c1d4..e02f9fcb382 100644 --- a/drivers/net/arm/lpc178x_eth.c +++ b/drivers/net/arm/lpc178x_eth.c @@ -672,19 +672,18 @@ static void __lpc_net_shutdown(struct netdata_local *pldat) static int lpc_mdio_read(struct mii_bus *bus, int phy_id, int phyreg) { struct netdata_local *pldat = bus->priv; - unsigned long timeout = jiffies + ((HZ * 100) / 1000); /* 100mS */ - int lps; + int lps,i; + i = 0; writel(((phy_id << 8) | phyreg), LPC_ENET_MADR(pldat->net_base)); writel(LPC_MCMD_READ, LPC_ENET_MCMD(pldat->net_base)); /* Wait for unbusy status */ while (readl(LPC_ENET_MIND(pldat->net_base)) & LPC_MIND_BUSY) { - if (jiffies > timeout) + if (i > 0x5000) return -EIO; - cpu_relax(); + i++; } - lps = (int) readl(LPC_ENET_MRDD(pldat->net_base)); writel(0, LPC_ENET_MCMD(pldat->net_base)); @@ -695,16 +694,16 @@ static int lpc_mdio_write(struct mii_bus *bus, int phy_id, int phyreg, u16 phydata) { struct netdata_local *pldat = bus->priv; - unsigned long timeout = jiffies + ((HZ * 100) / 1000); /* 100mS */ + int i = 0; writel(((phy_id << 8) | phyreg), LPC_ENET_MADR(pldat->net_base)); writel(phydata, LPC_ENET_MWTD(pldat->net_base)); /* Wait for completion */ while (readl(LPC_ENET_MIND(pldat->net_base)) & LPC_MIND_BUSY) { - if (jiffies > timeout) + if (i > 0x5000) return -EIO; - cpu_relax(); + i++; } return 0;