1 From 58670652cacb7c5752e01f29979d0ca4cdbfcc0a Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= <arinc.unal@arinc9.com>
3 Date: Fri, 1 Mar 2024 12:43:00 +0200
4 Subject: [PATCH 22/30] net: dsa: mt7530: get rid of useless error returns on
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
10 Remove error returns on the cases where they are already handled with the
11 function the mac_port_get_caps member in mt753x_table points to.
13 mt7531_mac_config() is also called from mt7531_cpu_port_config() outside of
14 phylink but the port and interface modes are already handled there.
16 Change the functions and the mac_port_config function pointer to void now
17 that there're no error returns anymore.
19 Remove mt753x_is_mac_port() that used to help the said error returns.
21 On mt7531_mac_config(), switch to if statements to simplify the code.
23 Remove internal phy cases from mt753x_phylink_mac_config(), there is no
24 need to check the interface mode as that's already handled with the
25 function the mac_port_get_caps member in mt753x_table points to.
27 Acked-by: Daniel Golle <daniel@makrotopia.org>
28 Tested-by: Daniel Golle <daniel@makrotopia.org>
29 Signed-off-by: Arınç ÜNAL <arinc.unal@arinc9.com>
30 Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
31 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
33 drivers/net/dsa/mt7530.c | 81 ++++++++--------------------------------
34 drivers/net/dsa/mt7530.h | 6 +--
35 2 files changed, 19 insertions(+), 68 deletions(-)
37 --- a/drivers/net/dsa/mt7530.c
38 +++ b/drivers/net/dsa/mt7530.c
39 @@ -2800,7 +2800,7 @@ static void mt7988_mac_port_get_caps(str
45 mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
46 phy_interface_t interface)
48 @@ -2810,22 +2810,14 @@ mt7530_mac_config(struct dsa_switch *ds,
49 mt7530_setup_port5(priv->ds, interface);
51 mt7530_setup_port6(priv->ds, interface);
56 -static int mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port,
57 - phy_interface_t interface,
58 - struct phy_device *phydev)
59 +static void mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port,
60 + phy_interface_t interface,
61 + struct phy_device *phydev)
65 - if (priv->p5_sgmii) {
66 - dev_err(priv->dev, "RGMII mode is not available for port %d\n",
71 val = mt7530_read(priv, MT7531_CLKGEN_CTRL);
74 @@ -2853,20 +2845,14 @@ static int mt7531_rgmii_setup(struct mt7
75 case PHY_INTERFACE_MODE_RGMII_ID:
82 - mt7530_write(priv, MT7531_CLKGEN_CTRL, val);
87 -static bool mt753x_is_mac_port(u32 port)
89 - return (port == 5 || port == 6);
90 + mt7530_write(priv, MT7531_CLKGEN_CTRL, val);
95 mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
96 phy_interface_t interface)
98 @@ -2874,42 +2860,21 @@ mt7531_mac_config(struct dsa_switch *ds,
99 struct phy_device *phydev;
102 - if (!mt753x_is_mac_port(port)) {
103 - dev_err(priv->dev, "port %d is not a MAC port\n", port);
107 - switch (interface) {
108 - case PHY_INTERFACE_MODE_RGMII:
109 - case PHY_INTERFACE_MODE_RGMII_ID:
110 - case PHY_INTERFACE_MODE_RGMII_RXID:
111 - case PHY_INTERFACE_MODE_RGMII_TXID:
112 + if (phy_interface_mode_is_rgmii(interface)) {
113 dp = dsa_to_port(ds, port);
114 phydev = dp->slave->phydev;
115 - return mt7531_rgmii_setup(priv, port, interface, phydev);
116 - case PHY_INTERFACE_MODE_SGMII:
117 - case PHY_INTERFACE_MODE_NA:
118 - case PHY_INTERFACE_MODE_1000BASEX:
119 - case PHY_INTERFACE_MODE_2500BASEX:
120 - /* handled in SGMII PCS driver */
124 + mt7531_rgmii_setup(priv, port, interface, phydev);
132 mt753x_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
133 const struct phylink_link_state *state)
135 struct mt7530_priv *priv = ds->priv;
137 - if (!priv->info->mac_port_config)
140 - return priv->info->mac_port_config(ds, port, mode, state->interface);
141 + if (priv->info->mac_port_config)
142 + priv->info->mac_port_config(ds, port, mode, state->interface);
145 static struct phylink_pcs *
146 @@ -2938,17 +2903,11 @@ mt753x_phylink_mac_config(struct dsa_swi
147 u32 mcr_cur, mcr_new;
151 - if (state->interface != PHY_INTERFACE_MODE_GMII &&
152 - state->interface != PHY_INTERFACE_MODE_INTERNAL)
156 if (priv->p5_interface == state->interface)
159 - if (mt753x_mac_config(ds, port, mode, state) < 0)
161 + mt753x_mac_config(ds, port, mode, state);
163 if (priv->p5_intf_sel != P5_DISABLED)
164 priv->p5_interface = state->interface;
165 @@ -2957,16 +2916,10 @@ mt753x_phylink_mac_config(struct dsa_swi
166 if (priv->p6_interface == state->interface)
169 - if (mt753x_mac_config(ds, port, mode, state) < 0)
171 + mt753x_mac_config(ds, port, mode, state);
173 priv->p6_interface = state->interface;
177 - dev_err(ds->dev, "%s: unsupported %s port: %i\n",
178 - __func__, phy_modes(state->interface), port);
182 mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port));
183 @@ -3049,7 +3002,6 @@ mt7531_cpu_port_config(struct dsa_switch
184 struct mt7530_priv *priv = ds->priv;
185 phy_interface_t interface;
191 @@ -3074,9 +3026,8 @@ mt7531_cpu_port_config(struct dsa_switch
195 - ret = mt7531_mac_config(ds, port, MLO_AN_FIXED, interface);
198 + mt7531_mac_config(ds, port, MLO_AN_FIXED, interface);
200 mt7530_write(priv, MT7530_PMCR_P(port),
201 PMCR_CPU_PORT_SETTING(priv->id));
202 mt753x_phylink_mac_link_up(ds, port, MLO_AN_FIXED, interface, NULL,
203 --- a/drivers/net/dsa/mt7530.h
204 +++ b/drivers/net/dsa/mt7530.h
205 @@ -760,9 +760,9 @@ struct mt753x_info {
206 void (*mac_port_validate)(struct dsa_switch *ds, int port,
207 phy_interface_t interface,
208 unsigned long *supported);
209 - int (*mac_port_config)(struct dsa_switch *ds, int port,
211 - phy_interface_t interface);
212 + void (*mac_port_config)(struct dsa_switch *ds, int port,
214 + phy_interface_t interface);
217 /* struct mt7530_priv - This is the main data structure for holding the state