Francois Romieu wrote:
quoted
quoted
+ /* Wait till the bus is free */
+ status = spin_event_timeout(
+ !((in_be32(®s->mdio_stat)) & MDIO_STAT_BSY), TIMEOUT, 0);
+ if (!status) {
+ dev_dbg(&bus->dev, "%s: timeout waiting for stat\n", __func__);
+ return -ETIMEDOUT;
+ }
This code - comment included - is repeated several times. You may
consider factoring it out in some xgmac_mdio_free_bus_wait function.
But it's just one line and a test. The function would look like this:
bool xgmac_mdio_free_bus_wait(struct tgec_mdio_controller __iomem *regs)
{
uint32_t status;
status = spin_event_timeout(
!((in_be32(®s->mdio_stat)) & MDIO_STAT_BSY), TIMEOUT, 0);
return status != 0;
}
and then
if (!xgmac_mdio_free_bus_wait(regs)) {
dev_dbg(&bus->dev, "%s: timeout waiting for stat\n", __func__);
return -ETIMEDOUT;
}
I don't see any real savings here.
--
Timur Tabi
Linux kernel developer at Freescale