linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] phy: phy-sun4i-usb: Fix optional gpios failing probe
@ 2016-06-13 11:45 Quentin Schulz
  2016-06-17 13:24 ` Kishon Vijay Abraham I
  0 siblings, 1 reply; 2+ messages in thread
From: Quentin Schulz @ 2016-06-13 11:45 UTC (permalink / raw)
  To: kishon, maxime.ripard, wens
  Cc: Quentin Schulz, linux-kernel, linux-arm-kernel, thomas.petazzoni

The interrupt 0 is not a valid interrupt number. In the event where the
retrieval of the vbus-det gpio would return null, the gpiod_to_irq
callback would return 0, while the current code makes the assumption
that it is a valid interrupt, and would go on calling request_irq.
Obviously, this would fail, preventing the driver from probing properly,
while the vbus and id gpios are optional.

Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>
---
 drivers/phy/phy-sun4i-usb.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
index bae54f7..45f01d6 100644
--- a/drivers/phy/phy-sun4i-usb.c
+++ b/drivers/phy/phy-sun4i-usb.c
@@ -645,11 +645,11 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
 
 	data->id_det_irq = gpiod_to_irq(data->id_det_gpio);
 	data->vbus_det_irq = gpiod_to_irq(data->vbus_det_gpio);
-	if ((data->id_det_gpio && data->id_det_irq < 0) ||
-	    (data->vbus_det_gpio && data->vbus_det_irq < 0))
+	if ((data->id_det_gpio && data->id_det_irq <= 0) ||
+	    (data->vbus_det_gpio && data->vbus_det_irq <= 0))
 		data->phy0_poll = true;
 
-	if (data->id_det_irq >= 0) {
+	if (data->id_det_irq > 0) {
 		ret = devm_request_irq(dev, data->id_det_irq,
 				sun4i_usb_phy0_id_vbus_det_irq,
 				IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
@@ -660,7 +660,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
 		}
 	}
 
-	if (data->vbus_det_irq >= 0) {
+	if (data->vbus_det_irq > 0) {
 		ret = devm_request_irq(dev, data->vbus_det_irq,
 				sun4i_usb_phy0_id_vbus_det_irq,
 				IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
-- 
2.5.0

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

* Re: [PATCH] phy: phy-sun4i-usb: Fix optional gpios failing probe
  2016-06-13 11:45 [PATCH] phy: phy-sun4i-usb: Fix optional gpios failing probe Quentin Schulz
@ 2016-06-17 13:24 ` Kishon Vijay Abraham I
  0 siblings, 0 replies; 2+ messages in thread
From: Kishon Vijay Abraham I @ 2016-06-17 13:24 UTC (permalink / raw)
  To: Quentin Schulz, maxime.ripard, wens
  Cc: linux-kernel, linux-arm-kernel, thomas.petazzoni



On Monday 13 June 2016 05:15 PM, Quentin Schulz wrote:
> The interrupt 0 is not a valid interrupt number. In the event where the
> retrieval of the vbus-det gpio would return null, the gpiod_to_irq
> callback would return 0, while the current code makes the assumption
> that it is a valid interrupt, and would go on calling request_irq.
> Obviously, this would fail, preventing the driver from probing properly,
> while the vbus and id gpios are optional.
> 
> Signed-off-by: Quentin Schulz <quentin.schulz@free-electrons.com>

applied, thanks.

-Kishon
> ---
>  drivers/phy/phy-sun4i-usb.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c
> index bae54f7..45f01d6 100644
> --- a/drivers/phy/phy-sun4i-usb.c
> +++ b/drivers/phy/phy-sun4i-usb.c
> @@ -645,11 +645,11 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
>  
>  	data->id_det_irq = gpiod_to_irq(data->id_det_gpio);
>  	data->vbus_det_irq = gpiod_to_irq(data->vbus_det_gpio);
> -	if ((data->id_det_gpio && data->id_det_irq < 0) ||
> -	    (data->vbus_det_gpio && data->vbus_det_irq < 0))
> +	if ((data->id_det_gpio && data->id_det_irq <= 0) ||
> +	    (data->vbus_det_gpio && data->vbus_det_irq <= 0))
>  		data->phy0_poll = true;
>  
> -	if (data->id_det_irq >= 0) {
> +	if (data->id_det_irq > 0) {
>  		ret = devm_request_irq(dev, data->id_det_irq,
>  				sun4i_usb_phy0_id_vbus_det_irq,
>  				IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
> @@ -660,7 +660,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> -	if (data->vbus_det_irq >= 0) {
> +	if (data->vbus_det_irq > 0) {
>  		ret = devm_request_irq(dev, data->vbus_det_irq,
>  				sun4i_usb_phy0_id_vbus_det_irq,
>  				IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
> 

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

end of thread, other threads:[~2016-06-17 13:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-13 11:45 [PATCH] phy: phy-sun4i-usb: Fix optional gpios failing probe Quentin Schulz
2016-06-17 13:24 ` Kishon Vijay Abraham I

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