* [PATCH v2 1/2] pinctrl: mcp23s08: Initialize mcp->dev and mcp->addr before regmap init
2026-05-13 23:11 [PATCH v2 0/2] pinctrl: mcp23s08: Fix probe issues Judith Mendez
@ 2026-05-13 23:11 ` Judith Mendez
2026-05-13 23:11 ` [PATCH v2 2/2] pinctrl: mcp23s08: Read spi-present-mask as u8 not u32 Judith Mendez
1 sibling, 0 replies; 3+ messages in thread
From: Judith Mendez @ 2026-05-13 23:11 UTC (permalink / raw)
To: Judith Mendez, Linus Walleij; +Cc: 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>
---
Changes since v1:
- Add #define for base adress & use instead of 0x40 hardcode base address
---
drivers/pinctrl/pinctrl-mcp23s08_spi.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
index 54f61c8cb1c0f..5ed368772adb7 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
@@ -10,6 +10,7 @@
#include "pinctrl-mcp23s08.h"
#define MCP_MAX_DEV_PER_CS 8
+#define MCP23S08_SPI_BASE 0x40
/*
* A given spi_device can represent up to eight mcp23sxx chips
@@ -173,6 +174,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 = MCP23S08_SPI_BASE | (addr << 1);
ret = mcp23s08_spi_regmap_init(data->mcp[addr], dev, addr, info);
if (ret)
@@ -184,7 +187,7 @@ static int mcp23s08_probe(struct spi_device *spi)
if (!data->mcp[addr]->pinctrl_desc.name)
return -ENOMEM;
- ret = mcp23s08_probe_one(data->mcp[addr], dev, 0x40 | (addr << 1),
+ ret = mcp23s08_probe_one(data->mcp[addr], dev, MCP23S08_SPI_BASE | (addr << 1),
info->type, -1);
if (ret < 0)
return ret;
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH v2 2/2] pinctrl: mcp23s08: Read spi-present-mask as u8 not u32
2026-05-13 23:11 [PATCH v2 0/2] pinctrl: mcp23s08: Fix probe issues Judith Mendez
2026-05-13 23:11 ` [PATCH v2 1/2] pinctrl: mcp23s08: Initialize mcp->dev and mcp->addr before regmap init Judith Mendez
@ 2026-05-13 23:11 ` Judith Mendez
1 sibling, 0 replies; 3+ messages in thread
From: Judith Mendez @ 2026-05-13 23:11 UTC (permalink / raw)
To: Judith Mendez, Linus Walleij; +Cc: linux-gpio, linux-kernel
The binding (microchip,mcp23s08) specifies microchip,spi-present-mask
as uint8, but driver would read u32, causing type mismatch. Use
device_property_read_u8 to match binding spec, hardware (8 chips max),
& prevent probe failure.
Cc: stable@vger.kernel.org
Fixes: 3ad8d3ec6d87 ("dt-bindings: pinctrl: convert pinctrl-mcp23s08.txt to yaml format")
Signed-off-by: Judith Mendez <jm@ti.com>
---
Changes since v1:
- Add patch 2/2
---
drivers/pinctrl/pinctrl-mcp23s08_spi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-mcp23s08_spi.c b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
index 5ed368772adb7..30775d31bd694 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08_spi.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08_spi.c
@@ -144,13 +144,13 @@ static int mcp23s08_probe(struct spi_device *spi)
unsigned int addr;
int chips;
int ret;
- u32 v;
+ u8 v;
info = spi_get_device_match_data(spi);
- ret = device_property_read_u32(dev, "microchip,spi-present-mask", &v);
+ ret = device_property_read_u8(dev, "microchip,spi-present-mask", &v);
if (ret) {
- ret = device_property_read_u32(dev, "mcp,spi-present-mask", &v);
+ ret = device_property_read_u8(dev, "mcp,spi-present-mask", &v);
if (ret) {
dev_err(dev, "missing spi-present-mask");
return ret;
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread