From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933033AbcFQNYs (ORCPT ); Fri, 17 Jun 2016 09:24:48 -0400 Received: from devils.ext.ti.com ([198.47.26.153]:59406 "EHLO devils.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753029AbcFQNYr (ORCPT ); Fri, 17 Jun 2016 09:24:47 -0400 Subject: Re: [PATCH] phy: phy-sun4i-usb: Fix optional gpios failing probe To: Quentin Schulz , , References: <1465818348-29499-1-git-send-email-quentin.schulz@free-electrons.com> CC: , , From: Kishon Vijay Abraham I Message-ID: <5763FA00.8030205@ti.com> Date: Fri, 17 Jun 2016 18:54:16 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <1465818348-29499-1-git-send-email-quentin.schulz@free-electrons.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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, >