From: Jose Abreu <jose.ab...@synopsys.com> Date: Fri, 9 Aug 2019 20:36:09 +0200
> + void __iomem *ioaddr = hw->pcsr; > + int count = 0; > + u32 value; > + > + do { > + if (readl_poll_timeout_atomic(ioaddr + XGMAC_TIMESTAMP_STATUS, > + value, value & XGMAC_TXTSC, > + 100, 10000)) > + break; > + > + *ts = readl(ioaddr + XGMAC_TXTIMESTAMP_NSEC) & XGMAC_TXTSSTSLO; > + *ts += readl(ioaddr + XGMAC_TXTIMESTAMP_SEC) * 1000000000ULL; > + } while (count++); > + > + if (count) > + return 0; > + return -EBUSY; This is a very strange construct, the loop never executes more than once. Simplified it is essentially: if (readl_poll_timeout_atomic(ioaddr + XGMAC_TIMESTAMP_STATUS, value, value & XGMAC_TXTSC, 100, 10000)) return -EBUSY; *ts = readl(ioaddr + XGMAC_TXTIMESTAMP_NSEC) & XGMAC_TXTSSTSLO; *ts += readl(ioaddr + XGMAC_TXTIMESTAMP_SEC) * 1000000000ULL; return 0; Don't make the code more complicated than it needs to be, there is no reason to use a loop here. And using a loop makes it look like the loop is the polling/timeout construct, when it isn't, because readl_poll_timeout_atomic() is serving that purpose.