Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4b0289c5 authored by Mayank Rana's avatar Mayank Rana Committed by Kyle Yan
Browse files

usb: gadget: gsi: Fix reporting of USB device's usage count



Currently driver is reading and logging usage count of gadget
device but it is required to use usage count of gadget's parent
device which is used to prevent USB controller's low power mode.
Hence fix reporting of USB devices' usage count.

Also mark sm_state to initialized and remove queueing of
ipa_usb_wq as ipa_work_handler() is running without USB gadget
is initialized i.e. gadget is NULL.

CRs-Fixed: 1021499
Change-Id: Ia64afa3adb769674f6a9a60fde2c7397b7e4fe49
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent d44fbf35
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -532,19 +532,30 @@ static void ipa_work_handler(struct work_struct *w)
						  usb_ipa_w);
	u8 event;
	int ret = 0;
	struct device *gad_dev = &d_port->gadget->dev;
	struct usb_gadget *gadget = d_port->gadget;
	struct device *dev;
	struct device *gad_dev;

	event = read_event(d_port);

	log_event_dbg("%s: event = %x sm_state %x", __func__,
			event, d_port->sm_state);

	if (gadget) {
		dev = &gadget->dev;
		if (!dev || !dev->parent) {
			log_event_err("%s(): dev or dev->parent is NULL.\n",
					__func__);
			return;
		}
		gad_dev = dev->parent;
	} else {
		log_event_err("%s(): gadget is NULL.\n", __func__);
		return;
	}

	switch (d_port->sm_state) {
	case STATE_UNINITIALIZED:
		if (event == EVT_INITIALIZED) {
			d_port->sm_state = STATE_INITIALIZED;
			log_event_dbg("%s: ST_INIT_EVT_INIT", __func__);
		}
		break;
	case STATE_INITIALIZED:
		if (event == EVT_CONNECT_IN_PROGRESS) {
@@ -2522,8 +2533,7 @@ static int gsi_bind(struct usb_configuration *c, struct usb_function *f)
		goto dereg_rndis;
	}

	post_event(&gsi->d_port, EVT_INITIALIZED);
	queue_work(gsi->d_port.ipa_usb_wq, &gsi->d_port.usb_ipa_w);
	gsi->d_port.sm_state = STATE_INITIALIZED;

	DBG(cdev, "%s: %s speed IN/%s OUT/%s NOTIFY/%s\n",
			f->name,