From patchwork Mon Apr 3 01:17:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 78321 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1999726vqo; Sun, 2 Apr 2023 18:20:41 -0700 (PDT) X-Google-Smtp-Source: AKy350a6/ZrZOdt6DSKRd5sfdewa4DR6oijG7eSpyyyAAL/ShIHx8A9TI6WpnZNpimM94DDEU3c+ X-Received: by 2002:a17:90a:43:b0:23e:f855:79f2 with SMTP id 3-20020a17090a004300b0023ef85579f2mr43497490pjb.12.1680484841389; Sun, 02 Apr 2023 18:20:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680484841; cv=none; d=google.com; s=arc-20160816; b=vfwe0GkZliaKHUahpk4+v2cUb+NiWmwrdxjPALmJGixrKycyaVyRDQwnEzWkJwb4XW fjyujTGKfxh09CiawgE0k9Bjaxb+4kMUK8pnA156E66q4cv5tBqqp4SS3/oeST2/fOvK CycGxF5aaNjYBzrgw6/AMYn+Exf17F+0UdYz0qgQGh13lOsICDp4KduTiOC8SmbZLxB+ knE8hAQuMpPLY30XY7++8UorAhgkzsBwjja8gLNHsl95Zf5tvu0eeHHuDH8QxR74SCqd y7G2CuN1jn9lmckopwla0yZnWt3BzujBkheoUvg7aM2B89jV6XntaRNFyuxw3qVDvfCo jLgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Hj5T5WFF8eU1ogBothxl6/m3GXL3iJV0+9bmKMhS+DE=; b=FUXvF93RQD4jhtjTqfPdfY9l/ycLqLucglBVxIeP2ZcreM8Tx53kfkp7NglvT4FGCU uOx3Dc0whjfxK/tykgk/tYv//+XzlYcSx7nVupHrWbmLdOUSZhWFsopL3rS6ZLwXnq+o 547ANapie90v7mXeSIYeewf72TwSuDsArlxzZ0K9+NCRQjfpP7l0VjW7rHd4lMLUuwH3 6BKaNKtgoa3F6ZlAhoNX9VeuHi1nlrDc0dL66N6dIQKmPIA7utz5O33j0Y9xzYRaXPIP enpk9OFmip/LSd6NLb3p5p2YpW1UD4TY/0GyJFf59ZwLl2eRgfV8aIG6p7TrOEB/ggOm 1tPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nk17-20020a17090b195100b002408d3d8724si11708839pjb.167.2023.04.02.18.20.29; Sun, 02 Apr 2023 18:20:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230522AbjDCBR6 (ORCPT + 99 others); Sun, 2 Apr 2023 21:17:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230488AbjDCBR4 (ORCPT ); Sun, 2 Apr 2023 21:17:56 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52F6EAF3C; Sun, 2 Apr 2023 18:17:48 -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 1pj8pO-0004hA-1f; Mon, 03 Apr 2023 03:17:46 +0200 Date: Mon, 3 Apr 2023 02:17:40 +0100 From: Daniel Golle To: netdev@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Andrew Lunn , 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 , Russell King , =?utf-8?b?QXLEsW7DpyDDnG5hbA==?= Cc: Sam Shih , Lorenzo Bianconi , John Crispin , Felix Fietkau Subject: [PATCH net-next v2 03/14] net: dsa: mt7530: use unlocked regmap accessors Message-ID: <57a3b497841ba5d2e0b2486ea91001c2ccd4c628.1680483896.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=0.0 required=5.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1762116072670434127?= X-GMAIL-MSGID: =?utf-8?q?1762116072670434127?= 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 = context; - *val = mt7530_read(priv, reg); + *val = mt7530_mii_read(priv, reg); return 0; }; @@ -2908,23 +2908,25 @@ static int mt7530_regmap_write(void *context, unsigned int reg, unsigned int val { struct mt7530_priv *priv = context; - mt7530_write(priv, reg, val); + mt7530_mii_write(priv, reg, val); return 0; }; -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 = context; + mutex_lock_nested(mdio_lock, MDIO_MUTEX_NESTED); +} - mt7530_rmw(priv, reg, mask, val); - return 0; -}; +static void +mt7530_mdio_regmap_unlock(void *mdio_lock) +{ + mutex_unlock(mdio_lock); +} static const struct regmap_bus mt7531_regmap_bus = { .reg_write = mt7530_regmap_write, .reg_read = mt7530_regmap_read, - .reg_update_bits = mt7530_regmap_update_bits, }; static int @@ -2950,6 +2952,9 @@ mt7531_create_sgmii(struct mt7530_priv *priv) mt7531_pcs_config[i]->reg_stride = 4; mt7531_pcs_config[i]->reg_base = MT7531_SGMII_REG_BASE(5 + i); mt7531_pcs_config[i]->max_register = 0x17c; + mt7531_pcs_config[i]->lock = mt7530_mdio_regmap_lock; + mt7531_pcs_config[i]->unlock = mt7530_mdio_regmap_unlock; + mt7531_pcs_config[i]->lock_arg = &priv->bus->mdio_lock; regmap = devm_regmap_init(priv->dev, &mt7531_regmap_bus, priv,