From 1b30680459373432fdce21746fea58cb50e040ed Mon Sep 17 00:00:00 2001 From: Mayank Rana Date: Wed, 11 May 2016 18:26:35 -0700 Subject: [PATCH] usb: gadget: gsi: Decrement USB gadget pm usage count on cable disconnect Currently USB GSI function driver increments USB gadget device's pm usage count on set_alt() and decrements on USB bus suspend or USB cable disconnect case. Current code is not decrementing this usage count when sm_state is STATE_INITIALIZED and USB cable is disconnected (i.e. event EVT_DISCONNECTED posted). Fix this issue by decrementing USB gadget device's pm usage count by addding check for event EVT_DISCONNECTED when sm_state is STATE_INITIALIZED. CRs-Fixed: 1003242 Change-Id: I4d6c9ce254f4c4139313dfd33da6c8745f34a1d3 Signed-off-by: Mayank Rana --- drivers/usb/gadget/function/f_gsi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/gadget/function/f_gsi.c b/drivers/usb/gadget/function/f_gsi.c index 1cb5d945ba7e..4274d6962a78 100644 --- a/drivers/usb/gadget/function/f_gsi.c +++ b/drivers/usb/gadget/function/f_gsi.c @@ -568,6 +568,11 @@ static void ipa_work_handler(struct work_struct *w) d_port->sm_state = STATE_CONNECTED; log_event_dbg("%s: ST_INIT_EVT_HOST_READY", __func__); + } else if (event == EVT_DISCONNECTED) { + usb_gadget_autopm_put_async(d_port->gadget); + log_event_dbg("%s: ST_INIT_EVT_DISC", __func__); + log_event_dbg("%s: put_async1 = %d", __func__, + atomic_read(&gad_dev->power.usage_count)); } break; case STATE_CONNECT_IN_PROGRESS: