From nobody Sat Sep 21 02:48:36 2024 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1D82C77B62 for ; Thu, 30 Mar 2023 15:21:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232903AbjC3PV1 (ORCPT ); Thu, 30 Mar 2023 11:21:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232875AbjC3PVW (ORCPT ); Thu, 30 Mar 2023 11:21:22 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BFBDD33F; Thu, 30 Mar 2023 08:20:17 -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 1phu4P-0006b7-1L; Thu, 30 Mar 2023 17:20:09 +0200 Date: Thu, 30 Mar 2023 16:20:05 +0100 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux@armlinux.org.uk, linux-kernel@vger.kernel.org, Andrew Lunn , =?utf-8?B?QXLEsW7DpyDDnG5hbA==?= , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Sean Wang , Landen Chao , DENG Qingfang , Philipp Zabel Cc: Sam Shih , Lorenzo Bianconi , John Crispin , Felix Fietkau Subject: [PATCH net-next 03/15] net: dsa: mt7530: use unlocked regmap accessors Message-ID: <4fcca663d13c38679b615d4a1a76bf5d5d885304.1680180959.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Instead of wrapping the locked register accessor functions, use the unlocked variants and add locking wrapper functions to let regmap handle the locking. This is a preparation towards being able to always use regmap to access switch registers instead of open-coded accessor functions. Signed-off-by: Daniel Golle Reviewed-by: Andrew Lunn --- drivers/net/dsa/mt7530.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c index 5685c71bc9173..d8b041d79f2b7 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2900,7 +2900,7 @@ static int mt7530_regmap_read(void *context, unsigned= int reg, unsigned int *val { struct mt7530_priv *priv =3D context; =20 - *val =3D mt7530_read(priv, reg); + *val =3D mt7530_mii_read(priv, reg); return 0; }; =20 @@ -2908,23 +2908,25 @@ static int mt7530_regmap_write(void *context, unsig= ned int reg, unsigned int val { struct mt7530_priv *priv =3D context; =20 - mt7530_write(priv, reg, val); + mt7530_mii_write(priv, reg, val); return 0; }; =20 -static int mt7530_regmap_update_bits(void *context, unsigned int reg, - unsigned int mask, unsigned int val) +static void +mt7530_mdio_regmap_lock(void *mdio_lock) { - struct mt7530_priv *priv =3D context; + mutex_lock_nested(mdio_lock, MDIO_MUTEX_NESTED); +} =20 - mt7530_rmw(priv, reg, mask, val); - return 0; -}; +static void +mt7530_mdio_regmap_unlock(void *mdio_lock) +{ + mutex_unlock(mdio_lock); +} =20 static const struct regmap_bus mt7531_regmap_bus =3D { .reg_write =3D mt7530_regmap_write, .reg_read =3D mt7530_regmap_read, - .reg_update_bits =3D mt7530_regmap_update_bits, }; =20 static int @@ -2950,6 +2952,9 @@ mt7531_create_sgmii(struct mt7530_priv *priv) mt7531_pcs_config[i]->reg_stride =3D 4; mt7531_pcs_config[i]->reg_base =3D MT7531_SGMII_REG_BASE(5 + i); mt7531_pcs_config[i]->max_register =3D 0x17c; + mt7531_pcs_config[i]->lock =3D mt7530_mdio_regmap_lock; + mt7531_pcs_config[i]->unlock =3D mt7530_mdio_regmap_unlock; + mt7531_pcs_config[i]->lock_arg =3D &priv->bus->mdio_lock; =20 regmap =3D devm_regmap_init(priv->dev, &mt7531_regmap_bus, priv, --=20 2.39.2