From patchwork Sat Jan 28 03:10:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Golle X-Patchwork-Id: 49774 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1167467wrn; Fri, 27 Jan 2023 19:20:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXtIJ+zR0hB2xVGoZNmMgWOLLkVeTQEmJ1Lo6m/fq+RMkS1mPeYGu+bG9i7qIByEV4ccbodZ X-Received: by 2002:a05:6402:520a:b0:49e:a080:d55f with SMTP id s10-20020a056402520a00b0049ea080d55fmr43432057edd.18.1674876041280; Fri, 27 Jan 2023 19:20:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674876041; cv=none; d=google.com; s=arc-20160816; b=pyK45PqiNn1vEmWU8DrOYecdl0s09vyDwj5xyE9qlBqHZ6lpYlDeRma4V30MlZvLgm y8/NpSYB290Mxny6YFCLVZpqEcM5KtcdkNTUzjUB9vmmBfjy888DFYGfcCrrib98CEa7 1KVsOceU+P9WFWvJZsV4S9gY7hcwV/WfIuj03zb3jPl+kd9IKkhY9+m7dvgmSHvIxDhb jL81v2NwwSdqDwAg928AGu/X3O6YudKluAg46Bhl0DAmAr8kwoitQpERJG3itdstSAsf qkR9HsAC0e+5Dh812wAUf8w5+W4DJpXa8nvGrhKXsGdzY6XjzuD+DtKx5JIhHPMsZF/P ku6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date; bh=zybutwiwEWrB+yX6Mwq88YIUZyYTHsYNuvlRNa1Daa0=; b=Th3rY/EjCViwadWIIlhIfuhVcaYuyZ5SiFKT3KgZ/m7A5FczBlZJWfCCqCyFpzEoXW rCxMrcMEpc1e6UCQETJwD+BUKo8DP3ioMiUePUVzy9gVz2ZEhjlTZtdCLe4Mawf9FZbB yw5UV9Eidt6nKAFIJBTiaRhZLlnRAH7D7DV8KQ31spca8k2l7oFK22vvCf2Dz91uHm6m LdU8XuVQQvLQTNnA/TEZsU22Gwbwvgor/apgB6js3qccbwP03VVjEeteYii5PdYzAABu XmUKfbUtKBDRNgMSRMBmCWCTdYPy8ZFCn9uFszyEjtG2jiW9H7nfif3RPI2mXdNgah0B sgWw== 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 z16-20020aa7cf90000000b004a21633babasi2701349edx.315.2023.01.27.19.20.17; Fri, 27 Jan 2023 19:20:41 -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 S232760AbjA1DKR (ORCPT + 99 others); Fri, 27 Jan 2023 22:10:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229619AbjA1DKQ (ORCPT ); Fri, 27 Jan 2023 22:10:16 -0500 Received: from fudo.makrotopia.org (fudo.makrotopia.org [IPv6:2a07:2ec0:3002::71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B15017E6B6 for ; Fri, 27 Jan 2023 19:10:15 -0800 (PST) Received: from local by fudo.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.96) (envelope-from ) id 1pLbbX-0006aV-1K; Sat, 28 Jan 2023 04:10:11 +0100 Date: Sat, 28 Jan 2023 03:10:01 +0000 From: Daniel Golle To: linux-kernel@vger.kernel.org, Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , Colin Foster Subject: [PATCH] regmap: apply reg_base and reg_downshift for single register ops Message-ID: <5355a99496d764a7918f0eaf801fab7c9a3f5a98.1674875341.git.daniel@makrotopia.org> MIME-Version: 1.0 Content-Disposition: inline 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: 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?1756234820060323100?= reg_base and reg_downshift currently don't have any effect if used with simple single register operations. Fix that by taking them into account also for _reg_read, _reg_write and _reg_update_bits (they may still be missing also in other place, eg. page selection code). 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 --- drivers/base/regmap/regmap.c | 6 ++++++ 1 file changed, 6 insertions(+) base-commit: e2f86c02fdc96ca29ced53221a3cbf50aa6f8b49 diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index d12d669157f24..7b8386ec21b8c 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1986,6 +1986,8 @@ int _regmap_write(struct regmap *map, unsigned int reg, } } + reg += map->reg_base; + reg >>= map->format.reg_downshift; ret = map->reg_write(context, reg, val); if (ret == 0) { if (regmap_should_log(map)) @@ -2879,6 +2881,8 @@ static int _regmap_read(struct regmap *map, unsigned int reg, if (!regmap_readable(map, reg)) return -EIO; + reg += map->reg_base; + reg >>= map->format.reg_downshift; ret = map->reg_read(context, reg, val); if (ret == 0) { if (regmap_should_log(map)) @@ -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;