From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=162.243.120.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796224084; b=L5iF+owovY1DITEKwhNtrY9CeOSkIHENlqRMYgELLtrI2RPMhjUEIklKyEm0i3PBOtSk hnty2CgBipOEq36mQxnmK2hN6Fv1fgkW6ve9JFZ40X/ZMZSA8rkLcSf/YI8UdEB3H36um UNbOCumdac18TQhXpLjNENz49jfS9PWX3Y0jmS5KmIlNwIrNZrarcemwjgoOpocNNno16 vDiWlH3raGhoBFf43tM3Mkw/hpIL6rd0x6FXYNtLSOf4F+mKJUlKOm+8mLXP7ZVABZyr5 VGCz010udPjPoqKuUYPoltIzWTT3xvbP1Ujg38fpeesyUqGC4eb84hYZJ6U1BDTCYtg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796224084; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-Id:In-Reply-To:References:X-Mailer:Mime-Version:Content-Type: Content-Transfer-Encoding:X-Spam_score:X-Spam_bar; bh=zXBs6YDtC1ttfoDZAANIBsSo2n1+VjX89slZRMmDjAU=; b=GpPKYS8S33a8SFKV2szZRVQ2dqfpNdft0c5dCWCqD9A37qmm6n812rP6UBzwT+iWaGBC vRhcA9BAassYXqYAnAmDJKMF2VtTWjl6uyfDuOp/rpIGMT+u7xtkniIiggyXEjKYqyult r4vU2XA57x3GAnYH07MAIz7urCLu4gkbt0DjX/o1qLKpGnrH9e9DpQMI0ipMH0eAWB8zC 12IfXviCcwACcHtzrT+vPYLB0TE3u7NITnwCu7WNx7wDe6VqXghFeoELa2vE3xJQbMw0x n7DWgdjzaP5MLZNBcZOm7CSEJr2eCCFHC0dRWie7bYfHbVrMhRR9Ofx2FgkusQMO9WQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=hugovil.com; spf=pass smtp.mailfrom=hugovil.com; dkim=pass header.d=hugovil.com header.i=@hugovil.com header.a=rsa-sha256 header.s=default header.b=fz1EvlBd; arc=none smtp.remote-ip=162.243.120.170 Received: from mail.hugovil.com (mail.hugovil.com [162.243.120.170]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE24A606A31A; Wed, 2 Dec 2026 15:08:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CE24A606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=hugovil.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hugovil.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=hugovil.com header.i=@hugovil.com header.a=rsa-sha256 header.s=default header.b=fz1EvlBd DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=hugovil.com ; s=default; h=Content-Transfer-Encoding:Mime-Version:Message-Id:Subject:Cc: To:From:Date:subject:date:message-id:reply-to; bh=zXBs6YDtC1ttfoDZAANIBsSo2n1+VjX89slZRMmDjAU=; b=fz1EvlBdecxi0dJU4WELKXOggl DPSH4uV8o2xwNZZ7CN3Nw/qx18YQAboEZaAaYxaflgBwjjXAPRcpvFHqKdv5t9OvlDoS6lhQypsaz zVo9kMVQ2JlIPn770Wf/8kSKdGNpymVgPvTS3uG0HOeJLc9+64ZOTs69sYMkgzqJxPbc=; Received: from modemcable168.174-80-70.mc.videotron.ca ([70.80.174.168] helo=chambers) by mail.hugovil.com with esmtpa (Exim 4.98.2) (envelope-from ) id 1xYlw9-000000003G3-36DG; Wed, 02 Dec 2026 10:08:02 -0500 Date: Wed, 2 Dec 2026 10:07:59 -0500 From: Hugo Villeneuve To: Akshat Rawat Cc: Alexandre Belloni , Elena Popa , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] rtc: pcf2127: fix regmap_config corruption across probes Message-Id: <20261202100759.2f329920e2a76ed312baad7e@hugovil.com> In-Reply-To: <20261125151108.423-1-akshatrawat095@gmail.com> References: <20261125151108.423-1-akshatrawat095@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam_score: -2.0 X-Spam_bar: -- On Wed, 25 Nov 2026 15:11:08 +0000 Akshat Rawat wrote: > Both pcf2127_i2c_probe() and pcf2127_spi_probe() declare config as a > static struct regmap_config and update it in place based on the chip > variant. > > In pcf2127_spi_probe(), if a PCF2131 probes first, read_flag_mask and > write_flag_mask are overwritten to 0 and never restored. Any PCF2127 or > PCF2129 probed later reuses those zeroed masks instead of 0xa0/0x20, > breaking SPI register access. Modifying static max_register and flag > masks also races if multiple instances probe concurrently. > > Remove the static qualifier from config in both probe functions so each > device gets its own initialized copy on the stack. > > Fixes: fd28ceb4603f ("rtc: pcf2127: add variant-specific configuration structure") > Fixes: fa78e9b606a4 ("rtc: pcf2127: fix SPI command byte for PCF2131") > Cc: stable@vger.kernel.org > Signed-off-by: Akshat Rawat Reviewed-by: Hugo Villeneuve > --- > Changes in v2: > - Reword commit title to state the bug fixed rather than the implementation > - Simplify to dropping static from config in pcf2127_i2c_probe() and > pcf2127_spi_probe(), as suggested by Hugo Villeneuve (note: checkpatch.pl > warns that struct regmap_config should normally be const) Not a problem since regmap copies the struct. > > Compile-tested (x86_64 gcc 15.2.0, W=1, CONFIG_WERROR=y) with > I2C+SPI, I2C-only, and SPI-only configs; not tested on hardware. > > drivers/rtc/rtc-pcf2127.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/rtc/rtc-pcf2127.c b/drivers/rtc/rtc-pcf2127.c > index 27c5fb9b2aaa..d9ac2dbb4023 100644 > --- a/drivers/rtc/rtc-pcf2127.c > +++ b/drivers/rtc/rtc-pcf2127.c > @@ -1455,7 +1455,7 @@ MODULE_DEVICE_TABLE(i2c, pcf2127_i2c_id); > static int pcf2127_i2c_probe(struct i2c_client *client) > { > struct regmap *regmap; > - static struct regmap_config config = { > + struct regmap_config config = { > .reg_bits = 8, > .val_bits = 8, > }; > @@ -1520,7 +1520,7 @@ static const struct spi_device_id pcf2127_spi_id[]; > > static int pcf2127_spi_probe(struct spi_device *spi) > { > - static struct regmap_config config = { > + struct regmap_config config = { > .reg_bits = 8, > .val_bits = 8, > .read_flag_mask = 0xa0, > -- > 2.56.1.windows.1 > > -- Hugo Villeneuve