From d3bab0eebf7aa79b33289fb844f71437bbdce0ca Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Thu, 17 Oct 2013 13:04:06 -0600 Subject: [PATCH] msm: kgsl: Fix the return value of 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: Jordan Crouse --- drivers/gpu/msm/kgsl_pwrctrl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/msm/kgsl_pwrctrl.c b/drivers/gpu/msm/kgsl_pwrctrl.c index 21c09e1e34d..f2398a57583 100644 --- a/drivers/gpu/msm/kgsl_pwrctrl.c +++ b/drivers/gpu/msm/kgsl_pwrctrl.c @@ -1631,17 +1631,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);