kernel: bump 6.6 to 6.6.23
[openwrt/openwrt.git] / target / linux / generic / backport-6.6 / 711-v6.8-01-net-phy-at803x-generalize-cdt-fault-length-function.patch
1 From 22eb276098da820d9440fad22901f9b74ed4d659 Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Thu, 4 Jan 2024 22:30:38 +0100
4 Subject: [PATCH 1/4] net: phy: at803x: generalize cdt fault length function
5
6 Generalize cable test fault length function since they all base on the
7 same magic values (already reverse engineered to understand the meaning
8 of it) to have consistenct values on every PHY.
9
10 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
11 Reviewed-by: Simon Horman <horms@kernel.org>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
13 ---
14 drivers/net/phy/at803x.c | 13 ++++++-------
15 1 file changed, 6 insertions(+), 7 deletions(-)
16
17 --- a/drivers/net/phy/at803x.c
18 +++ b/drivers/net/phy/at803x.c
19 @@ -1192,10 +1192,8 @@ static bool at803x_cdt_fault_length_vali
20 return false;
21 }
22
23 -static int at803x_cdt_fault_length(u16 status)
24 +static int at803x_cdt_fault_length(int dt)
25 {
26 - int dt;
27 -
28 /* According to the datasheet the distance to the fault is
29 * DELTA_TIME * 0.824 meters.
30 *
31 @@ -1211,8 +1209,6 @@ static int at803x_cdt_fault_length(u16 s
32 * With a VF of 0.69 we get the factor 0.824 mentioned in the
33 * datasheet.
34 */
35 - dt = FIELD_GET(AT803X_CDT_STATUS_DELTA_TIME_MASK, status);
36 -
37 return (dt * 824) / 10;
38 }
39
40 @@ -1265,9 +1261,11 @@ static int at803x_cable_test_one_pair(st
41 ethnl_cable_test_result(phydev, ethtool_pair[pair],
42 at803x_cable_test_result_trans(val));
43
44 - if (at803x_cdt_fault_length_valid(val))
45 + if (at803x_cdt_fault_length_valid(val)) {
46 + val = FIELD_GET(AT803X_CDT_STATUS_DELTA_TIME_MASK, val);
47 ethnl_cable_test_fault_length(phydev, ethtool_pair[pair],
48 at803x_cdt_fault_length(val));
49 + }
50
51 return 1;
52 }
53 @@ -1992,7 +1990,8 @@ static int qca808x_cdt_fault_length(stru
54 if (val < 0)
55 return val;
56
57 - return (FIELD_GET(QCA808X_CDT_DIAG_LENGTH, val) * 824) / 10;
58 + val = FIELD_GET(QCA808X_CDT_DIAG_LENGTH, val);
59 + return at803x_cdt_fault_length(val);
60 }
61
62 static int qca808x_cable_test_start(struct phy_device *phydev)