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

Commit 6b8562f0 authored by Mohit Aggarwal's avatar Mohit Aggarwal
Browse files

diag: Release wake source properly



Currently, diag driver is not releasing wake
source on receiving 0 length packet from SMD.
This patch ensures that the wake sources
hold are released properly.

Change-Id: I4eefc0d361a130c7f313b8ba215f51ecf32e0923
Signed-off-by: default avatarMohit Aggarwal <maggarwa@codeaurora.org>
parent 5f838c4f
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
/* Copyright (c) 2015, The Linux Foundation. All rights reserved.
/* Copyright (c) 2015-2016, 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
@@ -727,11 +727,13 @@ static int diag_smd_read(void *ctxt, unsigned char *buf, int buf_len)
	    !atomic_read(&smd_info->opened))
		return -EIO;

	/*
	 * Always try to read the data if notification is received from smd
	 * In case if packet size is 0 release the wake source hold earlier
	 */
	err = wait_event_interruptible(smd_info->read_wait_q,
				       (smd_info->hdl == NULL) ||
				       (atomic_read(&smd_info->opened) == 0) ||
				       (smd_cur_packet_size(smd_info->hdl)) ||
				       (!atomic_read(&smd_info->diag_state)));
				       (smd_info->hdl != NULL) &&
				       (atomic_read(&smd_info->opened) == 1));
	if (err) {
		diagfwd_channel_read_done(smd_info->fwd_ctxt, buf, 0);
		return -ERESTARTSYS;