1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- From 22eb276098da820d9440fad22901f9b74ed4d659 Mon Sep 17 00:00:00 2001
- From: Christian Marangi <[email protected]>
- Date: Thu, 4 Jan 2024 22:30:38 +0100
- Subject: [PATCH 1/4] net: phy: at803x: generalize cdt fault length function
- Generalize cable test fault length function since they all base on the
- same magic values (already reverse engineered to understand the meaning
- of it) to have consistenct values on every PHY.
- Signed-off-by: Christian Marangi <[email protected]>
- Reviewed-by: Simon Horman <[email protected]>
- Signed-off-by: David S. Miller <[email protected]>
- ---
- drivers/net/phy/at803x.c | 13 ++++++-------
- 1 file changed, 6 insertions(+), 7 deletions(-)
- --- a/drivers/net/phy/at803x.c
- +++ b/drivers/net/phy/at803x.c
- @@ -1192,10 +1192,8 @@ static bool at803x_cdt_fault_length_vali
- return false;
- }
-
- -static int at803x_cdt_fault_length(u16 status)
- +static int at803x_cdt_fault_length(int dt)
- {
- - int dt;
- -
- /* According to the datasheet the distance to the fault is
- * DELTA_TIME * 0.824 meters.
- *
- @@ -1211,8 +1209,6 @@ static int at803x_cdt_fault_length(u16 s
- * With a VF of 0.69 we get the factor 0.824 mentioned in the
- * datasheet.
- */
- - dt = FIELD_GET(AT803X_CDT_STATUS_DELTA_TIME_MASK, status);
- -
- return (dt * 824) / 10;
- }
-
- @@ -1265,9 +1261,11 @@ static int at803x_cable_test_one_pair(st
- ethnl_cable_test_result(phydev, ethtool_pair[pair],
- at803x_cable_test_result_trans(val));
-
- - if (at803x_cdt_fault_length_valid(val))
- + if (at803x_cdt_fault_length_valid(val)) {
- + val = FIELD_GET(AT803X_CDT_STATUS_DELTA_TIME_MASK, val);
- ethnl_cable_test_fault_length(phydev, ethtool_pair[pair],
- at803x_cdt_fault_length(val));
- + }
-
- return 1;
- }
- @@ -1992,7 +1990,8 @@ static int qca808x_cdt_fault_length(stru
- if (val < 0)
- return val;
-
- - return (FIELD_GET(QCA808X_CDT_DIAG_LENGTH, val) * 824) / 10;
- + val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH, val);
- + return at803x_cdt_fault_length(val);
- }
-
- static int qca808x_cable_test_start(struct phy_device *phydev)
|