@@ -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)
10701078remove_debug :
10711079 dbg_remove_files (ci );
10721080stop :
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 );
10741087deinit_phy :
10751088 ci_usb_phy_exit (ci );
10761089ulpi_exit :
0 commit comments