From: Russell King (Oracle) Date: Fri, 27 Mar 2026 08:43:43 +0000 (+0000) Subject: net: stmmac: qcom-ethqos: move detection of invalid RGMII speed X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=426ce4677e8101996d1ff230464ea696eba2d853;p=thirdparty%2Fkernel%2Flinux.git net: stmmac: qcom-ethqos: move detection of invalid RGMII speed Move detection of invalid RGMII speeds (which will never be triggered) before the switch() to allow register modifications that are common to all speeds to be moved out of the switch. Signed-off-by: Russell King (Oracle) Tested-by: Mohd Ayaan Anwar Link: https://patch.msgid.link/E1w62n9-0000000E3C9-2Zkr@rmk-PC.armlinux.org.uk Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index f7e3a2b8803f..d19331067459 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -397,6 +397,11 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos, int speed) /* Select RGMII, write 0 to interface select */ rgmii_clrmask(ethqos, RGMII_CONFIG_INTF_SEL, RGMII_IO_MACRO_CONFIG); + if (speed != SPEED_1000 && speed != SPEED_100 && speed != SPEED_10) { + dev_err(dev, "Invalid speed %d\n", speed); + return -EINVAL; + } + switch (speed) { case SPEED_1000: rgmii_setmask(ethqos, RGMII_CONFIG_DDR_MODE, @@ -510,9 +515,6 @@ static int ethqos_rgmii_macro_init(struct qcom_ethqos *ethqos, int speed) rgmii_updatel(ethqos, RGMII_CONFIG_LOOPBACK_EN, loopback, RGMII_IO_MACRO_CONFIG); break; - default: - dev_err(dev, "Invalid speed %d\n", speed); - return -EINVAL; } return 0;