net: arc_emac: remove delay from mdio polling loop
Avoid unneeded delay when waiting for the completion of a mdio operation and return as soon as possible. Signed-off-by: Beniamino Galvani <b.galvani@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
b4ce62d3d2
commit
b158af4f08
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <asm/mmu.h>
|
#include <asm/mmu.h>
|
||||||
|
#include <clock.h>
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <net.h>
|
#include <net.h>
|
||||||
#include <io.h>
|
#include <io.h>
|
||||||
|
@ -342,26 +343,18 @@ static int arc_emac_set_ethaddr(struct eth_device *edev, unsigned char *mac)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Number of seconds we wait for "MDIO complete" flag to appear */
|
|
||||||
#define ARC_MDIO_COMPLETE_POLL_COUNT 1
|
|
||||||
|
|
||||||
static int arc_mdio_complete_wait(struct arc_emac_priv *priv)
|
static int arc_mdio_complete_wait(struct arc_emac_priv *priv)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
uint64_t start = get_time_ns();
|
||||||
|
|
||||||
for (i = 0; i < ARC_MDIO_COMPLETE_POLL_COUNT * 40; i++) {
|
while (!is_timeout(start, 1000 * MSECOND)) {
|
||||||
unsigned int status = arc_reg_get(priv, R_STATUS);
|
if (arc_reg_get(priv, R_STATUS) & MDIO_MASK) {
|
||||||
|
|
||||||
status &= MDIO_MASK;
|
|
||||||
|
|
||||||
if (status) {
|
|
||||||
/* Reset "MDIO complete" flag */
|
/* Reset "MDIO complete" flag */
|
||||||
arc_reg_set(priv, R_STATUS, status);
|
arc_reg_set(priv, R_STATUS, MDIO_MASK);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
mdelay(25);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return -ETIMEDOUT;
|
return -ETIMEDOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue