[PATCH v2] gpio: mvebu: fail probe if gpiochip registration fails
From: Pengpeng Hou
Date: Mon Jun 22 2026 - 11:37:32 EST
mvebu_gpio_probe() registers the GPIO chip with devm_gpiochip_add_data()
but ignores the return value. If registration fails, probe continues and
leaves later code operating on a GPIO chip that was never published to
gpiolib.
Return the registration error so the device fails probe cleanly.
Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
---
Changes since v1:
- Use dev_err_probe() for the gpiochip registration failure as requested by
Linus Walleij.
drivers/gpio/gpio-mvebu.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index 31d880fd7b87..e92f499e3201 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -1217,7 +1217,10 @@ static int mvebu_gpio_probe(struct platform_device *pdev)
BUG();
}
- devm_gpiochip_add_data(&pdev->dev, &mvchip->chip, mvchip);
+ err = devm_gpiochip_add_data(&pdev->dev, &mvchip->chip, mvchip);
+ if (err)
+ return dev_err_probe(&pdev->dev, err,
+ "failed to register gpiochip\n");
/* Some MVEBU SoCs have simple PWM support for GPIO lines */
if (IS_REACHABLE(CONFIG_PWM)) {
--
2.50.1