From nobody Fri Sep 20 20:25:27 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25E89C77B75 for ; Mon, 22 May 2023 12:19:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233372AbjEVMTg (ORCPT ); Mon, 22 May 2023 08:19:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233798AbjEVMSV (ORCPT ); Mon, 22 May 2023 08:18:21 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA9F71FD8; Mon, 22 May 2023 05:16:55 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-96f683e8855so501064866b.2; Mon, 22 May 2023 05:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684757809; x=1687349809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L7JBtEPSTsLOs/JWqoRR+gHqVNN2Pp1AK8gJa80nPkU=; b=VQzCHkaoUfd1TJA66iSSLvg+i2UzryWZ2LZ10vl37d3qhgdkC9STal6sT65wfEKHmM DVjbklaBuGxtD56ZSe6zMYkQMom6MnLrELVZJkA7UR/pvB1/wzdE7CwXt7g4R+c+Evpu LOkvUYAvYwycI0kma7g4cWkPUWRbP3N5+vxE0Fsgd/AxwvOlS7Z3FdvrTmvUDB39sHsw ivR8kfbOZdtXg59akv5vNisMMm2pwYHz2oZ1U20/74NgbfIzX7x3Ld1V6J1PHcbUHmBm UPoZEeemgso2mWxm8C6JoV7hM6ygaVNzaiydiRLxzCwEyvE7dpYoL4jUvuh1UK2cedFJ 38jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684757809; x=1687349809; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L7JBtEPSTsLOs/JWqoRR+gHqVNN2Pp1AK8gJa80nPkU=; b=czZJKodLdvEjpoMwKx+6umqBjZbec5neLwY56apcyETtlG3Id+dZiIxYzE6+Td+UXA d8AiRIypNVf8JzTVdGk3qbDkrZat/OC6gHGm85dHtZquZrT6f6WU3Otl2MmXDVSu1wOj fMnhIsUDzifIHvZehOmSAMMNNIZJnt4N9Gm2Gq06snyftmtYVI3KEPyxdfGwANCYgYNt Nqd/kTKhbnR9rU9lcXXCi09Y4EVZxDdC1RW9tKHq3EgRcSGOT4GttZ3r0udYVymKuzqR 4ikj7vFm4imRPbaTDNpAHijRE6umiNvPB7eUdja7Fl15F1ZvnVl+khXjOVuQt4TkakR6 K5UQ== X-Gm-Message-State: AC+VfDzBq2AkEBtNOVVusNMLmCVDgcbqYKIPFjM1yJVfp1NOSWz3nc3x QWJXKhC8i79gCk2KeC5hXuI= X-Google-Smtp-Source: ACHHUZ4ernIKsoBOw6M1XLrlLoJ0AnuWIqRtrMaNnZj1SxdtLoMWsiR3HBHRQqp1eZPA/qrftxlNng== X-Received: by 2002:a17:906:db04:b0:957:1df0:9cbf with SMTP id xj4-20020a170906db0400b009571df09cbfmr9202182ejb.19.1684757809148; Mon, 22 May 2023 05:16:49 -0700 (PDT) Received: from arinc9-PC.. ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id y26-20020a17090614da00b009659fed3612sm2999950ejc.24.2023.05.22.05.16.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 05:16:48 -0700 (PDT) From: arinc9.unal@gmail.com X-Google-Original-From: arinc.unal@arinc9.com To: Sean Wang , Landen Chao , DENG Qingfang , Daniel Golle , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King Cc: =?UTF-8?q?Ar=C4=B1n=C3=A7=20=C3=9CNAL?= , Richard van Schagen , Richard van Schagen , Frank Wunderlich , Bartel Eerdekens , erkin.bozoglu@xeront.com, mithat.guner@xeront.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH net-next 21/30] net: dsa: mt7530: get rid of useless error returns on phylink code path Date: Mon, 22 May 2023 15:15:23 +0300 Message-Id: <20230522121532.86610-22-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230522121532.86610-1-arinc.unal@arinc9.com> References: <20230522121532.86610-1-arinc.unal@arinc9.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ar=C4=B1n=C3=A7 =C3=9CNAL Remove error returns on the cases where they are already handled with the function the mac_port_get_caps member 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() as there is no configuration to be done for them. There's also no need to check the interface mode as that's already handled with the function the mac_port_get_caps member points to. Remove the comments for port 5 and 6 as they're not really useful. Tested-by: Ar=C4=B1n=C3=A7 =C3=9CNAL Signed-off-by: Ar=C4=B1n=C3=A7 =C3=9CNAL Acked-by: Daniel Golle Tested-by: Daniel Golle --- drivers/net/dsa/mt7530.c | 85 +++++++++------------------------------- drivers/net/dsa/mt7530.h | 2 +- 2 files changed, 19 insertions(+), 68 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index aafb7415e2ce..996b8c02cb05 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2545,7 +2545,7 @@ static void mt7988_mac_port_get_caps(struct dsa_switc= h *ds, int port, } } =20 -static int +static void mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode, phy_interface_t interface) { @@ -2556,22 +2556,14 @@ mt7530_mac_config(struct dsa_switch *ds, int port, = unsigned int mode, } else if (port =3D=3D 6) { mt7530_setup_port6(priv->ds, interface); } - - return 0; } =20 -static int mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port, - phy_interface_t interface, - struct phy_device *phydev) +static void mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port, + phy_interface_t interface, + struct phy_device *phydev) { u32 val; =20 - if (priv->p5_sgmii) { - dev_err(priv->dev, "RGMII mode is not available for port %d\n", - port); - return -EINVAL; - } - val =3D mt7530_read(priv, MT7531_CLKGEN_CTRL); val |=3D GP_CLK_EN; val &=3D ~GP_MODE_MASK; @@ -2599,20 +2591,14 @@ static int mt7531_rgmii_setup(struct mt7530_priv *p= riv, u32 port, case PHY_INTERFACE_MODE_RGMII_ID: break; default: - return -EINVAL; + break; } } - mt7530_write(priv, MT7531_CLKGEN_CTRL, val); =20 - return 0; -} - -static bool mt753x_is_mac_port(u32 port) -{ - return (port =3D=3D 5 || port =3D=3D 6); + mt7530_write(priv, MT7531_CLKGEN_CTRL, val); } =20 -static int +static void mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode, phy_interface_t interface) { @@ -2620,42 +2606,21 @@ mt7531_mac_config(struct dsa_switch *ds, int port, = unsigned int mode, struct phy_device *phydev; struct dsa_port *dp; =20 - if (!mt753x_is_mac_port(port)) { - 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: + if (phy_interface_mode_is_rgmii(interface)) { dp =3D dsa_to_port(ds, port); phydev =3D dp->slave->phydev; - return 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; + mt7531_rgmii_setup(priv, port, interface, phydev); } - - return -EINVAL; } =20 -static int +static void mt753x_mac_config(struct dsa_switch *ds, int port, unsigned int mode, const struct phylink_link_state *state) { struct mt7530_priv *priv =3D ds->priv; =20 - if (!priv->info->mac_port_config) - return 0; - - return priv->info->mac_port_config(ds, port, mode, state->interface); + if (priv->info->mac_port_config) + priv->info->mac_port_config(ds, port, mode, state->interface); } =20 static struct phylink_pcs * @@ -2684,30 +2649,18 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, in= t port, unsigned int mode, u32 mcr_cur, mcr_new; =20 switch (port) { - case 0 ... 4: /* Internal phy */ - if (state->interface !=3D PHY_INTERFACE_MODE_GMII && - state->interface !=3D PHY_INTERFACE_MODE_INTERNAL) - goto unsupported; - break; - case 5: /* Port 5, can be used as a CPU port. */ + case 5: if (priv->p5_configured) break; =20 - if (mt753x_mac_config(ds, port, mode, state) < 0) - goto unsupported; + mt753x_mac_config(ds, port, mode, state); break; - case 6: /* Port 6, can be used as a CPU port. */ + case 6: if (priv->p6_configured) break; =20 - if (mt753x_mac_config(ds, port, mode, state) < 0) - goto unsupported; + mt753x_mac_config(ds, port, mode, state); break; - default: -unsupported: - dev_err(ds->dev, "%s: unsupported %s port: %i\n", - __func__, phy_modes(state->interface), port); - return; } =20 mcr_cur =3D mt7530_read(priv, MT7530_PMCR_P(port)); @@ -2800,7 +2753,6 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int por= t) struct mt7530_priv *priv =3D ds->priv; phy_interface_t interface; int speed; - int ret; =20 switch (port) { case 5: @@ -2825,9 +2777,8 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int por= t) else speed =3D SPEED_1000; =20 - ret =3D mt7531_mac_config(ds, port, MLO_AN_FIXED, interface); - if (ret) - return ret; + mt7531_mac_config(ds, port, MLO_AN_FIXED, interface); + mt7530_write(priv, MT7530_PMCR_P(port), PMCR_CPU_PORT_SETTING(priv->id)); mt753x_phylink_pcs_link_up(&priv->pcs[port].pcs, MLO_AN_FIXED, diff --git a/drivers/net/dsa/mt7530.h b/drivers/net/dsa/mt7530.h index f7a504e4c17b..b7f80a487073 100644 --- a/drivers/net/dsa/mt7530.h +++ b/drivers/net/dsa/mt7530.h @@ -722,7 +722,7 @@ struct mt753x_info { void (*mac_port_validate)(struct dsa_switch *ds, int port, phy_interface_t interface, 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, phy_interface_t interface); }; --=20 2.39.2