From patchwork Thu Mar 30 15:20:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 77253 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1240150vqo; Thu, 30 Mar 2023 09:09:53 -0700 (PDT) X-Google-Smtp-Source: AKy350YPnJkGChqSWm2niB0oHKd7U+0tKHAvLqGTVMQAc8wtAbl47jlZL3xzECQDNUj8FcKr0jHH X-Received: by 2002:a05:6402:5146:b0:502:1cae:8b11 with SMTP id n6-20020a056402514600b005021cae8b11mr26210195edd.23.1680192593038; Thu, 30 Mar 2023 09:09:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680192593; cv=none; d=google.com; s=arc-20160816; b=s0cTdfqJZDVrR6BLysf4du4WOAghQAY7HTrFEn19olfoysQvSp3UEJfxBQKsostQFd t3OqiNgaWcx47Lq1XWWFH6kJQA3oQ7zC/9nbYyqyRS5D7YTQNAtLkgDJ6j6inhe5enee V7jnW/F8TWCZxsGF7rqUCS+ZiF3XRgapaaBU2OBsPAJwDCFh1kSv90ywissFJKJbpJkt mHuy1W/HRQBTOxXZt+clZ/BCet3XVa7KKWE9V1gMdj4CFOoTAtbOq/IzhheiMl3yBS4U nHTWuDxDw9Z8xaEWUVW5o97h1l27F78x30YONu6OmfDfI5yAJ2iLED7NtYhCn5KW4EYn nWUA== 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=uIIGr54LDDV73P6wHe0w0WubtFz0QfASOO98ZR+p8ac=; b=EfOAAgAPo1qqsRAtdEszEJxMXhmchs/fxMZRrL5Zt1JlRx+NtjdcdLI88fG7LsNjAT TA9/6nQEyC9hdDgVb9BLQVUFCDf6RE9tgNSkKKez0SOCQNHqojKdjfkoN+o1gcMPTMnS bimYK0D9I8ryS/jeJZ3MrjG7J8kELxlBDAV+mO7JjBH50E/XG6yUkwPQd55uo9gDpXAy /2+3Fa0s0fdslOswsE2gTPhAJUUZtCsn43P5HJ0xwMQUTrJnDrOy7USfGkAn+h8VLi7L AsYpL14nhCcqUHrjnQ2JhAhTurpazbWoBS1YZdlLc/W6GdcUHG1pZr+ImyNp65qH4Mpg PaJg== 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 v6-20020aa7cd46000000b004fd21257a30si68844edw.623.2023.03.30.09.09.26; Thu, 30 Mar 2023 09:09:53 -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 S232900AbjC3PV0 (ORCPT + 99 others); Thu, 30 Mar 2023 11:21:26 -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?QXI=?= =?utf-8?b?xLFuw6cgw5xuYWw=?= , 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: 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?1761809628436542072?= X-GMAIL-MSGID: =?utf-8?q?1761809628436542072?= 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,