From: Peter Chen Date: Wed, 19 Feb 2020 09:25:48 +0000 (+0800) Subject: usb: chipidea: otg: handling vbus disconnect event occurred during system suspend X-Git-Tag: v5.7-rc1~192^2~26^2~1 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3ac82cf3f80c2ddc1964408a213f84ac538875dc;p=users%2Fwilly%2Flinux.git usb: chipidea: otg: handling vbus disconnect event occurred during system suspend During system suspend, the role switch may occur, eg, from gadget->host. In this case, the vbus disconnect event is lost, we add this handling in role switch routine in this commit. Signed-off-by: Peter Chen --- diff --git a/drivers/usb/chipidea/otg.c b/drivers/usb/chipidea/otg.c index fbfb02e05c97..be63924ea82e 100644 --- a/drivers/usb/chipidea/otg.c +++ b/drivers/usb/chipidea/otg.c @@ -170,6 +170,13 @@ static void ci_handle_id_switch(struct ci_hdrc *ci) dev_dbg(ci->dev, "switching from %s to %s\n", ci_role(ci)->name, ci->roles[role]->name); + if (ci->vbus_active && ci->role == CI_ROLE_GADGET) + /* + * vbus disconnect event is lost due to role + * switch occurs during system suspend. + */ + usb_gadget_vbus_disconnect(&ci->gadget); + ci_role_stop(ci); if (role == CI_ROLE_GADGET &&