Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp2666533rwr; Fri, 21 Apr 2023 12:05:06 -0700 (PDT) X-Google-Smtp-Source: AKy350ai8FQFLImOxS8jBo4TIRK0PfcXw1X5DA1JVx0GUe9M/UaP/pQlShJkmD6jZtY8j5g4QzYg X-Received: by 2002:a17:902:e802:b0:1a6:c366:1609 with SMTP id u2-20020a170902e80200b001a6c3661609mr7135162plg.0.1682103905635; Fri, 21 Apr 2023 12:05:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682103905; cv=none; d=google.com; s=arc-20160816; b=z/1j1jWN3mUdYOc6Sm5iluExFcK0tBaFRiSPIYllLPU3qPCUhTqS4JTfGjX1TRAT2U 4tu81zM+dTyetIjKxT9TfpnFsn2Yn/jgHz42rbiU9LIWF3g4mDH1CPMiqY8SQL6i2UI8 TtqE/34ISvdLs+EPjpZya+ZHhftqZYdAVcIQW0LqqOXGf7CKp3YWZ/5faBk2XoIepZYm +wrW3j3/YPfNZsYzlBF2QY4gXuXydQUYbtTjZpHtq9XMgHdKsJ7EGMo6x9iHIG7GX30/ kIf2ldVsJdk7z9y8DIABwSaJXvKHLpONeqdOHjrNfx8o1mHXvXz9NiEu92b+5LOO/9uX THHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=XglpWxPmNTyeP3VKXyw6q/5B7BF2PKLy4QeJw7uH6Bk=; b=OxiBK23Gqjjj+6Ryhh6F465fqHv8qTp9M564LHMgC6kFnL+6GlmDiR4akHoPVXCTyt BhLeo6RyTHQzFng0RsiUERsc8Fa+KNR4zQdUWTulK/TO7LVo94GN9tXyEmfdIVtI0Sqb nUNaFddpNR+xnIC8wZ5QcjE7U4idZkpJ8OFMczehKEsa8LZOynuKnG5gZDphuLPDrnuH uc9eiiu1ugfjs73qldcvNpEFLys11GOcxFsBajnnbw0Ifc6O56T2VGE3SPw9FCzOI3Fu UAUiKqq4GYJ7K9FWOvEEVIiI0l5Ps6J8wlMDZqjmsoR6BoHczq2FIHzwMnj0E8CcSh5x LM+A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ki7-20020a170903068700b001a93cb99252si3367963plb.375.2023.04.21.12.04.53; Fri, 21 Apr 2023 12:05:05 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233320AbjDUS7O (ORCPT + 99 others); Fri, 21 Apr 2023 14:59:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232311AbjDUS7M (ORCPT ); Fri, 21 Apr 2023 14:59:12 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D7BB2D4B; Fri, 21 Apr 2023 11:59:11 -0700 (PDT) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1ppvy8-0002kb-09; Fri, 21 Apr 2023 20:58:52 +0200 Date: Fri, 21 Apr 2023 19:58:48 +0100 From: Daniel Golle To: arinc9.unal@gmail.com Cc: Sean Wang , Landen Chao , DENG Qingfang , Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Russell King , =?utf-8?B?QXLEsW7DpyDDnE5BTA==?= , Richard van Schagen , Richard van Schagen , Frank Wunderlich , 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: Re: [RFC PATCH net-next 21/22] net: dsa: mt7530: get rid of useless error returns on phylink code path Message-ID: References: <20230421143648.87889-1-arinc.unal@arinc9.com> <20230421143648.87889-22-arinc.unal@arinc9.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230421143648.87889-22-arinc.unal@arinc9.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 On Fri, Apr 21, 2023 at 05:36:47PM +0300, arinc9.unal@gmail.com wrote: > 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 (on BPi-R3 MT7986A+MT7531AE, BPi-R64 MT7622+MT7531BE and MT7988A rfb) > --- > 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 8ece3d0d820c..3d19e06061cb 100644 > --- a/drivers/net/dsa/mt7530.c > +++ b/drivers/net/dsa/mt7530.c > @@ -2556,7 +2556,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) > { > @@ -2567,22 +2567,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; > @@ -2610,20 +2602,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) > { > @@ -2631,42 +2617,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 * > @@ -2695,30 +2660,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)); > @@ -2811,7 +2764,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: > @@ -2836,9 +2788,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 cad9115de22b..ee2b3d2d6258 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 >