As stated in the comment found on top of rcar_gen3_phy_usb2_work,
we should not be registering the IRQ if !otg_channel || !uses_otg_pins.
On top of that, we should also make sure that extcon has been
allocated before requesting the irq as rcar_gen3_phy_usb2_work
uses it, hence the patch.
Fixes: 2b38543c8db1 ("phy: rcar-gen3-usb2: add extcon support")
Fixes: 73801b90a38f ("phy: renesas: rcar-gen3-usb2: change a condition
"dr_mode"")
Signed-off-by: Fabrizio Castro <[email protected]>
---
drivers/phy/renesas/phy-rcar-gen3-usb2.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
index 0a34782..be1a392 100644
--- a/drivers/phy/renesas/phy-rcar-gen3-usb2.c
+++ b/drivers/phy/renesas/phy-rcar-gen3-usb2.c
@@ -447,20 +447,8 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device
*pdev)
if (IS_ERR(channel->base))
return PTR_ERR(channel->base);
- /* call request_irq for OTG */
- irq = platform_get_irq(pdev, 0);
- if (irq >= 0) {
- INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work);
- irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq,
- IRQF_SHARED, dev_name(dev), channel);
- if (irq < 0)
- dev_err(dev, "No irq handler (%d)\n", irq);
- }
-
channel->dr_mode = of_usb_get_dr_mode_by_phy(dev->of_node, 0);
- if (channel->dr_mode != USB_DR_MODE_UNKNOWN) {
- int ret;
-
+ if (channel->dr_mode == USB_DR_MODE_OTG) {
channel->is_otg_channel = true;
channel->uses_otg_pins = !of_property_read_bool(dev->of_node,
"renesas,no-otg-pins");
@@ -476,6 +464,18 @@ static int rcar_gen3_phy_usb2_probe(struct platform_device
*pdev)
}
}
+ if (channel->is_otg_channel && channel->uses_otg_pins) {
+ /* call request_irq for OTG */
+ irq = platform_get_irq(pdev, 0);
+ if (irq >= 0) {
+ INIT_WORK(&channel->work, rcar_gen3_phy_usb2_work);
+ irq = devm_request_irq(dev, irq, rcar_gen3_phy_usb2_irq,
+ IRQF_SHARED, dev_name(dev),
channel);
+ if (irq < 0)
+ dev_err(dev, "No irq handler (%d)\n", irq);
+ }
+ }
+
/*
* devm_phy_create() will call pm_runtime_enable(&phy->dev);
* And then, phy-core will manage runtime pm for this device.
--
2.7.4