Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp832635rwl; Wed, 29 Mar 2023 09:02:52 -0700 (PDT) X-Google-Smtp-Source: AK7set91sHtsng2St55W1OO0HqYxuW8eFsq2LaqkmbERMgtILo0uqCvT2NcfH1klvMfEAOfBmn0V X-Received: by 2002:a05:6a20:8009:b0:da:4be2:caff with SMTP id e9-20020a056a20800900b000da4be2caffmr15684426pza.56.1680105772140; Wed, 29 Mar 2023 09:02:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680105772; cv=none; d=google.com; s=arc-20160816; b=r2IGIs+VZxLZ7i3gHuqpn7me9BIhl3ikZ3O2b4tvmqQ6TEZer8XJFugjtizjAnrhR2 9GZX1QwmZS4mXryS0mcD+C5IoeGdFcla+bwPdzgd8h+reDJlG83j2nj24AdVu8EEp5JS JV8xkPmBTRvoUrVd+aOzQcqdu/7CjK82x7xL2fPmIhQXJHAiSCn4jD7roB9HC+hYIO+g dTbHjddxQE9tQlzdGHdXWI7eXtwagFmDXDLtv9/BdvuyJD0ed5SAwtLw+9MPYEx2WQjL phZNEJEDzFdILllh7o9MyU5hKcsPSNSTIW1iEg5EZyoJ81oBpSHpWZzfz6Zq2PBX1MLy E9jw== 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=J6oly2xRWX9QImtXrd+etwvRvcekLzfKBndnbaLLUFM=; b=EuNxig8lK0jBb5jVvsLsTGsaIkcFAkajtIm+sWkAkXlrvf4CsWP7NAgWX/Vh+xWK9b zhonxEQlAfGy6EwYyaSGUmMiAsZhKI46AnqnF5rkG1iHdjA2T8Gyxja4TraeiOULsMNP 1QE8Firhx8Z3Pk5gjFFqDGlYiIUWPdT8gLjdpATh76on2jPRTPp1FKwpdVTMb8xpbPtz WKupI4ksEtJULixdJ4y4eaYO0BJFjjCOonKnuCZoUEZenEk/OduMX8U93cg277aOCDSr 7+NcIFm+4hbw75Lbw6+c+BTcH7sMbZf0fgTdbTHSp+8pgsp4BhZH1CCN10piMvGFM2PC 3sLw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h191-20020a6383c8000000b004fbd53187ecsi223919pge.258.2023.03.29.09.02.14; Wed, 29 Mar 2023 09:02:52 -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 S231235AbjC2P7f (ORCPT + 99 others); Wed, 29 Mar 2023 11:59:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231262AbjC2P6p (ORCPT ); Wed, 29 Mar 2023 11:58:45 -0400 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C2CF61B6; Wed, 29 Mar 2023 08:58:23 -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 1phYB6-0003Kc-2a; Wed, 29 Mar 2023 17:57:36 +0200 Date: Wed, 29 Mar 2023 16:57:32 +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 Cc: Sam Shih , Lorenzo Bianconi , John Crispin , Felix Fietkau Subject: [RFC PATCH net-next v3 02/15] net: dsa: mt7530: use unlocked regmap accessors Message-ID: <1b79468f3043810ff8ec06a66cf8571738a13f72.1680105013.git.daniel@makrotopia.org> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 Instead of wrapping the locked register accessor functions, use the unlocked variants and add wrappers 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 --- 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 9b88ce5cee5bd..deb0b338b22c2 100644 --- a/drivers/net/dsa/mt7530.c +++ b/drivers/net/dsa/mt7530.c @@ -2899,7 +2899,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; }; @@ -2907,23 +2907,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 @@ -2949,6 +2951,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, -- 2.39.2