Skip to content

Commit 6e5c751

Browse files
committed
Merge tag 'usb-ci-v4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/peter.chen/usb into usb-next
Peter writes: One patch to improve error handling at chipidea core
2 parents 9c691cc + c4a0bbb commit 6e5c751

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

drivers/usb/chipidea/core.c

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ static inline void ci_role_destroy(struct ci_hdrc *ci)
818818
{
819819
ci_hdrc_gadget_destroy(ci);
820820
ci_hdrc_host_destroy(ci);
821-
if (ci->is_otg)
821+
if (ci->is_otg && ci->roles[CI_ROLE_GADGET])
822822
ci_hdrc_otg_destroy(ci);
823823
}
824824

@@ -980,27 +980,35 @@ static int ci_hdrc_probe(struct platform_device *pdev)
980980
/* initialize role(s) before the interrupt is requested */
981981
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
982982
ret = ci_hdrc_host_init(ci);
983-
if (ret)
984-
dev_info(dev, "doesn't support host\n");
983+
if (ret) {
984+
if (ret == -ENXIO)
985+
dev_info(dev, "doesn't support host\n");
986+
else
987+
goto deinit_phy;
988+
}
985989
}
986990

987991
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
988992
ret = ci_hdrc_gadget_init(ci);
989-
if (ret)
990-
dev_info(dev, "doesn't support gadget\n");
993+
if (ret) {
994+
if (ret == -ENXIO)
995+
dev_info(dev, "doesn't support gadget\n");
996+
else
997+
goto deinit_host;
998+
}
991999
}
9921000

9931001
if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
9941002
dev_err(dev, "no supported roles\n");
9951003
ret = -ENODEV;
996-
goto deinit_phy;
1004+
goto deinit_gadget;
9971005
}
9981006

9991007
if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) {
10001008
ret = ci_hdrc_otg_init(ci);
10011009
if (ret) {
10021010
dev_err(dev, "init otg fails, ret = %d\n", ret);
1003-
goto stop;
1011+
goto deinit_gadget;
10041012
}
10051013
}
10061014

@@ -1070,7 +1078,12 @@ static int ci_hdrc_probe(struct platform_device *pdev)
10701078
remove_debug:
10711079
dbg_remove_files(ci);
10721080
stop:
1073-
ci_role_destroy(ci);
1081+
if (ci->is_otg && ci->roles[CI_ROLE_GADGET])
1082+
ci_hdrc_otg_destroy(ci);
1083+
deinit_gadget:
1084+
ci_hdrc_gadget_destroy(ci);
1085+
deinit_host:
1086+
ci_hdrc_host_destroy(ci);
10741087
deinit_phy:
10751088
ci_usb_phy_exit(ci);
10761089
ulpi_exit:

0 commit comments

Comments
 (0)