From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 68230CD37AB for ; Tue, 3 Sep 2024 18:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=FTqTyrECFvbLD17NBUWn4/583otSS6XLuEd+TP20G+I=; b=lwXfR4jCU0+sa30LDR1Yx0qccA h+pG+HZ1M85L1Bd6iS1KxqE4/4xbnpY7vMXWzZK+AVwHUESx6xX+hSO4I7/ivagJeFxelTcI95VHb MXBS9ixOA7N/qAJY7RXrUyfRkc1jWIkgh+k/ELkIdnl4MIhAQZEzPzXhp6MCHnwo1myhGIBPbUUae j9cVGyg4k/VvNH/piEcjdI3hICRVKZWQxftsAlFwCkNNhurt8b7A8Ogd2IJIraBoNBLFx55fqN9nI aUtHfqOvmMqiO/mNsRpqrdUCjYAKrTDK/FYMmCxinSZczttm2l85v1wlVMRmvtPJXBeGHFKC8aqql SFZYGwiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slYae-00000001Vo7-0xis; Tue, 03 Sep 2024 18:49:20 +0000 Received: from lelv0142.ext.ti.com ([198.47.23.249]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slYYk-00000001VGV-38Nh for linux-arm-kernel@lists.infradead.org; Tue, 03 Sep 2024 18:47:24 +0000 Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id 483IlD8l014660; Tue, 3 Sep 2024 13:47:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1725389233; bh=FTqTyrECFvbLD17NBUWn4/583otSS6XLuEd+TP20G+I=; h=From:To:CC:Subject:Date; b=Y4JsSm1q5fFCVCyu7U7R/zp9O4h3Ge7Fo9rsYjLUds7t3Lip38a0++nzk0EsGTzj4 Mvi107htYdS9aBxknJ/fuzpXEAh5W8pfgPSjpCOBqi386Kp04mRnyFuCeoZ35Tw124 E/zsKSKZWmnL8OSn3R9bOvssyvBipDhTrfcyPtYo= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTP id 483IlDLW008470; Tue, 3 Sep 2024 13:47:13 -0500 Received: from DLEE100.ent.ti.com (157.170.170.30) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Tue, 3 Sep 2024 13:47:12 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Tue, 3 Sep 2024 13:47:12 -0500 Received: from localhost (uda0133052.dhcp.ti.com [128.247.81.232]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 483IlCbZ127692; Tue, 3 Sep 2024 13:47:12 -0500 From: Nishanth Menon To: Lee Jones CC: Arnd Bergmann , , , Nishanth Menon , Mark Brown , Shawn Guo , , Bjorn Andersson , , Florian Fainelli , , Alexandre Torgue Subject: [PATCH V2] mfd: syscon: Use regmap max_register_is_0 as needed Date: Tue, 3 Sep 2024 13:47:10 -0500 Message-ID: <20240903184710.1552067-1-nm@ti.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Organization: Texas Instruments, Inc. Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240903_114722_998758_7347DA0A X-CRM114-Status: GOOD ( 14.74 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org syscon has always set the optional max_register configuration of regmap to ensure the correct checks are in place. However, a recent commit 0ec74ad3c157 ("regmap: rework ->max_register handling") introduced explicit configuration in regmap framework for register maps that is exactly 1 register, when max_register is pointing to a valid register 0. This commit solved a previous limitation of regmap framework. Update syscon driver to consistent in regmap configuration for all sizes of syscons by using this new capability by setting max_register_is_0, when the max_register is valid and 0. Signed-off-by: Nishanth Menon --- Based on my search https://gist.github.com/nmenon/d537096d041fa553565fba7577d2cd24, the pattern of syscon registers that may potentially be impacted by this patch (that are exactly 1 register wide) is probably limited, though this patch in itself was inspired by a buggy driver code fixed in https://lore.kernel.org/linux-pm/20240828131915.3198081-1-nm@ti.com/ I have tried to Cc lists that may be interested in looking closer to avoid un-intended side-effects. Changes since V1: * Incorporate review comments by rewording commit message and $subject and dropped Fixes. * No functional change to the patch. * Expand the CC list to notify potential users. V1: https://lore.kernel.org/all/20240828121008.3066002-1-nm@ti.com/ Cc: Mark Brown Cc: Shawn Guo Cc: linux-arm-msm@vger.kernel.org Cc: Bjorn Andersson Cc: bcm-kernel-feedback-list@broadcom.com Cc: Florian Fainelli Cc: linux-stm32@st-md-mailman.stormreply.com Cc: Alexandre Torgue drivers/mfd/syscon.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index 2ce15f60eb10..3e1d699ba934 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -108,6 +108,8 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res) syscon_config.reg_stride = reg_io_width; syscon_config.val_bits = reg_io_width * 8; syscon_config.max_register = resource_size(&res) - reg_io_width; + if (!syscon_config.max_register) + syscon_config.max_register_is_0 = true; regmap = regmap_init_mmio(NULL, base, &syscon_config); kfree(syscon_config.name); @@ -357,6 +359,9 @@ static int syscon_probe(struct platform_device *pdev) return -ENOMEM; syscon_config.max_register = resource_size(res) - 4; + if (!syscon_config.max_register) + syscon_config.max_register_is_0 = true; + if (pdata) syscon_config.name = pdata->label; syscon->regmap = devm_regmap_init_mmio(dev, base, &syscon_config); -- 2.46.0