From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753077AbcGYTTa (ORCPT ); Mon, 25 Jul 2016 15:19:30 -0400 Received: from www.osadl.org ([62.245.132.105]:34848 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751360AbcGYTT2 (ORCPT ); Mon, 25 Jul 2016 15:19:28 -0400 From: Nicholas Mc Guire To: Greg Kroah-Hartman Cc: Wolfram Sang , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH] staging: ks7010: fix wait_for_completion_interruptible_timeout return handling Date: Mon, 25 Jul 2016 21:21:50 +0200 Message-Id: <1469474510-15551-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org wait_for_completion_interruptible_timeout return 0 on timeout and -ERESTARTSYS if interrupted. The check for !wait_for_completion_interruptible_timeout() would report an interrupt as timeout. Further, while HZ/50 will work most of the time it could fail for HZ < 50, so this is switched to msecs_to_jiffies(20). Fixes: 13a9930d15b4 ("staging: ks7010: add driver from Nanonote extra-repository") Signed-off-by: Nicholas Mc Guire --- API non-compliance was located by coccinelle Note: build showed some sparse warnings CHECK drivers/staging/ks7010/ks_hostif.c drivers/staging/ks7010/ks_hostif.c:72:6: warning: symbol 'ks_wlan_hw_wakeup_task' was not declared. Should it be static? drivers/staging/ks7010/ks_hostif.c:1512:6: warning: symbol 'hostif_infrastructure_set2_request' was not declared. Should it be static? Compile tested with: x86_64_defconfig + CONFIG_STAGING=y CONFIG_MMC=m, CONFIG_KS7010=m Patch is against 4.7-rc7 (localversion-next -next-20160725) drivers/staging/ks7010/ks_hostif.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index a8822fe..4d32c98 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -74,11 +74,15 @@ void ks_wlan_hw_wakeup_task(struct work_struct *work) struct ks_wlan_private *priv = container_of(work, struct ks_wlan_private, ks_wlan_wakeup_task); int ps_status = atomic_read(&priv->psstatus.status); + long time_left; if (ps_status == PS_SNOOZE) { ks_wlan_hw_wakeup_request(priv); - if (!wait_for_completion_interruptible_timeout(&priv->psstatus.wakeup_wait, HZ / 50)) { /* 20ms timeout */ - DPRINTK(1, "wake up timeout !!!\n"); + time_left = wait_for_completion_interruptible_timeout( + &priv->psstatus.wakeup_wait, + msecs_to_jiffies(20)); + if (time_left <= 0) { + DPRINTK(1, "wake up timeout or interrupted !!!\n"); schedule_work(&priv->ks_wlan_wakeup_task); return; } -- 2.1.4