Re: [PATCH net-next v4 9/9] net: phy: micrel: ksz886x/ksz8081: add cabletest support

From: Oleksij Rempel
Date: Sun Jun 13 2021 - 23:52:45 EST


On Sat, Jun 12, 2021 at 08:23:53PM +0200, Andrew Lunn wrote:
> > +static int ksz886x_cable_test_get_status(struct phy_device *phydev,
> > + bool *finished)
> > +{
> > + unsigned long pair_mask = 0x3;
> > + int retries = 20;
> > + int pair, ret;
> > +
> > + *finished = false;
> > +
> > + /* Try harder if link partner is active */
> > + while (pair_mask && retries--) {
> > + for_each_set_bit(pair, &pair_mask, 4) {
> > + ret = ksz886x_cable_test_one_pair(phydev, pair);
> > + if (ret == -EAGAIN)
> > + continue;
> > + if (ret < 0)
> > + return ret;
> > + clear_bit(pair, &pair_mask);
> > + }
> > + /* If link partner is in autonegotiation mode it will send 2ms
> > + * of FLPs with at least 6ms of silence.
> > + * Add 2ms sleep to have better chances to hit this silence.
> > + */
> > + if (pair_mask)
> > + msleep(2);
> > + }
> > +
> > + *finished = true;
> > +
> > + return 0;
>
> If ksz886x_cable_test_one_pair() returns -EAGAIN 20x and it gives up,
> you end up returning 0. Maybe it would be better to return ret?

Good point. Fixed.

Regards,
Oleksij
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |