From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Christian Marangi <ansuelsmth@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
Florian Fainelli <f.fainelli@gmail.com>,
Vladimir Oltean <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Heiner Kallweit <hkallweit1@gmail.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
upstream@airoha.com
Subject: Re: [net-next PATCH v3 3/3] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY
Date: Fri, 8 Nov 2024 11:09:30 +0000 [thread overview]
Message-ID: <Zy3xaviqqT6X8Ows@shell.armlinux.org.uk> (raw)
In-Reply-To: <20241106122254.13228-4-ansuelsmth@gmail.com>
On Wed, Nov 06, 2024 at 01:22:38PM +0100, Christian Marangi wrote:
> +/* MII Registers Page 1 */
> +#define AN8855_PHY_EXT_REG_14 0x14
> +#define AN8855_PHY_EN_DOWN_SHFIT BIT(4)
Shouldn't "AN8855_PHY_EN_DOWN_SHFIT" be "AN8855_PHY_EN_DOWN_SHIFT"
(notice the I and F are swapped) ?
> +static int an8855_get_downshift(struct phy_device *phydev, u8 *data)
> +{
> + int saved_page;
> + int val;
> + int ret;
> +
> + saved_page = phy_select_page(phydev, AN8855_PHY_PAGE_EXTENDED_1);
> + if (saved_page >= 0)
> + val = __phy_read(phydev, AN8855_PHY_EXT_REG_14);
> + ret = phy_restore_page(phydev, saved_page, val);
> + if (ret)
> + return ret;
This function is entirely broken.
phy_restore_page() will return "val" if everything went successfully,
so here you end up returning "val" via this very return statement
without executing any further code in the function. The only time
further code will be executed is if "val" was successfully read as
zero.
Please use the helpers provided:
ret = phy_read_paged(phydev, AN8855_PHY_PAGE_EXTENDED_1,
AN8855_PHY_EXT_REG_14);
if (ret < 0)
return ret;
ret now contains what you're using as "val" below. No need to open code
phy_read_paged().
> +
> + *data = val & AN8855_PHY_EXT_REG_14 ? DOWNSHIFT_DEV_DEFAULT_COUNT :
> + DOWNSHIFT_DEV_DISABLE;
Here, the test is against the register number rather than the bit that
controls downshift. Shouldn't AN8855_PHY_EXT_REG_14 be
AN8855_PHY_EN_DOWN_SH(F)I(F)T ?
> +static int an8855_set_downshift(struct phy_device *phydev, u8 cnt)
> +{
> + int saved_page;
> + int ret;
> +
> + saved_page = phy_select_page(phydev, AN8855_PHY_PAGE_EXTENDED_1);
> + if (saved_page >= 0) {
> + if (cnt != DOWNSHIFT_DEV_DISABLE)
> + ret = __phy_set_bits(phydev, AN8855_PHY_EXT_REG_14,
> + AN8855_PHY_EN_DOWN_SHFIT);
> + else
> + ret = __phy_clear_bits(phydev, AN8855_PHY_EXT_REG_14,
> + AN8855_PHY_EN_DOWN_SHFIT);
> + }
> +
> + return phy_restore_page(phydev, saved_page, ret);
This entire thing can be simplified to:
u16 ds = cnt != DOWNSHIFT_DEV_DISABLE ? AN8855_PHY_EN_DOWN_SHFIT: 0;
return phy_modify_paged(phydev, AN8855_PHY_PAGE_EXTENDED_1,
AN8855_PHY_EXT_REG_14, AN8855_PHY_EN_DOWN_SHFIT,
ds);
Thanks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
next prev parent reply other threads:[~2024-11-08 11:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-06 12:22 [net-next PATCH v3 0/3] net: dsa: Add Airoha AN8855 support Christian Marangi
2024-11-06 12:22 ` [net-next PATCH v3 1/3] dt-bindings: net: dsa: Add Airoha AN8855 Gigabit Switch documentation Christian Marangi
2024-11-06 12:22 ` [net-next PATCH v3 2/3] net: dsa: Add Airoha AN8855 5-Port Gigabit DSA Switch driver Christian Marangi
2024-11-07 17:53 ` Christophe JAILLET
2024-11-07 19:36 ` Andrew Lunn
2024-11-08 10:32 ` Christian Marangi
2024-11-08 10:51 ` Russell King (Oracle)
2024-11-06 12:22 ` [net-next PATCH v3 3/3] net: phy: Add Airoha AN8855 Internal Switch Gigabit PHY Christian Marangi
2024-11-06 14:54 ` Maxime Chevallier
2024-11-06 18:04 ` Christian Marangi
2024-11-06 16:19 ` Andrew Lunn
2024-11-06 18:11 ` Christian Marangi
2024-11-07 2:37 ` kernel test robot
2024-11-08 11:09 ` Russell King (Oracle) [this message]
2024-11-08 13:09 ` 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=Zy3xaviqqT6X8Ows@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=andrew@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=upstream@airoha.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).