From: Christian Marangi <ansuelsmth@gmail.com>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Andrew Lunn <andrew@lunn.ch>,
Heiner Kallweit <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
linux-arm-msm@vger.kernel.org
Subject: Re: [net-next PATCH 09/14] net: phy: at803x: remove specific qca808x check from at803x functions
Date: Wed, 29 Nov 2023 10:49:13 +0100 [thread overview]
Message-ID: <6567091b.050a0220.44fc8.41fb@mx.google.com> (raw)
In-Reply-To: <ZWcHzAXyIl++F1Sm@shell.armlinux.org.uk>
On Wed, Nov 29, 2023 at 09:43:40AM +0000, Russell King (Oracle) wrote:
> On Wed, Nov 29, 2023 at 03:12:14AM +0100, Christian Marangi wrote:
> > Remove specific qca808x check from at803x generic functions.
> >
> > While this cause a bit of code duplication, this is needed in
> > preparation for splitting the driver per PHY family and detaching
> > qca808x specific bits from the at803x driver.
> >
> > Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
> > ---
> > drivers/net/phy/at803x.c | 107 ++++++++++++++++++++++++++-------------
> > 1 file changed, 71 insertions(+), 36 deletions(-)
> >
> > diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> > index 8f5878ccb1a8..475b96165f45 100644
> > --- a/drivers/net/phy/at803x.c
> > +++ b/drivers/net/phy/at803x.c
> > @@ -1043,24 +1043,6 @@ static int at803x_config_aneg(struct phy_device *phydev)
> > */
> > ret = 0;
>
> Doesn't this become unnecessary?
> >
> > - if (phydev->drv->phy_id == QCA8081_PHY_ID) {
> > - int phy_ctrl = 0;
> > -
> > - /* The reg MII_BMCR also needs to be configured for force mode, the
> > - * genphy_config_aneg is also needed.
> > - */
> > - if (phydev->autoneg == AUTONEG_DISABLE)
> > - genphy_c45_pma_setup_forced(phydev);
> > -
> > - if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising))
> > - phy_ctrl = MDIO_AN_10GBT_CTRL_ADV2_5G;
> > -
> > - ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
> > - MDIO_AN_10GBT_CTRL_ADV2_5G, phy_ctrl);
> > - if (ret < 0)
> > - return ret;
> > - }
> > -
> > return __genphy_config_aneg(phydev, ret);
>
> ... since you can just call genphy_config_aneg() here now?
>
> > @@ -1845,6 +1815,47 @@ static int qca8327_suspend(struct phy_device *phydev)
> > return qca83xx_suspend(phydev);
> > }
> >
> > +static int qca808x_config_aneg(struct phy_device *phydev)
> > +{
> > + int phy_ctrl = 0;
> > + int ret;
> > +
> > + ret = at803x_config_mdix(phydev, phydev->mdix_ctrl);
> > + if (ret < 0)
> > + return ret;
> > +
> > + /* Changes of the midx bits are disruptive to the normal operation;
> > + * therefore any changes to these registers must be followed by a
> > + * software reset to take effect.
> > + */
> > + if (ret == 1) {
> > + ret = genphy_soft_reset(phydev);
> > + if (ret < 0)
> > + return ret;
> > + }
> > +
> > + /* Do not restart auto-negotiation by setting ret to 0 defautly,
> > + * when calling __genphy_config_aneg later.
> > + */
> > + ret = 0;
> > +
> > + /* The reg MII_BMCR also needs to be configured for force mode, the
> > + * genphy_config_aneg is also needed.
> > + */
> > + if (phydev->autoneg == AUTONEG_DISABLE)
> > + genphy_c45_pma_setup_forced(phydev);
> > +
> > + if (linkmode_test_bit(ETHTOOL_LINK_MODE_2500baseT_Full_BIT, phydev->advertising))
> > + phy_ctrl = MDIO_AN_10GBT_CTRL_ADV2_5G;
> > +
> > + ret = phy_modify_mmd_changed(phydev, MDIO_MMD_AN, MDIO_AN_10GBT_CTRL,
> > + MDIO_AN_10GBT_CTRL_ADV2_5G, phy_ctrl);
> > + if (ret < 0)
> > + return ret;
> > +
> > + return __genphy_config_aneg(phydev, ret);
> > +}
>
> ... but is it _really_ worth duplicating the entire function just to
> deal with the QCA8081 difference? On balance, I think the original code
> is better.
>
> Overall, I'm getting the impression that you have a mental hang-up about
> drivers checking the PHY ID in their method drivers... there's
> absolutely nothing wrong with that. When the result of trying to
> eliminate those results in bloating a driver, then the cleanup is not
> a cleanup anymore, it creates bloat and makes future maintenance
> harder.
For some AT803x ID it might be O.K. but here we are mixing all kind of
thing and you already noticing the state of this driver with the priv
changes. Again it's all to facilitate the last 2 patch of this series.
>
> Sorry, but no, I don't like this patch.
--
Ansuel
next prev parent reply other threads:[~2023-11-29 9:50 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 2:12 [net-next PATCH 00/14] net: phy: at803x: cleanup + split Christian Marangi
2023-11-29 2:12 ` [net-next PATCH 01/14] net: phy: at803x: fix passing the wrong reference for config_intr Christian Marangi
2023-11-30 14:50 ` Andrew Lunn
2023-11-29 2:12 ` [net-next PATCH 02/14] net: phy: at803x: move disable WOL for 8031 from probe to config Christian Marangi
2023-11-29 9:24 ` Russell King (Oracle)
2023-11-29 9:36 ` Christian Marangi
2023-11-29 10:45 ` Russell King (Oracle)
2023-11-29 11:03 ` Christian Marangi
2023-11-29 11:09 ` Russell King (Oracle)
2023-11-30 14:58 ` Andrew Lunn
2023-11-29 2:12 ` [net-next PATCH 03/14] net: phy: at803x: raname hw_stats functions to qca83xx specific name Christian Marangi
2023-11-30 14:59 ` Andrew Lunn
2023-11-29 2:12 ` [net-next PATCH 04/14] net: phy: at803x: move qca83xx stats out of generic at803x_priv struct Christian Marangi
2023-11-29 9:29 ` Russell King (Oracle)
2023-11-29 9:38 ` Christian Marangi
2023-11-30 15:09 ` Andrew Lunn
2023-11-29 2:12 ` [net-next PATCH 05/14] net: phy: at803x: move qca83xx specific check in dedicated functions Christian Marangi
2023-11-30 15:14 ` Andrew Lunn
2023-11-29 2:12 ` [net-next PATCH 06/14] net: phy: at803x: move at8031 specific data out of generic at803x_priv Christian Marangi
2023-11-29 9:35 ` Russell King (Oracle)
2023-11-29 11:08 ` Christian Marangi
2023-11-29 11:31 ` Russell King (Oracle)
2023-11-30 15:21 ` Andrew Lunn
2023-11-30 19:38 ` Christian Marangi
2023-11-30 20:14 ` Andrew Lunn
2023-11-30 20:24 ` Christian Marangi
2023-11-29 2:12 ` [net-next PATCH 07/14] net: phy: at803x: move at8035 specific DT parse to dedicated probe Christian Marangi
2023-11-30 15:29 ` Andrew Lunn
2023-11-29 2:12 ` [net-next PATCH 08/14] net: phy: at803x: drop specific PHY id check from cable test functions Christian Marangi
2023-11-29 9:38 ` Russell King (Oracle)
2023-11-29 9:47 ` Christian Marangi
2023-11-29 10:57 ` Russell King (Oracle)
2023-11-29 11:04 ` Christian Marangi
2023-11-29 11:07 ` Russell King (Oracle)
2023-11-29 2:12 ` [net-next PATCH 09/14] net: phy: at803x: remove specific qca808x check from at803x functions Christian Marangi
2023-11-29 9:43 ` Russell King (Oracle)
2023-11-29 9:49 ` Christian Marangi [this message]
2023-11-29 2:12 ` [net-next PATCH 10/14] net: phy: at803x: drop usless probe for qca8081 PHY Christian Marangi
2023-11-29 9:44 ` Russell King (Oracle)
2023-11-29 9:51 ` Christian Marangi
2023-11-29 2:12 ` [net-next PATCH 11/14] net: phy: at803x: make specific status mask more generic Christian Marangi
2023-11-29 2:12 ` [net-next PATCH 12/14] net: phy: move at803x PHY driver to dedicated directory Christian Marangi
2023-11-29 2:12 ` [net-next PATCH 13/14] net: phy: qcom: deatch qca83xx PHY driver from at803x Christian Marangi
2023-11-29 9:53 ` Russell King (Oracle)
2023-11-29 10:37 ` Christian Marangi
2023-11-29 11:20 ` Russell King (Oracle)
2023-11-29 11:21 ` Christian Marangi
2023-11-29 2:12 ` [net-next PATCH 14/14] net: phy: qcom: detach qca808x " Christian Marangi
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=6567091b.050a0220.44fc8.41fb@mx.google.com \
--to=ansuelsmth@gmail.com \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hkallweit1@gmail.com \
--cc=konrad.dybcio@linaro.org \
--cc=kuba@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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