* [PATCH v2] pinctrl: mcp23s08: Propagate reset GPIO errors
@ 2026-10-12 1:54 phucduc.bui
2026-10-12 2:01 ` sashiko-bot
0 siblings, 1 reply; 5+ messages in thread
From: phucduc.bui @ 2026-10-12 1:54 UTC (permalink / raw)
To: Linus Walleij
Cc: Darian Biastoch, Andreas Kaessens, linux-gpio, linux-kernel,
bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
devm_gpiod_get_optional() may return -EPROBE_DEFER or other errors,
but mcp23s08_probe_one() currently ignores them.
Check the return value and propagate errors from the reset GPIO lookup.
Fixes: 4e73bfa3ee37 ("pinctrl: mcp23s08: Add optional reset GPIO")
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
Changes in v2:
-return ERR_PTR(-EPROBE_DEFER) instead of uninitialized ret variable
drivers/pinctrl/pinctrl-mcp23s08.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
index cc668f84bf8b..259ac02134c6 100644
--- a/drivers/pinctrl/pinctrl-mcp23s08.c
+++ b/drivers/pinctrl/pinctrl-mcp23s08.c
@@ -613,6 +613,9 @@ int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
mcp->chip.owner = THIS_MODULE;
mcp->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
+ if (IS_ERR(mcp->reset_gpio))
+ return dev_err_probe(dev, PTR_ERR(mcp->reset_gpio),
+ "failed to get reset GPIO\n");
/* verify MCP_IOCON.SEQOP = 0, so sequential reads work,
* and MCP_IOCON.HAEN = 1, so we work with all chips.
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] pinctrl: mcp23s08: Propagate reset GPIO errors
2026-10-12 1:54 [PATCH v2] pinctrl: mcp23s08: Propagate reset GPIO errors phucduc.bui
@ 2026-10-12 2:01 ` sashiko-bot
2026-10-12 5:53 ` Bui Duc Phuc
0 siblings, 1 reply; 5+ messages in thread
From: sashiko-bot @ 2026-10-12 2:01 UTC (permalink / raw)
To: phucduc.bui; +Cc: linux-gpio
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pinctrl: mcp23s08: multi-device probe failure due to duplicate reset GPIO request
--
commit 95196894afec909a218e9bd99fc8884c93869fc7
Author: bui duc phuc <phucduc.bui@gmail.com>
pinctrl: mcp23s08: Propagate reset GPIO errors
This commit adds a check for the return value of devm_gpiod_get_optional() in
mcp23s08_probe_one() to propagate errors instead of ignoring them.
> diff --git a/drivers/pinctrl/pinctrl-mcp23s08.c b/drivers/pinctrl/pinctrl-mcp23s08.c
> index cc668f84bf8bc..259ac02134c64 100644
> --- a/drivers/pinctrl/pinctrl-mcp23s08.c
> +++ b/drivers/pinctrl/pinctrl-mcp23s08.c
> @@ -613,6 +613,9 @@ int mcp23s08_probe_one(struct mcp23s08 *mcp, struct device *dev,
> mcp->chip.owner = THIS_MODULE;
>
> mcp->reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_LOW);
> + if (IS_ERR(mcp->reset_gpio))
> + return dev_err_probe(dev, PTR_ERR(mcp->reset_gpio),
> + "failed to get reset GPIO\n");
[Severity: High]
Does this cause a regression for multi-chip SPI configurations by aborting the
probe due to -EBUSY?
In the SPI driver, multiple physical chips can share a single SPI chip select.
This is handled in drivers/pinctrl/pinctrl-mcp23s08_spi.c:mcp23s08_probe() by
iterating over spi_present_mask and calling mcp23s08_probe_one() for each:
drivers/pinctrl/pinctrl-mcp23s08_spi.c:mcp23s08_probe() {
...
for_each_set_bit(addr, &spi_present_mask, MCP_MAX_DEV_PER_CS) {
...
ret = mcp23s08_probe_one(data->mcp[addr], dev, MCP23S08_SPI_BASE | (addr << 1),
info->type, -1);
if (ret < 0)
return ret;
}
...
}
Because all logical chips share the same SPI device, the same struct device
*dev pointer is passed to every mcp23s08_probe_one() call.
During the first iteration, the reset GPIO is successfully requested
exclusively.
During the second iteration, devm_gpiod_get_optional() is called again on the
same dev pointer for the same "reset" connection ID. The GPIO core will
attempt to request the same descriptor again, which will return -EBUSY because
it is already requested and does not use GPIOD_FLAGS_BIT_NONEXCLUSIVE.
Prior to this patch, the -EBUSY error was ignored, allowing the second and
subsequent chips to probe successfully (which was safe since the reset line
was already asserted and deasserted by the first chip).
>
> /* verify MCP_IOCON.SEQOP = 0, so sequential reads work,
> * and MCP_IOCON.HAEN = 1, so we work with all chips.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012015433.6155-1-phucduc.bui@gmail.com?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] pinctrl: mcp23s08: Propagate reset GPIO errors
2026-10-12 2:01 ` sashiko-bot
@ 2026-10-12 5:53 ` Bui Duc Phuc
2026-10-12 8:04 ` Linus Walleij
0 siblings, 1 reply; 5+ messages in thread
From: Bui Duc Phuc @ 2026-10-12 5:53 UTC (permalink / raw)
To: sashiko-reviews, Linus Walleij; +Cc: linux-gpio
>
> [Severity: High]
> Does this cause a regression for multi-chip SPI configurations by aborting the
> probe due to -EBUSY?
>
> In the SPI driver, multiple physical chips can share a single SPI chip select.
> This is handled in drivers/pinctrl/pinctrl-mcp23s08_spi.c:mcp23s08_probe() by
> iterating over spi_present_mask and calling mcp23s08_probe_one() for each:
>
> drivers/pinctrl/pinctrl-mcp23s08_spi.c:mcp23s08_probe() {
> ...
> for_each_set_bit(addr, &spi_present_mask, MCP_MAX_DEV_PER_CS) {
> ...
> ret = mcp23s08_probe_one(data->mcp[addr], dev, MCP23S08_SPI_BASE | (addr << 1),
> info->type, -1);
> if (ret < 0)
> return ret;
> }
> ...
> }
>
> Because all logical chips share the same SPI device, the same struct device
> *dev pointer is passed to every mcp23s08_probe_one() call.
>
> During the first iteration, the reset GPIO is successfully requested
> exclusively.
>
> During the second iteration, devm_gpiod_get_optional() is called again on the
> same dev pointer for the same "reset" connection ID. The GPIO core will
> attempt to request the same descriptor again, which will return -EBUSY because
> it is already requested and does not use GPIOD_FLAGS_BIT_NONEXCLUSIVE.
>
> Prior to this patch, the -EBUSY error was ignored, allowing the second and
> subsequent chips to probe successfully (which was safe since the reset line
> was already asserted and deasserted by the first chip).
>
> >
> > /* verify MCP_IOCON.SEQOP = 0, so sequential reads work,
> > * and MCP_IOCON.HAEN = 1, so we work with all chips.
>
I looked at how the cs35l35 and aic3x drivers handle -EBUSY
when the reset GPIO is shared:
- cs35l35: https://elixir.bootlin.com/linux/v7.3-rc6/source/sound/soc/codecs/cs35l35.c#L1524
- aic3x: https://elixir.bootlin.com/linux/v7.3-rc6/source/sound/soc/codecs/tlv320aic3x.c#L1815
I think handling -EBUSY similarly to cs35l35 may be more
appropriate here, preserving the existing behavior for shared
reset GPIOs while propagating other errors.
Linus, could you confirm whether this approach would be OK for
mcp23s08?
Best regards,
Phuc
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] pinctrl: mcp23s08: Propagate reset GPIO errors
2026-10-12 5:53 ` Bui Duc Phuc
@ 2026-10-12 8:04 ` Linus Walleij
2026-10-12 8:28 ` Bui Duc Phuc
0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2026-10-12 8:04 UTC (permalink / raw)
To: Bui Duc Phuc; +Cc: sashiko-reviews, linux-gpio
On Mon, Oct 12, 2026 at 7:53 AM Bui Duc Phuc <phucduc.bui@gmail.com> wrote:
> Linus, could you confirm whether this approach would be OK for
> mcp23s08?
I don't understand Sashiko's fringe use-case rambling here,
I think the patch is fine.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] pinctrl: mcp23s08: Propagate reset GPIO errors
2026-10-12 8:04 ` Linus Walleij
@ 2026-10-12 8:28 ` Bui Duc Phuc
0 siblings, 0 replies; 5+ messages in thread
From: Bui Duc Phuc @ 2026-10-12 8:28 UTC (permalink / raw)
To: Linus Walleij; +Cc: sashiko-reviews, linux-gpio
Hi Linus,
Thanks for confirming.
>
> I don't understand Sashiko's fringe use-case rambling here,
> I think the patch is fine.
>
I'll keep the patch as proposed.
Best regards,
Phuc
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-12 8:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-12 1:54 [PATCH v2] pinctrl: mcp23s08: Propagate reset GPIO errors phucduc.bui
2026-10-12 2:01 ` sashiko-bot
2026-10-12 5:53 ` Bui Duc Phuc
2026-10-12 8:04 ` Linus Walleij
2026-10-12 8:28 ` Bui Duc Phuc
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.