[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 3 Mar 2020 18:03:16 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Russell King <rmk+kernel@...linux.org.uk>
Cc: Florian Fainelli <f.fainelli@...il.com>,
Heiner Kallweit <hkallweit1@...il.com>,
Antoine Tenart <antoine.tenart@...tlin.com>,
"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org
Subject: Re: [PATCH net-next v2 1/3] net: phy: marvell10g: add mdix control
> +static int mv3310_reset(struct phy_device *phydev, u32 unit)
> +{
> + int retries, val, err;
> +
> + err = phy_modify_mmd(phydev, MDIO_MMD_PCS, unit + MDIO_CTRL1,
> + MDIO_CTRL1_RESET, MDIO_CTRL1_RESET);
> + if (err < 0)
> + return err;
> +
> + retries = 20;
> + do {
> + msleep(5);
> + val = phy_read_mmd(phydev, MDIO_MMD_PCS, unit + MDIO_CTRL1);
> + if (val < 0)
> + return val;
> + } while (val & MDIO_CTRL1_RESET && --retries);
> +
> + return val & MDIO_CTRL1_RESET ? -ETIMEDOUT : 0;
Hi Russell
I've often seen people get this sort of polling loop wrong. So i
generally point people towards include/linux/iopoll.h.
I wonder if it would be helpful to add phy_read_mmd_poll_timeout()
and maybe phy_read_poll_timeout() to phy-core.c?
Just an idea, not a blocker for the patch.
Andrew
Powered by blists - more mailing lists