]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: ks7010: fix wait_for_completion_interruptible_timeout return handling
authorNicholas Mc Guire <hofrat@osadl.org>
Mon, 25 Jul 2016 19:21:50 +0000 (21:21 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Aug 2016 16:12:57 +0000 (18:12 +0200)
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 <hofrat@osadl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ks7010/ks_hostif.c

index a8822fe2bd60295ded9a8dfc15d5ee75556bd406..6deee462eca7092369fb5b2d58a799a5a92e3906 100644 (file)
@@ -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;
                }