generic: 6.1, 6.6: mt7530: import accepted patches
[openwrt/openwrt.git] / target / linux / generic / backport-6.6 / 763-v6.10-net-dsa-introduce-dsa_phylink_to_port.patch
1 From f13b2b33c7674fa0988dfaa9adb95d7d912b489f Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Wed, 10 Apr 2024 20:42:38 +0100
4 Subject: [PATCH 1/2] net: dsa: introduce dsa_phylink_to_port()
5
6 We convert from a phylink_config struct to a dsa_port struct in many
7 places, let's provide a helper for this.
8
9 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
10 Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
11 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
12 Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
13 Link: https://lore.kernel.org/r/E1rudqA-006K9B-85@rmk-PC.armlinux.org.uk
14 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
15 ---
16 include/net/dsa.h | 6 ++++++
17 net/dsa/port.c | 12 ++++++------
18 2 files changed, 12 insertions(+), 6 deletions(-)
19
20 --- a/include/net/dsa.h
21 +++ b/include/net/dsa.h
22 @@ -327,6 +327,12 @@ struct dsa_port {
23 };
24 };
25
26 +static inline struct dsa_port *
27 +dsa_phylink_to_port(struct phylink_config *config)
28 +{
29 + return container_of(config, struct dsa_port, pl_config);
30 +}
31 +
32 /* TODO: ideally DSA ports would have a single dp->link_dp member,
33 * and no dst->rtable nor this struct dsa_link would be needed,
34 * but this would require some more complex tree walking,
35 --- a/net/dsa/port.c
36 +++ b/net/dsa/port.c
37 @@ -1572,7 +1572,7 @@ static struct phylink_pcs *
38 dsa_port_phylink_mac_select_pcs(struct phylink_config *config,
39 phy_interface_t interface)
40 {
41 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
42 + struct dsa_port *dp = dsa_phylink_to_port(config);
43 struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP);
44 struct dsa_switch *ds = dp->ds;
45
46 @@ -1586,7 +1586,7 @@ static int dsa_port_phylink_mac_prepare(
47 unsigned int mode,
48 phy_interface_t interface)
49 {
50 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
51 + struct dsa_port *dp = dsa_phylink_to_port(config);
52 struct dsa_switch *ds = dp->ds;
53 int err = 0;
54
55 @@ -1601,7 +1601,7 @@ static void dsa_port_phylink_mac_config(
56 unsigned int mode,
57 const struct phylink_link_state *state)
58 {
59 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
60 + struct dsa_port *dp = dsa_phylink_to_port(config);
61 struct dsa_switch *ds = dp->ds;
62
63 if (!ds->ops->phylink_mac_config)
64 @@ -1614,7 +1614,7 @@ static int dsa_port_phylink_mac_finish(s
65 unsigned int mode,
66 phy_interface_t interface)
67 {
68 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
69 + struct dsa_port *dp = dsa_phylink_to_port(config);
70 struct dsa_switch *ds = dp->ds;
71 int err = 0;
72
73 @@ -1629,7 +1629,7 @@ static void dsa_port_phylink_mac_link_do
74 unsigned int mode,
75 phy_interface_t interface)
76 {
77 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
78 + struct dsa_port *dp = dsa_phylink_to_port(config);
79 struct phy_device *phydev = NULL;
80 struct dsa_switch *ds = dp->ds;
81
82 @@ -1652,7 +1652,7 @@ static void dsa_port_phylink_mac_link_up
83 int speed, int duplex,
84 bool tx_pause, bool rx_pause)
85 {
86 - struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
87 + struct dsa_port *dp = dsa_phylink_to_port(config);
88 struct dsa_switch *ds = dp->ds;
89
90 if (!ds->ops->phylink_mac_link_up) {