Re: [RFC net-next] net: phy: at803x: add cable diagnostics support

From: Michael Walle
Date: Tue May 05 2020 - 10:21:04 EST


Am 2020-05-05 15:07, schrieb Andrew Lunn:
+static int at803x_cable_test_get_status(struct phy_device *phydev,
+ bool *finished)
+{
+ struct at803x_priv *priv = phydev->priv;
+ static const int ethtool_pair[] = {
+ ETHTOOL_A_CABLE_PAIR_0, ETHTOOL_A_CABLE_PAIR_1,
+ ETHTOOL_A_CABLE_PAIR_2, ETHTOOL_A_CABLE_PAIR_3};

If you put one per line, you will keep the reverse christmas tree, and
David will be happy.

+ int pair, val, ret;
+ unsigned int delay_ms;

Well, David will be happy if you move this as well.

Damn, this should really be a checkpatch.pl check ;) It was "int delay_ms;"
before, then it was changed to "unsigned int delay_ms;"..


+ *finished = false;
+
+ if (priv->cdt_start) {
+ delay_ms = AT803X_CDT_DELAY_MS;
+ delay_ms -= jiffies_delta_to_msecs(jiffies - priv->cdt_start);
+ if (delay_ms > 0)
+ msleep(delay_ms);
+ }
+
+ for (pair = 0; pair < 4; pair++) {
+ ret = at803x_cdt_start(phydev, pair);
+ if (ret)
+ return ret;
+
+ ret = at803x_cdt_wait_for_completion(phydev);
+ if (ret)
+ return ret;
+
+ val = phy_read(phydev, AT803X_CDT_STATUS);
+ if (val < 0)
+ return val;
+
+ ethnl_cable_test_result(phydev, ethtool_pair[pair],
+ at803x_cdt_test_result(val));
+
+ if (at803x_cdt_fault_length_valid(val))
+ continue;

The name is not very intuitive. It return false if it is valid?

Mhh, this is actually wrong, it returns true if the length is
valid. I need to double check that. what about
at803x_cdt_fault_length_is_valid()

Otherwise, this looks good.

I'll wait for your v3 and then I'll rebase on that.

-michael