Commit adf4ae24 authored by Arınç ÜNAL's avatar Arınç ÜNAL Committed by Paolo Abeni

net: dsa: mt7530: get rid of useless error returns on phylink code path

Remove error returns on the cases where they are already handled with the
function the mac_port_get_caps member in mt753x_table points to.

mt7531_mac_config() is also called from mt7531_cpu_port_config() outside of
phylink but the port and interface modes are already handled there.

Change the functions and the mac_port_config function pointer to void now
that there're no error returns anymore.

Remove mt753x_is_mac_port() that used to help the said error returns.

On mt7531_mac_config(), switch to if statements to simplify the code.

Remove internal phy cases from mt753x_phylink_mac_config(), there is no
need to check the interface mode as that's already handled with the
function the mac_port_get_caps member in mt753x_table points to.
Acked-by: default avatarDaniel Golle <daniel@makrotopia.org>
Tested-by: default avatarDaniel Golle <daniel@makrotopia.org>
Signed-off-by: default avatarArınç ÜNAL <arinc.unal@arinc9.com>
Reviewed-by: default avatarRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent a565f98d
...@@ -2587,7 +2587,7 @@ static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port, ...@@ -2587,7 +2587,7 @@ static void mt7988_mac_port_get_caps(struct dsa_switch *ds, int port,
} }
} }
static int static void
mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode, mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
phy_interface_t interface) phy_interface_t interface)
{ {
...@@ -2597,22 +2597,14 @@ mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode, ...@@ -2597,22 +2597,14 @@ mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
mt7530_setup_port5(priv->ds, interface); mt7530_setup_port5(priv->ds, interface);
else if (port == 6) else if (port == 6)
mt7530_setup_port6(priv->ds, interface); mt7530_setup_port6(priv->ds, interface);
return 0;
} }
static int mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port, static void mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port,
phy_interface_t interface, phy_interface_t interface,
struct phy_device *phydev) struct phy_device *phydev)
{ {
u32 val; u32 val;
if (priv->p5_sgmii) {
dev_err(priv->dev, "RGMII mode is not available for port %d\n",
port);
return -EINVAL;
}
val = mt7530_read(priv, MT7531_CLKGEN_CTRL); val = mt7530_read(priv, MT7531_CLKGEN_CTRL);
val |= GP_CLK_EN; val |= GP_CLK_EN;
val &= ~GP_MODE_MASK; val &= ~GP_MODE_MASK;
...@@ -2640,20 +2632,14 @@ static int mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port, ...@@ -2640,20 +2632,14 @@ static int mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port,
case PHY_INTERFACE_MODE_RGMII_ID: case PHY_INTERFACE_MODE_RGMII_ID:
break; break;
default: default:
return -EINVAL; break;
} }
} }
mt7530_write(priv, MT7531_CLKGEN_CTRL, val);
return 0;
}
static bool mt753x_is_mac_port(u32 port) mt7530_write(priv, MT7531_CLKGEN_CTRL, val);
{
return (port == 5 || port == 6);
} }
static int static void
mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode, mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
phy_interface_t interface) phy_interface_t interface)
{ {
...@@ -2661,42 +2647,21 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode, ...@@ -2661,42 +2647,21 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
struct phy_device *phydev; struct phy_device *phydev;
struct dsa_port *dp; struct dsa_port *dp;
if (!mt753x_is_mac_port(port)) { if (phy_interface_mode_is_rgmii(interface)) {
dev_err(priv->dev, "port %d is not a MAC port\n", port);
return -EINVAL;
}
switch (interface) {
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_TXID:
dp = dsa_to_port(ds, port); dp = dsa_to_port(ds, port);
phydev = dp->user->phydev; phydev = dp->user->phydev;
return mt7531_rgmii_setup(priv, port, interface, phydev); mt7531_rgmii_setup(priv, port, interface, phydev);
case PHY_INTERFACE_MODE_SGMII:
case PHY_INTERFACE_MODE_NA:
case PHY_INTERFACE_MODE_1000BASEX:
case PHY_INTERFACE_MODE_2500BASEX:
/* handled in SGMII PCS driver */
return 0;
default:
return -EINVAL;
} }
return -EINVAL;
} }
static int static void
mt753x_mac_config(struct dsa_switch *ds, int port, unsigned int mode, mt753x_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
const struct phylink_link_state *state) const struct phylink_link_state *state)
{ {
struct mt7530_priv *priv = ds->priv; struct mt7530_priv *priv = ds->priv;
if (!priv->info->mac_port_config) if (priv->info->mac_port_config)
return 0; priv->info->mac_port_config(ds, port, mode, state->interface);
return priv->info->mac_port_config(ds, port, mode, state->interface);
} }
static struct phylink_pcs * static struct phylink_pcs *
...@@ -2725,17 +2690,11 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, ...@@ -2725,17 +2690,11 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
u32 mcr_cur, mcr_new; u32 mcr_cur, mcr_new;
switch (port) { switch (port) {
case 0 ... 4:
if (state->interface != PHY_INTERFACE_MODE_GMII &&
state->interface != PHY_INTERFACE_MODE_INTERNAL)
goto unsupported;
break;
case 5: case 5:
if (priv->p5_interface == state->interface) if (priv->p5_interface == state->interface)
break; break;
if (mt753x_mac_config(ds, port, mode, state) < 0) mt753x_mac_config(ds, port, mode, state);
goto unsupported;
if (priv->p5_intf_sel != P5_DISABLED) if (priv->p5_intf_sel != P5_DISABLED)
priv->p5_interface = state->interface; priv->p5_interface = state->interface;
...@@ -2744,16 +2703,10 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, ...@@ -2744,16 +2703,10 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
if (priv->p6_interface == state->interface) if (priv->p6_interface == state->interface)
break; break;
if (mt753x_mac_config(ds, port, mode, state) < 0) mt753x_mac_config(ds, port, mode, state);
goto unsupported;
priv->p6_interface = state->interface; priv->p6_interface = state->interface;
break; break;
default:
unsupported:
dev_err(ds->dev, "%s: unsupported %s port: %i\n",
__func__, phy_modes(state->interface), port);
return;
} }
mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port)); mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port));
...@@ -2836,7 +2789,6 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int port) ...@@ -2836,7 +2789,6 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int port)
struct mt7530_priv *priv = ds->priv; struct mt7530_priv *priv = ds->priv;
phy_interface_t interface; phy_interface_t interface;
int speed; int speed;
int ret;
switch (port) { switch (port) {
case 5: case 5:
...@@ -2861,9 +2813,8 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int port) ...@@ -2861,9 +2813,8 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int port)
else else
speed = SPEED_1000; speed = SPEED_1000;
ret = mt7531_mac_config(ds, port, MLO_AN_FIXED, interface); mt7531_mac_config(ds, port, MLO_AN_FIXED, interface);
if (ret)
return ret;
mt7530_write(priv, MT7530_PMCR_P(port), mt7530_write(priv, MT7530_PMCR_P(port),
PMCR_CPU_PORT_SETTING(priv->id)); PMCR_CPU_PORT_SETTING(priv->id));
mt753x_phylink_mac_link_up(ds, port, MLO_AN_FIXED, interface, NULL, mt753x_phylink_mac_link_up(ds, port, MLO_AN_FIXED, interface, NULL,
......
...@@ -730,9 +730,9 @@ struct mt753x_info { ...@@ -730,9 +730,9 @@ struct mt753x_info {
void (*mac_port_validate)(struct dsa_switch *ds, int port, void (*mac_port_validate)(struct dsa_switch *ds, int port,
phy_interface_t interface, phy_interface_t interface,
unsigned long *supported); unsigned long *supported);
int (*mac_port_config)(struct dsa_switch *ds, int port, void (*mac_port_config)(struct dsa_switch *ds, int port,
unsigned int mode, unsigned int mode,
phy_interface_t interface); phy_interface_t interface);
}; };
/* struct mt7530_priv - This is the main data structure for holding the state /* struct mt7530_priv - This is the main data structure for holding the state
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment