From 029eebcb5e040f9b4163b452acb9beaef1a5cfd7 Mon Sep 17 00:00:00 2001 From: Chris Lew Date: Mon, 22 Feb 2016 11:04:26 -0800 Subject: [PATCH] diag: Close MD session when switching to USB Mode Cannot switch from memory device logging to USB Mode after the first switch because the first MD state is stored. This fix resets the MD state by closing the session when switching to USB Mode from MD mode. Change-Id: I9addf0c7d8f1c058485349e196c1dcaa54b92f3a CRs-Fixed: 972027 Signed-off-by: Chris Lew --- drivers/char/diag/diagchar_core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/char/diag/diagchar_core.c b/drivers/char/diag/diagchar_core.c index 27065a140fbf..d38a0f3fdaa2 100644 --- a/drivers/char/diag/diagchar_core.c +++ b/drivers/char/diag/diagchar_core.c @@ -1340,6 +1340,7 @@ static int diag_md_session_check(int curr_mode, int req_mode, uint8_t *change_mode) { int err = 0; + struct diag_md_session_t *session_info = NULL; if (!param || !change_mode) return -EIO; @@ -1404,8 +1405,10 @@ static int diag_md_session_check(int curr_mode, int req_mode, "another instance running\n"); *change_mode = 0; return -EINVAL; - } else - return 0; + } + session_info = diag_md_session_get_pid(current->tgid); + diag_md_session_close(session_info); + return 0; } if (param->mode_param == DIAG_MD_NORMAL) {