Skip to contentSkip to conversation

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

PATCH In review [email protected] 3 participants 3 messages Oct 15, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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

---
v2: fix typos in commit message s/it's/its, s/probably/probable

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(+)
drivers/usb/host/ohci-at91.c +2 -0
index e98673954020..ec6739ef3129 100644
@@ -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);
Signature · 1 line
2.9.4
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 7 lines · On 15/10/2018 at 11:00, Tudor Ambarus - M18064 wrote:

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.

Quoted 7 lines

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

As for v1 (patchwork friendly addition):

Bye,
Nicolas

Quoted 23 lines

---
v2: fix typos in commit message s/it's/its, s/probably/probable

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(+)
drivers/usb/host/ohci-at91.c +2 -0
index e98673954020..ec6739ef3129 100644
@@ -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);
Signature · 1 line
Nicolas Ferre
maintainer Acked-by on v2 1/1
#2 lore raw
In reply to [email protected]
Quoted 28 lines · On Mon, 15 Oct 2018 Tudor.Ambarus at microchip.com wrote:

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

---
v2: fix typos in commit message s/it's/its, s/probably/probable

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(+)
drivers/usb/host/ohci-at91.c +0 -0
index e98673954020..ec6739ef3129 100644

drivers/usb/host/ohci-at91.c static int ohci_hcd_at91_drv_probe(struct platform_device *pdev) · line 558

Quoted 8 lines
drivers/usb/host/ohci-at91.c +2 -0
@@ -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);