diff options
author | Quentin Schulz <quentin.schulz@free-electrons.com> | 2016-06-13 07:45:48 -0400 |
---|---|---|
committer | Kishon Vijay Abraham I <kishon@ti.com> | 2016-06-17 09:18:59 -0400 |
commit | 5cf700ac9d50353dc5b8194a57c6f40bf1fc4424 (patch) | |
tree | 2804c5a30e4d8cc26cdbbc82b66fbf720824db62 | |
parent | 075adb8046532d9642f411a92b4f385d04ced24d (diff) |
phy: phy-sun4i-usb: Fix optional gpios failing probe
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>
-rw-r--r-- | drivers/phy/phy-sun4i-usb.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/phy/phy-sun4i-usb.c b/drivers/phy/phy-sun4i-usb.c index bae54f7a1f48..45f01d6c9ed2 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) | |||
645 | 645 | ||
646 | data->id_det_irq = gpiod_to_irq(data->id_det_gpio); | 646 | data->id_det_irq = gpiod_to_irq(data->id_det_gpio); |
647 | data->vbus_det_irq = gpiod_to_irq(data->vbus_det_gpio); | 647 | data->vbus_det_irq = gpiod_to_irq(data->vbus_det_gpio); |
648 | if ((data->id_det_gpio && data->id_det_irq < 0) || | 648 | if ((data->id_det_gpio && data->id_det_irq <= 0) || |
649 | (data->vbus_det_gpio && data->vbus_det_irq < 0)) | 649 | (data->vbus_det_gpio && data->vbus_det_irq <= 0)) |
650 | data->phy0_poll = true; | 650 | data->phy0_poll = true; |
651 | 651 | ||
652 | if (data->id_det_irq >= 0) { | 652 | if (data->id_det_irq > 0) { |
653 | ret = devm_request_irq(dev, data->id_det_irq, | 653 | ret = devm_request_irq(dev, data->id_det_irq, |
654 | sun4i_usb_phy0_id_vbus_det_irq, | 654 | sun4i_usb_phy0_id_vbus_det_irq, |
655 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | 655 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
@@ -660,7 +660,7 @@ static int sun4i_usb_phy_probe(struct platform_device *pdev) | |||
660 | } | 660 | } |
661 | } | 661 | } |
662 | 662 | ||
663 | if (data->vbus_det_irq >= 0) { | 663 | if (data->vbus_det_irq > 0) { |
664 | ret = devm_request_irq(dev, data->vbus_det_irq, | 664 | ret = devm_request_irq(dev, data->vbus_det_irq, |
665 | sun4i_usb_phy0_id_vbus_det_irq, | 665 | sun4i_usb_phy0_id_vbus_det_irq, |
666 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, | 666 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |