Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp250619ybd; Tue, 25 Jun 2019 20:45:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqmHYHALWrogBParUM0RzvR6wvk/eigC7TJZ5IOvadOAiGJ0RQVMapYW3gH/QTXRHd3IT0 X-Received: by 2002:a63:dc02:: with SMTP id s2mr607481pgg.286.1561520708343; Tue, 25 Jun 2019 20:45:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561520708; cv=none; d=google.com; s=arc-20160816; b=bfMk9nWJI0VS4rhj29ktoxE3ZYsHqc0zjgRWPByXNc3HIV7NwDS3AmIUqBWm6lwp+/ TzxejIGCYBud9Ny4KIH5Mu8WWjKyjT9gxkWl9YWgt4w4dVQGvlEey1MJ3RlIVv+UqgYx 9QNHda6bqfu2MdoU13vnT8Pf3vojHTxq4yLpWa9vFRJqGH86xUBgo7szhKJyepPqP1v9 y/UzMlfw77a7PNU9MnymRlPcJAEbaSY9BlFeMwmCJN/e75P7mVOdWBdCFg5qh3jX0YyF ffYGD2JUOtUmmks5avqJYhqscTdRFbpkExtY9+QM2mEymXYQK4DDK3cx9pToycPgrq3C k5RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=foPUsYXidjnfYbt5Wnhk/ObPeBxlKORN357TyN9jl6s=; b=qqf/5UKFnQAGiCNKnXd4FIvLMN1njTH5v1y6sPhtIk8oQRZWtdEkukZf/896NmUqca ooXp90O+TcCrf2t/9Gk6zNeXw/rTtup9/Pkb2xcjculkqxYyfyJpoPGCejgymIZofF06 7Fo6ymzbs+THCICKOIZz3k5zB5sVGhN8RkkYoJCdRicatjOthnLPHICC3QB/4a/71PXL 5e0zWsjvtoNGUp6k+XalmB9GTD9q4gLjQxtw1BJk4UipHFfcFdwauVQqGdfwCwofvnVp aBvsABqjLGBGA7mC7iDH6gzZVRBcbZ86BqRIutTgU6n0KA81TzhpwRo7S/3SAzroXz+1 kHbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MsEO1GsD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3si2114591plr.187.2019.06.25.20.44.52; Tue, 25 Jun 2019 20:45:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MsEO1GsD; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726594AbfFZDnC (ORCPT + 99 others); Tue, 25 Jun 2019 23:43:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:54010 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbfFZDm6 (ORCPT ); Tue, 25 Jun 2019 23:42:58 -0400 Received: from sasha-vm.mshome.net (mobile-107-77-172-74.mobile.att.net [107.77.172.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2C92C21655; Wed, 26 Jun 2019 03:42:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561520577; bh=l4wRp0ciZsdiP8bdq+krdoTNEqZRrCAe8x8ByEs1JDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MsEO1GsDeK7aGxCPC/nqo31EXl+JeSukNeQD+PKE88kVUZrnlgA8ifaH9fZhu6ySS r1KkBQ/OCgzhm0tN71vSFRUwSLh1WKyrL3jrPzvsfPdXCwA/vu8A95kOHI8Vk2qviV ExQrauKHSne3NEfmTP1r8XdjBpYWgimhiEyjp+8Q= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "H. Nikolaus Schaller" , Linus Walleij , Sasha Levin , linux-gpio@vger.kernel.org Subject: [PATCH AUTOSEL 5.1 35/51] gpio: pca953x: hack to fix 24 bit gpio expanders Date: Tue, 25 Jun 2019 23:40:51 -0400 Message-Id: <20190626034117.23247-35-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190626034117.23247-1-sashal@kernel.org> References: <20190626034117.23247-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "H. Nikolaus Schaller" [ Upstream commit 3b00691cc46a4089368a008b30655a8343411715 ] 24 bit expanders use REG_ADDR_AI in combination with register addressing. This conflicts with regmap which takes this bit as part of the register number, i.e. a second cache entry is defined for accessed with REG_ADDR_AI being set although on the chip it is the same register as with REG_ADDR_AI being cleared. The problem was introduced by commit b32cecb46bdc ("gpio: pca953x: Extract the register address mangling to single function") but only became visible by commit 8b9f9d4dc511 ("regmap: verify if register is writeable before writing operations") because before, the regmap size was effectively ignored and pca953x_writeable_register() did know to ignore REG_ADDR_AI. Still, there were two separate cache entries created. Since the use of REG_ADDR_AI seems to be static we can work around this issue by simply increasing the size of the regmap to cover the "virtual" registers with REG_ADDR_AI being set. This only means that half of the regmap buffer will be unused. Reported-by: H. Nikolaus Schaller Suggested-by: Linus Walleij Signed-off-by: H. Nikolaus Schaller Signed-off-by: Linus Walleij Signed-off-by: Sasha Levin --- drivers/gpio/gpio-pca953x.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c index 7e76830b3368..b6f10e56dfa0 100644 --- a/drivers/gpio/gpio-pca953x.c +++ b/drivers/gpio/gpio-pca953x.c @@ -306,7 +306,8 @@ static const struct regmap_config pca953x_i2c_regmap = { .volatile_reg = pca953x_volatile_register, .cache_type = REGCACHE_RBTREE, - .max_register = 0x7f, + /* REVISIT: should be 0x7f but some 24 bit chips use REG_ADDR_AI */ + .max_register = 0xff, }; static u8 pca953x_recalc_addr(struct pca953x_chip *chip, int reg, int off, -- 2.20.1