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

Subsystems: the rest, usb ohci driver, usb subsystem

STALE2846d

2 messages, 2 authors, 2018-10-15 · open the first message on its own page

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

From: <hidden>
Date: 2018-10-15 08:34:10

atmel,oc-gpio is optional. Request it's 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 probably 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 <redacted>
---
Based on https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git,
usb-next branch.

 drivers/usb/host/ohci-at91.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index e98673954020..ec6739ef3129 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -551,6 +551,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
 		pdata->overcurrent_pin[i] =
 			devm_gpiod_get_index_optional(&pdev->dev, "atmel,oc",
 						      i, GPIOD_IN);
+		if (!pdata->overcurrent_pin[i])
+			continue;
 		if (IS_ERR(pdata->overcurrent_pin[i])) {
 			err = PTR_ERR(pdata->overcurrent_pin[i]);
 			dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err);
-- 
2.9.4

Re: [PATCH] usb: host: ohci-at91: fix request of irq for optional gpio

From: Nicolas Ferre <nicolas.ferre@microchip.com>
Date: 2018-10-15 08:58:39

On 15/10/2018 at 10:34, Tudor Ambarus - M18064 wrote:
atmel,oc-gpio is optional. Request it's 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 probably 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 <redacted>
Yes, indeed:
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

Thanks, best regards,
   Nicolas
quoted hunk
---
Based on https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git,
usb-next branch.

  drivers/usb/host/ohci-at91.c | 2 ++
  1 file changed, 2 insertions(+)
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index e98673954020..ec6739ef3129 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -551,6 +551,8 @@ static int ohci_hcd_at91_drv_probe(struct platform_device *pdev)
  		pdata->overcurrent_pin[i] =
  			devm_gpiod_get_index_optional(&pdev->dev, "atmel,oc",
  						      i, GPIOD_IN);
+		if (!pdata->overcurrent_pin[i])
+			continue;
  		if (IS_ERR(pdata->overcurrent_pin[i])) {
  			err = PTR_ERR(pdata->overcurrent_pin[i]);
  			dev_err(&pdev->dev, "unable to claim gpio \"overcurrent\": %d\n", err);

-- 
Nicolas Ferre
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help