Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp6667984rwr; Tue, 25 Apr 2023 01:44:35 -0700 (PDT) X-Google-Smtp-Source: AKy350Yjuj/E8WHtRvNJ1vGeRbH+WMiaC3B0NBrb9qiMboqQpCiaC87WdZFDGfEPksIayYwABZan X-Received: by 2002:a17:90b:313:b0:23d:500f:e826 with SMTP id ay19-20020a17090b031300b0023d500fe826mr16925953pjb.14.1682412274897; Tue, 25 Apr 2023 01:44:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682412274; cv=none; d=google.com; s=arc-20160816; b=QAdn+ftgoRfNbgcWDjYRBofR0xCRSG1F23OdDJQXIqA4RPOGD3wayOy5FUx8lIQTFh vEYO/V4mwSukFwTnp6Bo/G5dbiu7eajhTFKIa4dhZsicLCUx8UYLJW9XXYRRjc7CiCiI SsIOmRb9Wd1q5XQriKHDkMPwroadg8U0sdvcwI+YDMz44OJp7Mp+o8EjiCFlSN7fwPMO gScBUvvODbkhzMShnmAoGGQaYMAOaHSkRy2oZ9da7ukXo4xAxKIdUFZhhlMVnX8eSFer Vh4OqG7MEYM2CzSOumjkcIta0FSnHmgxXHU37nnWoVAMiT+zsNXtS2pm7ly5AexAI6B6 /dHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DcEecCSVjHrfHWDBYIR91HFhVC039k17zyIM1kkNbqQ=; b=EAG0XozQLGL1VkHPTh6D4qQRQABB9PGbJwrZj1/c4VQbxjzxOtqPg0GaIabfp3hicO utWPgW+Md1hrGrHrAYvWEBMS7SOxX/tJasFsEA1wykykp2xNiGtFfd03IerMnW2yJjoG V3MYsLeuhlF/md582gGIGBG79uVorRB9P4tzPvUeX+PfpLO7DYjQE6l+EdGDys3SeM96 mOD+t4OrS6MbYF/bUhurtwsScG+FZ3nmu9Ps8GoPVOtD9yIXuI9QbPS1fvH6frjoksEV m3wzNMyQZcEcJ/udzm8CZvo/YsDl7RCZi0SBk+AKnYSck1TjWOVFXT9S8kSZcDyO1tQ9 Wk/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=h2YPjHK0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g1-20020a17090adac100b00247c0ee86d6si15451498pjx.28.2023.04.25.01.44.20; Tue, 25 Apr 2023 01:44:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=h2YPjHK0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233893AbjDYId0 (ORCPT + 99 others); Tue, 25 Apr 2023 04:33:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233660AbjDYIbz (ORCPT ); Tue, 25 Apr 2023 04:31:55 -0400 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CDC66E97; Tue, 25 Apr 2023 01:30:50 -0700 (PDT) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-953343581a4so804686566b.3; Tue, 25 Apr 2023 01:30:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682411447; x=1685003447; 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=DcEecCSVjHrfHWDBYIR91HFhVC039k17zyIM1kkNbqQ=; b=h2YPjHK0YyO7kNZZERdjSTIaMFrALCP6RRpluyNBwxaPpj25GQO2pTQy4iso+ZgTWJ m2oELAWptlmGrWwGjYhskz6AsvghdBhJeVgvpptyhUFqAuZE7r64COHv8CMtaFtHmzVy r87HvoD3RlubhBui6i3/vQjE13pc19SUaVhcb3ZWf469GD0W2IlpUt3tu5a5M6kY3o5I r2dQCnOmZjFfnElUeJ2Jw5aE81g9+fdXfDaspf5ID0bsvjPI3enVLMPaX8ebhRM9czR9 Z2QiOyE4q2Wsz3ShuYCqg+GpoxFw3k0TfzImRWkRXNLg2SYldcGZG0BPLedGaQC+zpm/ zp+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682411447; x=1685003447; 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=DcEecCSVjHrfHWDBYIR91HFhVC039k17zyIM1kkNbqQ=; b=NTAxXk1oXAYmZ+6+5DHtbGTZoNcdiNpLjPzx1ltVdrX/fSjclRsCXQlEMLW51dqZ1w ng02NpxbNdSkV2GG7ItAlYKl6QxUlRelqKq0EFVlD6pe4sim9vGkf8Dh++lT0LghaBwB PPi1Rp2H6+b4IgBTEKpw9XCjj1h62X376a22s24ORB805C6XBivKS57Bj5dMsztWQI0o r7HiPWqnGSr9dphHypQIN2ul6YwJlkF+1BnXSqDdvzIt4k8BC/ld9Ujf+POPc8aGj1tI wsdI+6OjJPFklGF0tQCMcDvZXMt/yVaqQ4c7pDKuWNjg1n9BIJhTPPOiE/T30LJ6qvs1 y8AA== X-Gm-Message-State: AAQBX9e0JlG3Wvo/t6Kw5xub7DM/uXxIshP/LXYs1bD5ApsdRq8fqa7E nuCXxoa4RWMWHhnrAedMsX0= X-Received: by 2002:a17:907:c002:b0:932:ac6c:7ef9 with SMTP id ss2-20020a170907c00200b00932ac6c7ef9mr12445119ejc.22.1682411446671; Tue, 25 Apr 2023 01:30:46 -0700 (PDT) Received: from arinc9-PC.lan ([149.91.1.15]) by smtp.gmail.com with ESMTPSA id mc2-20020a170906eb4200b0094ca077c985sm6439028ejb.213.2023.04.25.01.30.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Apr 2023 01:30:46 -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, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH net-next 22/24] net: dsa: mt7530: get rid of useless error returns on phylink code path Date: Tue, 25 Apr 2023 11:29:31 +0300 Message-Id: <20230425082933.84654-23-arinc.unal@arinc9.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230425082933.84654-1-arinc.unal@arinc9.com> References: <20230425082933.84654-1-arinc.unal@arinc9.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arınç ÜNAL 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. Tested-by: Arınç ÜNAL Signed-off-by: Arınç ÜNAL Acked-by: Daniel Golle Tested-by: Daniel Golle --- drivers/net/dsa/mt7530.c | 81 ++++++++-------------------------------- drivers/net/dsa/mt7530.h | 2 +- 2 files changed, 17 insertions(+), 66 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 0bd38323e2b6..02e6ba5a4403 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2550,7 +2550,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, phy_interface_t interface) { @@ -2561,22 +2561,14 @@ mt7530_mac_config(struct dsa_switch *ds, int port, unsigned int mode, } else if (port == 6) { mt7530_setup_port6(priv->ds, interface); } - - return 0; } -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; - 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 |= GP_CLK_EN; val &= ~GP_MODE_MASK; @@ -2604,20 +2596,14 @@ static int mt7531_rgmii_setup(struct mt7530_priv *priv, u32 port, case PHY_INTERFACE_MODE_RGMII_ID: break; default: - return -EINVAL; + break; } } - mt7530_write(priv, MT7531_CLKGEN_CTRL, val); - return 0; -} - -static bool mt753x_is_mac_port(u32 port) -{ - return (port == 5 || port == 6); + mt7530_write(priv, MT7531_CLKGEN_CTRL, val); } -static int +static void mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode, phy_interface_t interface) { @@ -2625,42 +2611,21 @@ mt7531_mac_config(struct dsa_switch *ds, int port, unsigned int mode, struct phy_device *phydev; struct dsa_port *dp; - 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 = dsa_to_port(ds, port); phydev = 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; } -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 = ds->priv; - 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); } static struct phylink_pcs * @@ -2689,30 +2654,18 @@ mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode, u32 mcr_cur, mcr_new; switch (port) { - case 0 ... 4: /* Internal phy */ - if (state->interface != PHY_INTERFACE_MODE_GMII && - state->interface != PHY_INTERFACE_MODE_INTERNAL) - goto unsupported; - break; case 5: /* Port 5, can be used as a CPU port. */ if (priv->p5_configured) break; - 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. */ if (priv->p6_configured) break; - 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; } mcr_cur = mt7530_read(priv, MT7530_PMCR_P(port)); @@ -2805,7 +2758,6 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int port) struct mt7530_priv *priv = ds->priv; phy_interface_t interface; int speed; - int ret; switch (port) { case 5: @@ -2830,9 +2782,8 @@ mt7531_cpu_port_config(struct dsa_switch *ds, int port) else speed = SPEED_1000; - ret = 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); }; -- 2.37.2