From: Jakub Kicinski <kuba@kernel.org>
To: Landen Chao <landen.chao@mediatek.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Vivien Didelot <vivien.didelot@gmail.com>,
Florian Fainelli <f.fainelli@gmail.com>,
"David S . Miller" <davem@davemloft.net>,
Rob Herring <robh+dt@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
Sean Wang <sean.wang@mediatek.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
Russell King <linux@armlinux.org.uk>, <netdev@vger.kernel.org>,
<devicetree@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
<linux-mediatek@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <frank-w@public-files.de>,
<opensource@vdorst.com>, <dqfext@gmail.com>
Subject: Re: [PATCH net-next v3 2/6] net: dsa: mt7530: Extend device data ready for adding a new hardware
Date: Sat, 5 Sep 2020 16:47:02 -0700 [thread overview]
Message-ID: <20200905164702.72edf26c@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> (raw)
In-Reply-To: <3cf9909d7b06346b8aa339c346e19585cccf74c8.1599228079.git.landen.chao@mediatek.com>
On Fri, 4 Sep 2020 22:21:57 +0800 Landen Chao wrote:
> +static bool
> +mt7530_phy_mode_supported(struct dsa_switch *ds, int port,
> + const struct phylink_link_state *state)
> {
> struct mt7530_priv *priv = ds->priv;
> - u32 mcr_cur, mcr_new;
>
> switch (port) {
> case 0: /* Internal phy */
> @@ -1363,33 +1364,114 @@ static void mt7530_phylink_mac_config(struct dsa_switch *ds, int port,
> case 3:
> case 4:
> if (state->interface != PHY_INTERFACE_MODE_GMII)
> - return;
> + goto unsupported;
return false;
Jumping to a label which does nothing but returns makes the code less
readable.
> break;
> case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
> - if (priv->p5_interface == state->interface)
> - break;
> if (!phy_interface_mode_is_rgmii(state->interface) &&
> state->interface != PHY_INTERFACE_MODE_MII &&
> state->interface != PHY_INTERFACE_MODE_GMII)
> - return;
> + goto unsupported;
> + break;
> + case 6: /* 1st cpu port */
> + if (state->interface != PHY_INTERFACE_MODE_RGMII &&
> + state->interface != PHY_INTERFACE_MODE_TRGMII)
> + goto unsupported;
> + break;
> + default:
> + dev_err(priv->dev, "%s: unsupported port: %i\n", __func__,
> + port);
> + goto unsupported;
> + }
> +
> + return true;
> +
> +unsupported:
> + return false;
> +}
> +static void
> +mt753x_phylink_mac_config(struct dsa_switch *ds, int port, unsigned int mode,
> + const struct phylink_link_state *state)
> +{
> + struct mt7530_priv *priv = ds->priv;
> + u32 mcr_cur, mcr_new;
> +
> + if (!mt753x_phy_mode_supported(ds, port, state))
> + goto unsupported;
> +
> + switch (port) {
> + case 0: /* Internal phy */
> + case 1:
> + case 2:
> + case 3:
> + case 4:
case 0 ... 4:
> + if (state->interface != PHY_INTERFACE_MODE_GMII)
> + goto unsupported;
> + break;
> + case 5: /* 2nd cpu port with phy of port 0 or 4 / external phy */
> + if (priv->p5_interface == state->interface)
> + break;
> +static void
> +mt753x_phylink_validate(struct dsa_switch *ds, int port,
> + unsigned long *supported,
> + struct phylink_link_state *state)
> +{
> + struct mt7530_priv *priv = ds->priv;
> __ETHTOOL_DECLARE_LINK_MODE_MASK(mask) = { 0, };
Please keep the variables longest to shortest (reverse xmas tree).
next prev parent reply other threads:[~2020-09-05 23:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 14:21 [PATCH net-next v3 0/6] net-next: dsa: mt7530: add support for MT7531 Landen Chao
2020-09-04 14:21 ` [PATCH net-next v3 1/6] net: dsa: mt7530: Refine message in Kconfig Landen Chao
2020-09-04 14:21 ` [PATCH net-next v3 2/6] net: dsa: mt7530: Extend device data ready for adding a new hardware Landen Chao
2020-09-05 23:47 ` Jakub Kicinski [this message]
2020-09-04 14:21 ` [PATCH net-next v3 3/6] dt-bindings: net: dsa: add new MT7531 binding to support MT7531 Landen Chao
2020-09-05 23:37 ` Jakub Kicinski
2020-09-04 14:21 ` [PATCH net-next v3 4/6] net: dsa: mt7530: Add the support of MT7531 switch Landen Chao
2020-09-05 23:50 ` Jakub Kicinski
2020-09-04 14:22 ` [PATCH net-next v3 5/6] arm64: dts: mt7622: add mt7531 dsa to mt7622-rfb1 board Landen Chao
2020-09-04 14:22 ` [PATCH net-next v3 6/6] arm64: dts: mt7622: add mt7531 dsa to bananapi-bpi-r64 board Landen Chao
2020-09-05 8:45 ` Aw: [PATCH net-next v3 0/6] net-next: dsa: mt7530: add support for MT7531 Frank Wunderlich
2020-09-07 8:49 ` Frank Wunderlich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200905164702.72edf26c@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com \
--to=kuba@kernel.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=dqfext@gmail.com \
--cc=f.fainelli@gmail.com \
--cc=frank-w@public-files.de \
--cc=landen.chao@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux@armlinux.org.uk \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=opensource@vdorst.com \
--cc=p.zabel@pengutronix.de \
--cc=robh+dt@kernel.org \
--cc=sean.wang@mediatek.com \
--cc=vivien.didelot@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).