[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6123223eaf54ea6f492c896d81551315a1e38f66.camel@redhat.com>
Date: Tue, 23 Apr 2024 10:40:47 +0200
From: Paolo Abeni <pabeni@...hat.com>
To: Arınç ÜNAL <arinc.unal@...nc9.com>, Daniel
Golle <daniel@...rotopia.org>, DENG Qingfang <dqfext@...il.com>, Sean Wang
<sean.wang@...iatek.com>, Andrew Lunn <andrew@...n.ch>, Florian Fainelli
<f.fainelli@...il.com>, Vladimir Oltean <olteanv@...il.com>, "David S.
Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub
Kicinski <kuba@...nel.org>, Matthias Brugger <matthias.bgg@...il.com>,
AngeloGioacchino Del Regno <angelogioacchino.delregno@...labora.com>
Cc: Bartel Eerdekens <bartel.eerdekens@...stell8.be>,
mithat.guner@...ont.com, erkin.bozoglu@...ont.com, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org
Subject: Re: [PATCH net-next v3 2/2] net: dsa: mt7530: simplify core
operations
On Thu, 2024-04-18 at 08:35 +0300, Arınç ÜNAL wrote:
> The core_rmw() function calls core_read_mmd_indirect() to read the
> requested register, and then calls core_write_mmd_indirect() to write the
> requested value to the register. Because Clause 22 is used to access Clause
> 45 registers, some operations on core_write_mmd_indirect() are
> unnecessarily run. Get rid of core_read_mmd_indirect() and
> core_write_mmd_indirect(), and run only the necessary operations on
> core_write() and core_rmw().
>
> Reviewed-by: Daniel Golle <daniel@...rotopia.org>
> Tested-by: Daniel Golle <daniel@...rotopia.org>
> Signed-off-by: Arınç ÜNAL <arinc.unal@...nc9.com>
> ---
> drivers/net/dsa/mt7530.c | 108 +++++++++++++++++++----------------------------
> 1 file changed, 43 insertions(+), 65 deletions(-)
>
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index 64b1f6320b9a..e0cb194019f8 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
> @@ -74,116 +74,94 @@ static const struct mt7530_mib_desc mt7530_mib[] = {
> MIB_DESC(1, 0xb8, "RxArlDrop"),
> };
>
> -/* Since phy_device has not yet been created and
> - * phy_{read,write}_mmd_indirect is not available, we provide our own
> - * core_{read,write}_mmd_indirect with core_{clear,write,set} wrappers
> - * to complete this function.
> - */
> -static int
> -core_read_mmd_indirect(struct mt7530_priv *priv, int prtad, int devad)
> +static void
> +mt7530_mutex_lock(struct mt7530_priv *priv)
> +{
> + if (priv->bus)
> + mutex_lock_nested(&priv->bus->mdio_lock, MDIO_MUTEX_NESTED);
> +}
> +
> +static void
> +mt7530_mutex_unlock(struct mt7530_priv *priv)
> +{
> + if (priv->bus)
> + mutex_unlock(&priv->bus->mdio_lock);
> +}
> +
> +static void
> +core_write(struct mt7530_priv *priv, u32 reg, u32 val)
> {
> struct mii_bus *bus = priv->bus;
> - int value, ret;
> + int ret;
> +
> + mt7530_mutex_lock(priv);
>
> /* Write the desired MMD Devad */
> ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
> - MII_MMD_CTRL, devad);
> + MII_MMD_CTRL, MDIO_MMD_VEND2);
> if (ret < 0)
> goto err;
>
> /* Write the desired MMD register address */
> ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
> - MII_MMD_DATA, prtad);
> + MII_MMD_DATA, reg);
> if (ret < 0)
> goto err;
>
> /* Select the Function : DATA with no post increment */
> ret = bus->write(bus, MT753X_CTRL_PHY_ADDR(priv->mdiodev->addr),
> - MII_MMD_CTRL, devad | MII_MMD_CTRL_NOINCR);
> + MII_MMD_CTRL, MDIO_MMD_VEND2 | MII_MMD_CTRL_NOINCR);
> if (ret < 0)
> goto err;
What about a possible follow-up, moving the above writes in a separate
helper (say, 'core_select_register' or the like) and reusing it here
and in core_rmw() ?
Not blocking this series, I'm applying it.
Thanks,
Paolo
Powered by blists - more mailing lists