The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] pinctrl: mcp23s08: Initialize mcp->dev and mcp->addr before regmap init
@ 2026-05-08 21:43 Judith Mendez
  2026-05-11  9:13 ` Linus Walleij
  0 siblings, 1 reply; 2+ messages in thread
From: Judith Mendez @ 2026-05-08 21:43 UTC (permalink / raw)
  To: Judith Mendez, Linus Walleij; +Cc: Maksim Kiselev, linux-gpio, linux-kernel

Regmap initialization triggers regcache_maple_populate() which attempts
SPI read to populate cache. SPI read requires mcp->dev and mcp->addr to
be set, without them, NULL pointer dereference occurs during probe.

Move initialization before mcp23s08_spi_regmap_init() call.

Cc: stable@vger.kernel.org
Fixes: f9f4fda15e72 ("pinctrl: mcp23s08: init reg_defaults from HW at probe and switch cache type")
Signed-off-by: Judith Mendez <jm@ti.com>
---
 drivers/pinctrl/pinctrl-mcp23s08_spi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
index 54f61c8cb1c0..1e99b2566d5a 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
@@ -173,6 +173,8 @@ static int mcp23s08_probe(struct spi_device *spi)
 	for_each_set_bit(addr, &spi_present_mask, MCP_MAX_DEV_PER_CS) {
 		data->mcp[addr] = &data->chip[--chips];
 		data->mcp[addr]->irq = spi->irq;
+		data->mcp[addr]->dev = dev;
+		data->mcp[addr]->addr = 0x40 | (addr << 1);
 
 		ret = mcp23s08_spi_regmap_init(data->mcp[addr], dev, addr, info);
 		if (ret)
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] pinctrl: mcp23s08: Initialize mcp->dev and mcp->addr before regmap init
  2026-05-08 21:43 [PATCH] pinctrl: mcp23s08: Initialize mcp->dev and mcp->addr before regmap init Judith Mendez
@ 2026-05-11  9:13 ` Linus Walleij
  0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2026-05-11  9:13 UTC (permalink / raw)
  To: Judith Mendez; +Cc: Maksim Kiselev, linux-gpio, linux-kernel

Hi Judith,

thanks for your patch!

On Fri, May 8, 2026 at 11:43 PM Judith Mendez <jm@ti.com> wrote:

> Regmap initialization triggers regcache_maple_populate() which attempts
> SPI read to populate cache. SPI read requires mcp->dev and mcp->addr to
> be set, without them, NULL pointer dereference occurs during probe.
>
> Move initialization before mcp23s08_spi_regmap_init() call.
>
> Cc: stable@vger.kernel.org
> Fixes: f9f4fda15e72 ("pinctrl: mcp23s08: init reg_defaults from HW at probe and switch cache type")
> Signed-off-by: Judith Mendez <jm@ti.com>
(...)
> +               data->mcp[addr]->dev = dev;
> +               data->mcp[addr]->addr = 0x40 | (addr << 1);

What does this 0x40 mean here? Can you use a #define to specify
exactly what is going on?

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-11  9:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-08 21:43 [PATCH] pinctrl: mcp23s08: Initialize mcp->dev and mcp->addr before regmap init Judith Mendez
2026-05-11  9:13 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox