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

Commit 08c77e77 authored by Jordan Crouse's avatar Jordan Crouse
Browse files

msm: kgsl: Return the correct error from kgsl_active_count_wait()



kgsl_active_count_wait() is very badly crafted. If the active count
is already under the threshold (as it often is - a successful condition)
the conditional at the end of the function returns -ETIMEDOUT instead
of 0. Return the proper error value so the caller can make a wise
decision based on the result.

Change-Id: Ic0dedbadb948820cf64e3131f895fa3d15247cac
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
parent 3b8fb39d
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -1593,17 +1593,19 @@ static int _check_active_count(struct kgsl_device *device, int count)
 */
int kgsl_active_count_wait(struct kgsl_device *device, int count)
{
	int ret = 0;
	int result = 0;

	BUG_ON(!mutex_is_locked(&device->mutex));

	if (atomic_read(&device->active_cnt) > count) {
		int ret;
		mutex_unlock(&device->mutex);
		ret = wait_event_timeout(device->active_cnt_wq,
			_check_active_count(device, count), HZ);
		mutex_lock(&device->mutex);
		result = ret == 0 ? -ETIMEDOUT : 0;
	}

	return ret == 0 ? -ETIMEDOUT : 0;
	return result;
}
EXPORT_SYMBOL(kgsl_active_count_wait);