* [PATCH v2] gpio: lpc32xx: check devm_gpiochip_add_data() return value
@ 2026-10-16 15:42 Jayaraj Devaraj
0 siblings, 0 replies; 3+ messages in thread
From: Jayaraj Devaraj @ 2026-10-16 15:42 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij
Cc: Vladimir Zapolskiy, Piotr Wojtaszczyk, linux-gpio,
linux-arm-kernel, linux-kernel, Jayaraj Devaraj
lpc32xx_gpio_probe() registers each gpio chip with
devm_gpiochip_add_data() but ignores the return value. If registering
a chip fails, probe still returns 0, so the driver binds with a chip
missing and no error is reported.
Check the return value, print an error naming the failing chip and
return the error code. Chips registered earlier in the loop are devm
managed and are removed automatically on failure.
Signed-off-by: Jayaraj Devaraj <jayarajdmit@gmail.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
---
v2: use dev_err_probe() as suggested by Bartosz
drivers/gpio/gpio-lpc32xx.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c
index 37fc54fc7385..7fb46262e18c 100644
--- a/drivers/gpio/gpio-lpc32xx.c
+++ b/drivers/gpio/gpio-lpc32xx.c
@@ -510,7 +510,7 @@ static int lpc32xx_of_xlate(struct gpio_chip *gc,
static int lpc32xx_gpio_probe(struct platform_device *pdev)
{
- int i;
+ int i, ret;
void __iomem *reg_base;
reg_base = devm_platform_ioremap_resource(pdev, 0);
@@ -524,8 +524,11 @@ static int lpc32xx_gpio_probe(struct platform_device *pdev)
lpc32xx_gpiochip[i].chip.of_gpio_n_cells = 3;
lpc32xx_gpiochip[i].reg_base = reg_base;
}
- devm_gpiochip_add_data(&pdev->dev, &lpc32xx_gpiochip[i].chip,
- &lpc32xx_gpiochip[i]);
+ ret = devm_gpiochip_add_data(&pdev->dev, &lpc32xx_gpiochip[i].chip,
+ &lpc32xx_gpiochip[i]);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "failed to register gpio chip %d\n", i);
}
return 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH] gpio: lpc32xx: check devm_gpiochip_add_data() return value
@ 2026-10-14 20:43 Jayaraj Devaraj
2026-10-15 17:15 ` [PATCH v2] " Jayaraj Devaraj
0 siblings, 1 reply; 3+ messages in thread
From: Jayaraj Devaraj @ 2026-10-14 20:43 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij
Cc: Vladimir Zapolskiy, Piotr Wojtaszczyk, linux-gpio,
linux-arm-kernel, linux-kernel, Jayaraj Devaraj
lpc32xx_gpio_probe() registers each gpio chip with
devm_gpiochip_add_data() but ignores the return value. If registering
a chip fails, probe still returns 0, so the driver binds with a chip
missing and no error is reported.
Check the return value, print an error naming the failing chip and
return the error code. Chips registered earlier in the loop are devm
managed and are removed automatically on failure.
Signed-off-by: Jayaraj Devaraj <jayarajdmit@gmail.com>
---
drivers/gpio/gpio-lpc32xx.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c
index 37fc54fc7385..014eb8bc70da 100644
--- a/drivers/gpio/gpio-lpc32xx.c
+++ b/drivers/gpio/gpio-lpc32xx.c
@@ -510,7 +510,7 @@ static int lpc32xx_of_xlate(struct gpio_chip *gc,
static int lpc32xx_gpio_probe(struct platform_device *pdev)
{
- int i;
+ int i, ret;
void __iomem *reg_base;
reg_base = devm_platform_ioremap_resource(pdev, 0);
@@ -524,8 +524,12 @@ static int lpc32xx_gpio_probe(struct platform_device *pdev)
lpc32xx_gpiochip[i].chip.of_gpio_n_cells = 3;
lpc32xx_gpiochip[i].reg_base = reg_base;
}
- devm_gpiochip_add_data(&pdev->dev, &lpc32xx_gpiochip[i].chip,
- &lpc32xx_gpiochip[i]);
+ ret = devm_gpiochip_add_data(&pdev->dev, &lpc32xx_gpiochip[i].chip,
+ &lpc32xx_gpiochip[i]);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to register gpio chip %d: %d\n", i, ret);
+ return ret;
+ }
}
return 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH v2] gpio: lpc32xx: check devm_gpiochip_add_data() return value
2026-10-14 20:43 [PATCH] " Jayaraj Devaraj
@ 2026-10-15 17:15 ` Jayaraj Devaraj
2026-10-16 8:59 ` Bartosz Golaszewski
0 siblings, 1 reply; 3+ messages in thread
From: Jayaraj Devaraj @ 2026-10-15 17:15 UTC (permalink / raw)
To: Bartosz Golaszewski, Linus Walleij
Cc: Vladimir Zapolskiy, Piotr Wojtaszczyk, linux-gpio,
linux-arm-kernel, linux-kernel, Jayaraj Devaraj
lpc32xx_gpio_probe() registers each gpio chip with
devm_gpiochip_add_data() but ignores the return value. If registering
a chip fails, probe still returns 0, so the driver binds with a chip
missing and no error is reported.
Check the return value, print an error naming the failing chip and
return the error code. Chips registered earlier in the loop are devm
managed and are removed automatically on failure.
Signed-off-by: Jayaraj Devaraj <jayarajdmit@gmail.com>
Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
---
v2: use dev_err_probe() as suggested by Bartosz
drivers/gpio/gpio-lpc32xx.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c
index 37fc54fc7385..7fb46262e18c 100644
--- a/drivers/gpio/gpio-lpc32xx.c
+++ b/drivers/gpio/gpio-lpc32xx.c
@@ -510,7 +510,7 @@ static int lpc32xx_of_xlate(struct gpio_chip *gc,
static int lpc32xx_gpio_probe(struct platform_device *pdev)
{
- int i;
+ int i, ret;
void __iomem *reg_base;
reg_base = devm_platform_ioremap_resource(pdev, 0);
@@ -524,8 +524,11 @@ static int lpc32xx_gpio_probe(struct platform_device *pdev)
lpc32xx_gpiochip[i].chip.of_gpio_n_cells = 3;
lpc32xx_gpiochip[i].reg_base = reg_base;
}
- devm_gpiochip_add_data(&pdev->dev, &lpc32xx_gpiochip[i].chip,
- &lpc32xx_gpiochip[i]);
+ ret = devm_gpiochip_add_data(&pdev->dev, &lpc32xx_gpiochip[i].chip,
+ &lpc32xx_gpiochip[i]);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "failed to register gpio chip %d\n", i);
}
return 0;
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] gpio: lpc32xx: check devm_gpiochip_add_data() return value
2026-10-15 17:15 ` [PATCH v2] " Jayaraj Devaraj
@ 2026-10-16 8:59 ` Bartosz Golaszewski
0 siblings, 0 replies; 3+ messages in thread
From: Bartosz Golaszewski @ 2026-10-16 8:59 UTC (permalink / raw)
To: Jayaraj Devaraj
Cc: Bartosz Golaszewski, Linus Walleij, Vladimir Zapolskiy,
Piotr Wojtaszczyk, linux-gpio, linux-arm-kernel, linux-kernel
On Thu, 15 Oct 2026 19:15:57 +0200, Jayaraj Devaraj
<jayarajdmit@gmail.com> said:
> lpc32xx_gpio_probe() registers each gpio chip with
> devm_gpiochip_add_data() but ignores the return value. If registering
> a chip fails, probe still returns 0, so the driver binds with a chip
> missing and no error is reported.
>
> Check the return value, print an error naming the failing chip and
> return the error code. Chips registered earlier in the loop are devm
> managed and are removed automatically on failure.
>
> Signed-off-by: Jayaraj Devaraj <jayarajdmit@gmail.com>
> Reviewed-by: Vladimir Zapolskiy <vz@mleia.com>
> ---
Please don't send new versions of patches in response to existing threads. They
must be new threads. Please consider using b4 for managing patches[1].
Please resend it as a new thread.
Bartosz
[1] https://b4.docs.kernel.org/en/latest/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-16 15:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16 15:42 [PATCH v2] gpio: lpc32xx: check devm_gpiochip_add_data() return value Jayaraj Devaraj
-- strict thread matches above, loose matches on Subject: below --
2026-10-14 20:43 [PATCH] " Jayaraj Devaraj
2026-10-15 17:15 ` [PATCH v2] " Jayaraj Devaraj
2026-10-16 8:59 ` Bartosz Golaszewski
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.