Skip to content

Commit a05c848

Browse files
neosys007gregkh
authored andcommitted
gpio: htc-egpio: use managed gpiochip registration
[ Upstream commit 17326db ] egpio_probe() registers each nested gpio_chip with gpiochip_add_data() but ignores the return value. If one registration fails, probe still returns success even though one of the chips was not published to gpiolib. Use devm_gpiochip_add_data() and fail probe if any chip registration fails. This lets devres unwind already registered chips and prevents the driver from publishing a partially initialized device. Fixes: a1635b8 ("[ARM] 4947/1: htc-egpio, a driver for GPIO/IRQ expanders with fixed input/output pins") Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn> Link: https://patch.msgid.link/20260624131828.94139-1-pengpeng@iscas.ac.cn Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f0320c6 commit a05c848

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/gpio/gpio-htc-egpio.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ static int __init egpio_probe(struct platform_device *pdev)
268268
struct gpio_chip *chip;
269269
unsigned int irq, irq_end;
270270
int i;
271+
int ret;
271272

272273
/* Initialize ei data structure. */
273274
ei = devm_kzalloc(&pdev->dev, sizeof(*ei), GFP_KERNEL);
@@ -331,7 +332,10 @@ static int __init egpio_probe(struct platform_device *pdev)
331332
chip->base = pdata->chip[i].gpio_base;
332333
chip->ngpio = pdata->chip[i].num_gpios;
333334

334-
gpiochip_add_data(chip, &ei->chip[i]);
335+
ret = devm_gpiochip_add_data(&pdev->dev, chip, &ei->chip[i]);
336+
if (ret)
337+
return dev_err_probe(&pdev->dev, ret,
338+
"failed to register gpiochip %d\n", i);
335339
}
336340

337341
/* Set initial pin values */

0 commit comments

Comments
 (0)