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

Commit 5b5d088c authored by Ravi Aravamudhan's avatar Ravi Aravamudhan
Browse files

diag: Reset rsp_buf_busy flag when switching to USB mode



When a client switches from callback mode to USB mode explicitly,
there is a possibility that the last response is not drained to the
user space. Reset the rsp_buf_busy flag in such scenarios so that
we don't hold on to the response buffer forever.

Change-Id: I0be80174e8193174eb53a768c5ed3a4e322d50ec
Signed-off-by: default avatarRavi Aravamudhan <aravamud@codeaurora.org>
parent 8ae7326c
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -1875,6 +1875,7 @@ int diagfwd_connect(void)
{
	int err;
	int i;
	unsigned long flags;

	printk(KERN_DEBUG "diag: USB connected\n");
	err = usb_diag_alloc_req(driver->legacy_ch,
@@ -1884,6 +1885,17 @@ int diagfwd_connect(void)
	if (err)
		goto exit;
	driver->usb_connected = 1;
	if (driver->rsp_buf_busy) {
		/*
		 * When a client switches from callback mode to USB mode
		 * explicitly, there can be a situation when the last response
		 * is not drained to the user space application. Reset the
		 * in_busy flag in this case.
		 */
		spin_lock_irqsave(&driver->rsp_buf_busy_lock, flags);
		driver->rsp_buf_busy = 0;
		spin_unlock_irqrestore(&driver->rsp_buf_busy_lock, flags);
	}
	diag_reset_smd_data(RESET_AND_QUEUE);
	for (i = 0; i < NUM_SMD_CONTROL_CHANNELS; i++) {
		/* Poll SMD CNTL channels to check for data */