linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] usb: host: ohci-at91: fix request of irq for optional gpio
@ 2018-10-15  9:00 Tudor.Ambarus
  2018-10-15  9:12 ` Nicolas Ferre
  2018-10-15 15:23 ` Alan Stern
  0 siblings, 2 replies; 3+ messages in thread
From: Tudor.Ambarus @ 2018-10-15  9:00 UTC (permalink / raw)
  To: stern, gregkh, Nicolas.Ferre, alexandre.belloni, Cristian.Birsan,
	linux-usb, linux-arm-kernel, linux-kernel
  Cc: Tudor.Ambarus

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>
---
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(+)

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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] usb: host: ohci-at91: fix request of irq for optional gpio
  2018-10-15  9:00 [PATCH v2] usb: host: ohci-at91: fix request of irq for optional gpio Tudor.Ambarus
@ 2018-10-15  9:12 ` Nicolas Ferre
  2018-10-15 15:23 ` Alan Stern
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Ferre @ 2018-10-15  9:12 UTC (permalink / raw)
  To: Tudor Ambarus - M18064, stern, gregkh, alexandre.belloni,
	Cristian Birsan - M91496, linux-usb, linux-arm-kernel,
	linux-kernel

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.
> 
> 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>

As for v1 (patchwork friendly addition):
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

Bye,
   Nicolas

> ---
> 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(+)
> 
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] usb: host: ohci-at91: fix request of irq for optional gpio
  2018-10-15  9:00 [PATCH v2] usb: host: ohci-at91: fix request of irq for optional gpio Tudor.Ambarus
  2018-10-15  9:12 ` Nicolas Ferre
@ 2018-10-15 15:23 ` Alan Stern
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Stern @ 2018-10-15 15:23 UTC (permalink / raw)
  To: Tudor.Ambarus
  Cc: gregkh, Nicolas.Ferre, alexandre.belloni, Cristian.Birsan,
	linux-usb, linux-arm-kernel, linux-kernel

On Mon, 15 Oct 2018 Tudor.Ambarus@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
> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> ---
> 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(+)
> 
> 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);

Acked-by: Alan Stern <stern@rowland.harvard.edu>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-15 15:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-15  9:00 [PATCH v2] usb: host: ohci-at91: fix request of irq for optional gpio Tudor.Ambarus
2018-10-15  9:12 ` Nicolas Ferre
2018-10-15 15:23 ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).