usb: phy: msm: Unregister driver interest for VBUS and ID events
Subsystems (2)
PATCH 1/1 usb: phy: msm: Unregister driver interest for VBUS and ID events
Right now even if driver failed to probe extcon framework will still deliver its VBUS and ID events, which will lead to random exception codes.
Fix this by removing driver interest for VBUS and ID events when probe fail.
--- drivers/usb/phy/phy-msm-usb.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)
drivers/usb/phy/phy-msm-usb.c +17 -9
@@ -1581,6 +1581,8 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) ret =extcon_register_interest (&motg->id.conn, ext_id->name,"USB-HOST" , &motg->id.nb);if (ret <0 ) { +if (!IS_ERR (ext_vbus)) +extcon_unregister_interest (&motg->vbus.conn);dev_err (&pdev->dev,"register ID notifier failed\n" );return ret; }
@@ -1630,15 +1632,6 @@ static int msm_otg_probe(struct platform_device *pdev)if (!motg)return -ENOMEM ; - pdata =dev_get_platdata (&pdev->dev); -if (!pdata) { -if (!np) -return -ENXIO ; - ret =msm_otg_read_dt (pdev, motg); -if (ret) -return ret; - } - motg->phy.otg =devm_kzalloc (&pdev->dev,sizeof (struct usb_otg ),GFP_KERNEL );if (!motg->phy.otg)
@@ -1709,6 +1702,15 @@ static int msm_otg_probe(struct platform_device *pdev)if (ret)return ret; + pdata =dev_get_platdata (&pdev->dev); +if (!pdata) { +if (!np) +return -ENXIO ; + ret =msm_otg_read_dt (pdev, motg); +if (ret) +return ret; + } + motg->vddcx = regs[0 ].consumer; motg->v3p3 = regs[1 ].consumer; motg->v1p8 = regs[2 ].consumer;
@@ -1793,6 +1795,12 @@ disable_clks:clk_disable_unprepare (motg->clk);if (!IS_ERR (motg->core_clk))clk_disable_unprepare (motg->core_clk); + +if (motg->id.conn.edev) +extcon_unregister_interest (&motg->id.conn); +if (motg->vbus.conn.edev) +extcon_unregister_interest (&motg->vbus.conn); +return ret; }
--
1.9.1
Quoted 20 lines · Ivan T. Ivanov
Right now even if driver failed to probe extcon framework will still deliver its VBUS and ID events, which will lead to random exception codes.
Fix this by removing driver interest for VBUS and ID events when probe fail.
Fixes 591fc116f330 ("usb: phy: msm: Use extcon framework for VBUS and ID detection")Reported-by Tim Bird <[email protected]>Signed-off-by Ivan T. Ivanov <[email protected]>--- drivers/usb/phy/phy-msm-usb.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)drivers/usb/phy/phy-msm-usb.c +0
-0
drivers/usb/phy/phy-msm-usb.c static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) · line 1588
Quoted 8 lines
drivers/usb/phy/phy-msm-usb.c +2
-0@@ -1581,6 +1581,8 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) ret =extcon_register_interest (&motg->id.conn, ext_id->name,"USB-HOST" , &motg->id.nb);if (ret <0 ) { +if (!IS_ERR (ext_vbus)) +extcon_unregister_interest (&motg->vbus.conn);dev_err (&pdev->dev,"register ID notifier failed\n" );return ret; }
...
This patch is obsoleted by commit 83b7b67c7, which changes the extcon API a bit (from register_interest to register_notifier, among other things).
But, in general, I would expect this approach to work.
Do you want me to re-spin this with the new API?
-- Tim
Quoted 31 lines · Tim Bird
Quoted 28 lines · Ivan T. Ivanov
Right now even if driver failed to probe extcon framework will still deliver its VBUS and ID events, which will lead to random exception codes.
Fix this by removing driver interest for VBUS and ID events when probe fail.
Fixes 591fc116f330 ("usb: phy: msm: Use extcon framework for VBUS and ID detection")Reported-by Tim Bird [email protected]>Signed-off-by Ivan T. Ivanov [email protected]>--- drivers/usb/phy/phy-msm-usb.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-)drivers/usb/phy/phy-msm-usb.c +2
-0@@ -1581,6 +1581,8 @@ static int msm_otg_read_dt(struct platform_device *pdev, struct msm_otg *motg) ret =extcon_register_interest (&motg->id.conn, ext_id->name,"USB-HOST" , &motg->id.nb);if (ret <0 ) { +if (!IS_ERR (ext_vbus)) +extcon_unregister_interest (&motg->vbus.conn);dev_err (&pdev->dev,"register ID notifier failed\n" );return ret; }...
Quoted 2 lines
This patch is obsoleted by commit
83b7b67c7, which changes the extcon API a bit (fromregister_interesttoregister_notifier, among other things).
Ah, sorry, missed this. New version is coming.
Regards,
Ivan