Skip to content

Commit

Permalink
net: phy: mdio-mux-bcm-iproc: use readl_poll_timeout() to simplify code
Browse files Browse the repository at this point in the history
use readl_poll_timeout() to replace the poll codes for simplify
iproc_mdio_wait_for_idle() function

Signed-off-by: Dejin Zheng <zhengdejin5@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Dejin Zheng authored and David S. Miller committed Mar 24, 2020
1 parent 5ef8c66 commit c9c1fd6
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions drivers/net/phy/mdio-mux-bcm-iproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/phy.h>
#include <linux/mdio-mux.h>
#include <linux/delay.h>
#include <linux/iopoll.h>

#define MDIO_RATE_ADJ_EXT_OFFSET 0x000
#define MDIO_RATE_ADJ_INT_OFFSET 0x004
Expand Down Expand Up @@ -78,18 +79,11 @@ static void mdio_mux_iproc_config(struct iproc_mdiomux_desc *md)

static int iproc_mdio_wait_for_idle(void __iomem *base, bool result)
{
unsigned int timeout = 1000; /* loop for 1s */
u32 val;

do {
val = readl(base + MDIO_STAT_OFFSET);
if ((val & MDIO_STAT_DONE) == result)
return 0;

usleep_range(1000, 2000);
} while (timeout--);

return -ETIMEDOUT;
return readl_poll_timeout(base + MDIO_STAT_OFFSET, val,
(val & MDIO_STAT_DONE) == result,
2000, 1000000);
}

/* start_miim_ops- Program and start MDIO transaction over mdio bus.
Expand Down

0 comments on commit c9c1fd6

Please sign in to comment.