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

Commit 2231fbb3 authored by Ajay Agarwal's avatar Ajay Agarwal
Browse files

usb: gadget: f_ipc: Update online flag in set_alt/disable



Currently the driver updates online flag to true as a part of
connect function_work handling. If the function suspend is issued
by the host before this connect work could get scheduled, then
the online flag will be set to true but ep_queue will fail and
it will wait for function resume to get called. While this is
functionally not an issue but logically incorrect.
Fix this by moving the updation of online flag out of workqueue
to set_alt/disable functions.

Change-Id: I633b33cc50bfaac1f7281e3ab28fcbbdf9ec72e0
Signed-off-by: default avatarAjay Agarwal <ajaya@codeaurora.org>
parent f33c55b9
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -407,7 +407,6 @@ static void ipc_function_work(struct work_struct *w)
			break;

		ctxt->current_state = IPC_CONNECTED;
		ctxt->online = 1;
		ctxt->pdev = platform_device_alloc("ipc_bridge", -1);
		if (!ctxt->pdev)
			goto pdev_fail;
@@ -432,7 +431,6 @@ static void ipc_function_work(struct work_struct *w)
			break;

		ctxt->current_state = IPC_DISCONNECTED;
		ctxt->online = 0;
		wake_up(&ctxt->state_wq);
		platform_device_unregister(ctxt->pdev);
		break;
@@ -443,7 +441,6 @@ static void ipc_function_work(struct work_struct *w)
	return;

pdev_fail:
	ctxt->online = 0;
	ctxt->current_state = IPC_DISCONNECTED;
	return;
}
@@ -592,6 +589,7 @@ static int ipc_set_alt(struct usb_function *f, unsigned int intf,

	spin_lock_irqsave(&ctxt->lock, flags);
	ctxt->connected = 1;
	ctxt->online = 1;
	spin_unlock_irqrestore(&ctxt->lock, flags);
	schedule_work(&ctxt->func_work);

@@ -605,6 +603,7 @@ static void ipc_disable(struct usb_function *f)

	pr_debug("%s: Disabling\n", __func__);
	spin_lock_irqsave(&ctxt->lock, flags);
	ctxt->online = 0;
	ctxt->connected = 0;
	spin_unlock_irqrestore(&ctxt->lock, flags);
	schedule_work(&ctxt->func_work);