One patch to improve error handling at chipidea core

-----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQEcBAABAgAGBQJZSdzXAAoJEEhZKYFQ1nG7M1YH/0tSpERwjAaL8xmKjm1KDO9v
 EeeTC/P7nkv1iWRdMGZuun8cOivuTD4aC/IuXh6G40FkgUUMZI8qayt+JnS6eiv/
 fVbX1L6lP8UnP9C8HHQcANCVlOHysPlbG3hdfpAVjtz56sqdK7NGFakdhHqBerx9
 xcD40glwLUpt3jrZfcHPepF9WMn/3eA0GsTXyydHuL/D+jejCUu4kVPICdfOm7Vr
 k+E0oilsjfYSxA4NRaqjd5CDpAiPPKQ/g37DIfG13A9bBjvDSQbky4Y69ibVWLqv
 sGGCnLeFGx3L798GKeV6bDsKU8NEYF93pnFlQ5FBY5PjYU3mudEXAB/fpVBGagA=
 =KEw/
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Greg Kroah-Hartman 2017-06-27 17:35:31 +02:00
commit 6e5c7514e7

View file

@ -818,7 +818,7 @@ static inline void ci_role_destroy(struct ci_hdrc *ci)
{
ci_hdrc_gadget_destroy(ci);
ci_hdrc_host_destroy(ci);
if (ci->is_otg)
if (ci->is_otg && ci->roles[CI_ROLE_GADGET])
ci_hdrc_otg_destroy(ci);
}
@ -980,27 +980,35 @@ static int ci_hdrc_probe(struct platform_device *pdev)
/* initialize role(s) before the interrupt is requested */
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_HOST) {
ret = ci_hdrc_host_init(ci);
if (ret)
dev_info(dev, "doesn't support host\n");
if (ret) {
if (ret == -ENXIO)
dev_info(dev, "doesn't support host\n");
else
goto deinit_phy;
}
}
if (dr_mode == USB_DR_MODE_OTG || dr_mode == USB_DR_MODE_PERIPHERAL) {
ret = ci_hdrc_gadget_init(ci);
if (ret)
dev_info(dev, "doesn't support gadget\n");
if (ret) {
if (ret == -ENXIO)
dev_info(dev, "doesn't support gadget\n");
else
goto deinit_host;
}
}
if (!ci->roles[CI_ROLE_HOST] && !ci->roles[CI_ROLE_GADGET]) {
dev_err(dev, "no supported roles\n");
ret = -ENODEV;
goto deinit_phy;
goto deinit_gadget;
}
if (ci->is_otg && ci->roles[CI_ROLE_GADGET]) {
ret = ci_hdrc_otg_init(ci);
if (ret) {
dev_err(dev, "init otg fails, ret = %d\n", ret);
goto stop;
goto deinit_gadget;
}
}
@ -1070,7 +1078,12 @@ static int ci_hdrc_probe(struct platform_device *pdev)
remove_debug:
dbg_remove_files(ci);
stop:
ci_role_destroy(ci);
if (ci->is_otg && ci->roles[CI_ROLE_GADGET])
ci_hdrc_otg_destroy(ci);
deinit_gadget:
ci_hdrc_gadget_destroy(ci);
deinit_host:
ci_hdrc_host_destroy(ci);
deinit_phy:
ci_usb_phy_exit(ci);
ulpi_exit: