Skip to content

Commit

Permalink
phy: phy-sun4i-usb: Fix optional gpios failing probe
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
  • Loading branch information
Quentin Schulz authored and Kishon Vijay Abraham I committed Jun 17, 2016
1 parent 075adb8 commit 5cf700a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/phy/phy-sun4i-usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 5cf700a

Please sign in to comment.