@@ -818,7 +818,7 @@ static inline void ci_role_destroy(struct ci_hdrc *ci)
818
818
{
819
819
ci_hdrc_gadget_destroy (ci );
820
820
ci_hdrc_host_destroy (ci );
821
- if (ci -> is_otg )
821
+ if (ci -> is_otg && ci -> roles [ CI_ROLE_GADGET ] )
822
822
ci_hdrc_otg_destroy (ci );
823
823
}
824
824
@@ -980,27 +980,35 @@ static int ci_hdrc_probe(struct platform_device *pdev)
980
980
/* initialize role(s) before the interrupt is requested */
981
981
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST ) {
982
982
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
+ }
985
989
}
986
990
987
991
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL ) {
988
992
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
+ }
991
999
}
992
1000
993
1001
if (!ci -> roles [CI_ROLE_HOST ] && !ci -> roles [CI_ROLE_GADGET ]) {
994
1002
dev_err (dev , "no supported roles\n" );
995
1003
ret = - ENODEV ;
996
- goto deinit_phy ;
1004
+ goto deinit_gadget ;
997
1005
}
998
1006
999
1007
if (ci -> is_otg && ci -> roles [CI_ROLE_GADGET ]) {
1000
1008
ret = ci_hdrc_otg_init (ci );
1001
1009
if (ret ) {
1002
1010
dev_err (dev , "init otg fails, ret = %d\n" , ret );
1003
- goto stop ;
1011
+ goto deinit_gadget ;
1004
1012
}
1005
1013
}
1006
1014
@@ -1070,7 +1078,12 @@ static int ci_hdrc_probe(struct platform_device *pdev)
1070
1078
remove_debug :
1071
1079
dbg_remove_files (ci );
1072
1080
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 );
1074
1087
deinit_phy :
1075
1088
ci_usb_phy_exit (ci );
1076
1089
ulpi_exit :
0 commit comments