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

Commit 16d42d09 authored by Sreelakshmi Gownipalli's avatar Sreelakshmi Gownipalli Committed by Gerrit - the friendly Code Review server
Browse files

diag: Add support for mhi shutdown notification



Add support for mhi shutdown notification to clear the
diag mhi states.

Change-Id: I4760c0f23bfc81280f45b5a5173492341d003adf
Signed-off-by: default avatarSreelakshmi Gownipalli <sgownipa@codeaurora.org>
parent 6293e143
Loading
Loading
Loading
Loading
+21 −8
Original line number Diff line number Diff line
/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -552,6 +552,8 @@ static void mhi_notifier(struct mhi_cb_info *cb_info)
	struct mhi_result *result = NULL;
	struct diag_mhi_ch_t *ch = NULL;
	void *buf = NULL;
	struct diag_mhi_info *mhi_info = NULL;
	unsigned long flags;

	if (!cb_info)
		return;
@@ -603,13 +605,6 @@ static void mhi_notifier(struct mhi_cb_info *cb_info)
		queue_work(diag_mhi[index].mhi_wq,
			   &(diag_mhi[index].open_work));
		break;
	case MHI_CB_MHI_DISABLED:
		DIAG_LOG(DIAG_DEBUG_BRIDGE,
			 "received mhi disabled notifiation port: %d ch: %d\n",
			 index, ch->type);
		atomic_set(&(ch->opened), 0);
		__mhi_close(&diag_mhi[index], CHANNELS_CLOSED);
		break;
	case MHI_CB_XFER:
		/*
		 * If the channel is a read channel, this is a read
@@ -636,6 +631,24 @@ static void mhi_notifier(struct mhi_cb_info *cb_info)
					   result->bytes_xferd,
					   diag_mhi[index].id);
		break;
	case MHI_CB_MHI_DISABLED:
	case MHI_CB_SYS_ERROR:
	case MHI_CB_MHI_SHUTDOWN:
		DIAG_LOG(DIAG_DEBUG_BRIDGE,
			 "received mhi link down cb: %d port: %d ch: %d\n",
			 cb_info->cb_reason, index, ch->type);
		mhi_info = &diag_mhi[index];
		if (!mhi_info->enabled)
			return;
		spin_lock_irqsave(&mhi_info->lock, flags);
		mhi_info->enabled = 0;
		spin_unlock_irqrestore(&mhi_info->lock, flags);
		atomic_set(&(mhi_info->read_ch.opened), 0);
		atomic_set(&(mhi_info->write_ch.opened), 0);
		flush_workqueue(mhi_info->mhi_wq);
		mhi_buf_tbl_clear(mhi_info);
		diag_remote_dev_close(mhi_info->dev_id);
		break;
	default:
		pr_err("diag: In %s, invalid cb reason 0x%x\n", __func__,
		       cb_info->cb_reason);