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

Commit 7457a16f authored by Ravi Aravamudhan's avatar Ravi Aravamudhan Committed by Gerrit - the friendly Code Review server
Browse files

diag: Fix issues when memory-device mode closes



Diag driver is not cleaning up the buffers properly when the logging
mode is switched from memory-device mode to USB mode. Changing the
clean up sequence solves this issue.

Change-Id: I3523748a79e37489c378393f578f54d0a44bd0b9
Signed-off-by: default avatarRavi Aravamudhan <aravamud@codeaurora.org>
parent ac38dd94
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -97,6 +97,10 @@ void diag_md_close_all()

	for (i = 0; i < NUM_DIAG_MD_DEV; i++) {
		ch = &diag_md[i];

		if (ch->ops && ch->ops->close)
			ch->ops->close(ch->ctx, DIAG_MEMORY_DEVICE_MODE);

		/*
		 * When we close the Memory device mode, make sure we flush the
		 * internal buffers in the table so that there are no stale
@@ -115,8 +119,6 @@ void diag_md_close_all()
			entry->ctx = 0;
			spin_unlock_irqrestore(&entry->lock, flags);
		}
		if (ch->ops && ch->ops->close)
			ch->ops->close(ch->ctx, DIAG_MEMORY_DEVICE_MODE);
	}

	diag_ws_reset(DIAG_WS_MUX);
+13 −3
Original line number Diff line number Diff line
@@ -375,7 +375,6 @@ static void diag_close_logging_process(int pid)
			logging_proc->socket_process = NULL;
		if (logging_proc->callback_process)
			logging_proc->callback_process = NULL;
		logging_proc->pid = 0;
		if (driver->md_client_info.client_process)
			driver->md_client_info.client_process = NULL;
		diag_update_proc_vote(DIAG_PROC_MEMORY_DEVICE, VOTE_DOWN, i);
@@ -408,14 +407,25 @@ static void diag_close_logging_process(int pid)
	 */
	for (i = 0; i < DIAG_NUM_PROC; i++) {
		logging_proc = &driver->md_proc[i];
		if (logging_proc->pid != 0) {
		if ((logging_proc->callback_process) &&
		    (logging_proc->pid != pid)) {
			switch_flag = 0;
			break;
		}
	}

	if (switch_flag)
	if (switch_flag) {
		diag_switch_logging(USB_MODE);
		mutex_lock(&driver->diagchar_mutex);
		for (i = 0; i < DIAG_NUM_PROC; i++) {
			logging_proc = &driver->md_proc[i];
			if (logging_proc->pid != pid)
				continue;
			logging_proc->pid = 0;
		}
		mutex_unlock(&driver->diagchar_mutex);
	}

}

static int diagchar_close(struct inode *inode, struct file *file)