Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: host: ohci-at91: fix request of irq for optional gpio

atmel,oc-gpio is optional. Request its irq only when atmel,oc is set
in device tree.

devm_gpiod_get_index_optional returns NULL if -ENOENT. Check its
return value for NULL before error, because it is more probable that
atmel,oc is not set.

This fixes the following errors on boards where atmel,oc is not set in
device tree:
[ 0.960000] at91_ohci 500000.ohci: failed to request gpio "overcurrent" IRQ
[ 0.960000] at91_ohci 500000.ohci: failed to request gpio "overcurrent" IRQ
[ 0.970000] at91_ohci 500000.ohci: failed to request gpio "overcurrent" IRQ

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Tudor.Ambarus@microchip.com and committed by
Greg Kroah-Hartman
325b9313 24f5975f

+2
+2
drivers/usb/host/ohci-at91.c
··· 551 551 pdata->overcurrent_pin[i] = 552 552 devm_gpiod_get_index_optional(&pdev->dev, "atmel,oc", 553 553 i, GPIOD_IN); 554 + if (!pdata->overcurrent_pin[i]) 555 + continue; 554 556 if (IS_ERR(pdata->overcurrent_pin[i])) { 555 557 err = PTR_ERR(pdata->overcurrent_pin[i]); 556 558 dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err);