Message ID | Y9clyVS3tQEHlUhA@makrotopia.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1968822wrn; Sun, 29 Jan 2023 18:14:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXvnlch5R40/lIaV5UHn67cxriSulfxS/K0FJOS9eHyR4pt10vdEg/ljGXKgODeeKrhCldwf X-Received: by 2002:a17:90a:1a:b0:22b:bcae:d6e2 with SMTP id 26-20020a17090a001a00b0022bbcaed6e2mr35429219pja.10.1675044857395; Sun, 29 Jan 2023 18:14:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675044857; cv=none; d=google.com; s=arc-20160816; b=Z/xncEJisq3MrpyyQG1ThEnsrtYmH/N9W5mqpgRrnrNz8q+fuWe/sWykJ5N2rj49wd UP7Enj2DzKIRIC8ncZcS351CGbKSie2WuqrTPfkapl+XSeEsBSxSYSSs7siAb5TGp2yI tsIUZB7jT3wkhmmFqn9zIzgJLIFzq1jhOBgPYCHT5wagCyapOum73zaaBt/f7aVaMXTc Pz6/hZWIXbp0/H5aUlLL2+fa17mTPggnDE/dIFEbNi5IQYzyB+2kJU8lefk3ow39YNLb Awi/m205oOEFD5Wb00wTFTu/jk4KwdLmTdFBCsWmnQKHuHxXlcF4yf94CfW5VDakNh/9 kJbQ== 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:to:from:date; bh=IzOKznPXRzmHZrqPL/+c31bn1e9m5Wy747jQtQUZ3QY=; b=n/tTopM+5JqILbTRu/EsfGv5b/DDANZk3N4NfDQ+VCs24cVqjYKqB/vN4ZGNh1pIzd ylY1AjGzwBcffEHcl3FLTAvo7tvM/WwXeuMffKpJRylF95GnTF5289mjL3aLCeIe0cE3 hoOOICsJEmXOUGRHsLg4mO8viojAF8NGoGnjKCaJ5iwiqIRUxFdvI+eM4rC0OlT28Elx ZnYkX7BrhgA5kjr8N2Orcs7LPc/WIneOD5QQlVN+pmc482LvPklNefHBGJVaUJd3wsxz ZrGbOUJqm6E0YLTahX1MoOcW77E9v1L3Sh1TF19g7L7fl9HjlpJST7T4j28upUZyeKbV mNMg== 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 i198-20020a636dcf000000b004da13f2c14esi11526638pgc.710.2023.01.29.18.14.02; Sun, 29 Jan 2023 18:14:17 -0800 (PST) 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 S235412AbjA3CFO (ORCPT <rfc822;n2h9z4@gmail.com> + 99 others); Sun, 29 Jan 2023 21:05:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235407AbjA3CFN (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 29 Jan 2023 21:05:13 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4019E4226 for <linux-kernel@vger.kernel.org>; Sun, 29 Jan 2023 18:05:11 -0800 (PST) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from <daniel@makrotopia.org>) id 1pMJXg-0007Ev-0U; Mon, 30 Jan 2023 03:05:08 +0100 Date: Mon, 30 Jan 2023 02:04:57 +0000 From: Daniel Golle <daniel@makrotopia.org> To: Colin Foster <colin.foster@in-advantage.com>, linux-kernel@vger.kernel.org, Mark Brown <broonie@kernel.org>, "Rafael J. Wysocki" <rafael@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Subject: [RFC PATCH v2] regmap: apply reg_base and reg_downshift for single register ops Message-ID: <Y9clyVS3tQEHlUhA@makrotopia.org> References: <Y9WAPBYaLMsCbQN6@euler> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <Y9WAPBYaLMsCbQN6@euler> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756234820060323100?= X-GMAIL-MSGID: =?utf-8?q?1756411836390837250?= |
Series |
[RFC,v2] regmap: apply reg_base and reg_downshift for single register ops
|
|
Commit Message
Daniel Golle
Jan. 30, 2023, 2:04 a.m. UTC
reg_base and reg_downshift currently don't have any effect if used with
a regmap_bus or regmap_config which only offers single register
operations (ie. reg_read, reg_write and optionally reg_update_bits).
Fix that and take them into account also for regmap_bus with only
reg_read and read_write operations by applying reg_base and
reg_downshift in _regmap_bus_reg_write, _regmap_bus_reg_read.
Also apply reg_base and reg_downshift in _regmap_update_bits, but only
in case the operation is carried out with a reg_update_bits call
defined in either regmap_bus or regmap_config.
Fixes: 0074f3f2b1e43d ("regmap: allow a defined reg_base to be added to every address")
Fixes: 86fc59ef818beb ("regmap: add configurable downshift for addresses")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
I hope that I didn't miss anything there...
@Colin Please let me know if this breaks anything with your ocelot_spi
use-case.
drivers/base/regmap/regmap.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
Hi Daniel, On Mon, Jan 30, 2023 at 02:04:57AM +0000, Daniel Golle wrote: > reg_base and reg_downshift currently don't have any effect if used with > a regmap_bus or regmap_config which only offers single register > operations (ie. reg_read, reg_write and optionally reg_update_bits). > > Fix that and take them into account also for regmap_bus with only > reg_read and read_write operations by applying reg_base and > reg_downshift in _regmap_bus_reg_write, _regmap_bus_reg_read. > > Also apply reg_base and reg_downshift in _regmap_update_bits, but only > in case the operation is carried out with a reg_update_bits call > defined in either regmap_bus or regmap_config. > > Fixes: 0074f3f2b1e43d ("regmap: allow a defined reg_base to be added to every address") > Fixes: 86fc59ef818beb ("regmap: add configurable downshift for addresses") > Signed-off-by: Daniel Golle <daniel@makrotopia.org> > --- > I hope that I didn't miss anything there... > > @Colin Please let me know if this breaks anything with your ocelot_spi > use-case. I see we're working on similar things! (DSA hardware, that is) This patch works for me. I don't konw if there's any value in back-porting it to affected kernels, as ocelot_spi is the only user as far as I can tell. (wishing I called it something more greppable than 'reg_base') Tested-by: Colin Foster <colin.foster@in-advantage.com> > > drivers/base/regmap/regmap.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c > index d12d669157f24..d2a54eb0efd9b 100644 > --- a/drivers/base/regmap/regmap.c > +++ b/drivers/base/regmap/regmap.c > @@ -1942,6 +1942,8 @@ static int _regmap_bus_reg_write(void *context, unsigned int reg, > { > struct regmap *map = context; > > + reg += map->reg_base; > + reg >>= map->format.reg_downshift; > return map->bus->reg_write(map->bus_context, reg, val); > } > > @@ -2840,6 +2842,8 @@ static int _regmap_bus_reg_read(void *context, unsigned int reg, > { > struct regmap *map = context; > > + reg += map->reg_base; > + reg >>= map->format.reg_downshift; > return map->bus->reg_read(map->bus_context, reg, val); > } > > @@ -3231,6 +3235,8 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg, > *change = false; > > if (regmap_volatile(map, reg) && map->reg_update_bits) { > + reg += map->reg_base; > + reg >>= map->format.reg_downshift; > ret = map->reg_update_bits(map->bus_context, reg, mask, val); > if (ret == 0 && change) > *change = true; > -- > 2.39.1 >
On Mon, 30 Jan 2023 02:04:57 +0000, Daniel Golle wrote: > reg_base and reg_downshift currently don't have any effect if used with > a regmap_bus or regmap_config which only offers single register > operations (ie. reg_read, reg_write and optionally reg_update_bits). > > Fix that and take them into account also for regmap_bus with only > reg_read and read_write operations by applying reg_base and > reg_downshift in _regmap_bus_reg_write, _regmap_bus_reg_read. > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next Thanks! [1/1] regmap: apply reg_base and reg_downshift for single register ops commit: 697c3892d825fb78f42ec8e53bed065dd728db3e All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index d12d669157f24..d2a54eb0efd9b 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1942,6 +1942,8 @@ static int _regmap_bus_reg_write(void *context, unsigned int reg, { struct regmap *map = context; + reg += map->reg_base; + reg >>= map->format.reg_downshift; return map->bus->reg_write(map->bus_context, reg, val); } @@ -2840,6 +2842,8 @@ static int _regmap_bus_reg_read(void *context, unsigned int reg, { struct regmap *map = context; + reg += map->reg_base; + reg >>= map->format.reg_downshift; return map->bus->reg_read(map->bus_context, reg, val); } @@ -3231,6 +3235,8 @@ static int _regmap_update_bits(struct regmap *map, unsigned int reg, *change = false; if (regmap_volatile(map, reg) && map->reg_update_bits) { + reg += map->reg_base; + reg >>= map->format.reg_downshift; ret = map->reg_update_bits(map->bus_context, reg, mask, val); if (ret == 0 && change) *change = true;