521da5f30b482672b2112368db73ebcfa279b305
[openwrt/staging/xback.git] /
1 From d1a16dbbd84e02d2a6dcfcb8d5c4b8b2c0289f00 Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Fri, 8 Nov 2024 16:02:00 +0000
4 Subject: [PATCH 4/5] net: phylink: remove switch() statement in resolve
5 handling
6
7 The switch() statement doesn't sit very well with the preceeding if()
8 statements, so let's just convert everything to if()s. As a result of
9 the two preceding commits, there is now only one case in the switch()
10 statement. Remove the switch statement and reduce the code indentation.
11 Code reformatting will be in the following commit.
12
13 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
14 Link: https://patch.msgid.link/E1t9RQu-002Fez-AA@rmk-PC.armlinux.org.uk
15 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
16 ---
17 drivers/net/phy/phylink.c | 94 +++++++++++++++++++--------------------
18 1 file changed, 45 insertions(+), 49 deletions(-)
19
20 --- a/drivers/net/phy/phylink.c
21 +++ b/drivers/net/phy/phylink.c
22 @@ -1436,60 +1436,56 @@ static void phylink_resolve(struct work_
23 link_state = pl->phy_state;
24 mac_config = link_state.link;
25 } else {
26 - switch (pl->cur_link_an_mode) {
27 - case MLO_AN_INBAND:
28 - phylink_mac_pcs_get_state(pl, &link_state);
29 -
30 - /* The PCS may have a latching link-fail indicator.
31 - * If the link was up, bring the link down and
32 - * re-trigger the resolve. Otherwise, re-read the
33 - * PCS state to get the current status of the link.
34 + phylink_mac_pcs_get_state(pl, &link_state);
35 +
36 + /* The PCS may have a latching link-fail indicator.
37 + * If the link was up, bring the link down and
38 + * re-trigger the resolve. Otherwise, re-read the
39 + * PCS state to get the current status of the link.
40 + */
41 + if (!link_state.link) {
42 + if (cur_link_state)
43 + retrigger = true;
44 + else
45 + phylink_mac_pcs_get_state(pl,
46 + &link_state);
47 + }
48 +
49 + /* If we have a phy, the "up" state is the union of
50 + * both the PHY and the MAC
51 + */
52 + if (pl->phydev)
53 + link_state.link &= pl->phy_state.link;
54 +
55 + /* Only update if the PHY link is up */
56 + if (pl->phydev && pl->phy_state.link) {
57 + /* If the interface has changed, force a
58 + * link down event if the link isn't already
59 + * down, and re-resolve.
60 */
61 - if (!link_state.link) {
62 - if (cur_link_state)
63 - retrigger = true;
64 - else
65 - phylink_mac_pcs_get_state(pl,
66 - &link_state);
67 + if (link_state.interface !=
68 + pl->phy_state.interface) {
69 + retrigger = true;
70 + link_state.link = false;
71 }
72 + link_state.interface = pl->phy_state.interface;
73
74 - /* If we have a phy, the "up" state is the union of
75 - * both the PHY and the MAC
76 + /* If we are doing rate matching, then the
77 + * link speed/duplex comes from the PHY
78 */
79 - if (pl->phydev)
80 - link_state.link &= pl->phy_state.link;
81 -
82 - /* Only update if the PHY link is up */
83 - if (pl->phydev && pl->phy_state.link) {
84 - /* If the interface has changed, force a
85 - * link down event if the link isn't already
86 - * down, and re-resolve.
87 - */
88 - if (link_state.interface !=
89 - pl->phy_state.interface) {
90 - retrigger = true;
91 - link_state.link = false;
92 - }
93 - link_state.interface = pl->phy_state.interface;
94 -
95 - /* If we are doing rate matching, then the
96 - * link speed/duplex comes from the PHY
97 - */
98 - if (pl->phy_state.rate_matching) {
99 - link_state.rate_matching =
100 - pl->phy_state.rate_matching;
101 - link_state.speed = pl->phy_state.speed;
102 - link_state.duplex =
103 - pl->phy_state.duplex;
104 - }
105 -
106 - /* If we have a PHY, we need to update with
107 - * the PHY flow control bits.
108 - */
109 - link_state.pause = pl->phy_state.pause;
110 - mac_config = true;
111 + if (pl->phy_state.rate_matching) {
112 + link_state.rate_matching =
113 + pl->phy_state.rate_matching;
114 + link_state.speed = pl->phy_state.speed;
115 + link_state.duplex =
116 + pl->phy_state.duplex;
117 }
118 - break;
119 +
120 + /* If we have a PHY, we need to update with
121 + * the PHY flow control bits.
122 + */
123 + link_state.pause = pl->phy_state.pause;
124 + mac_config = true;
125 }
126 }
127