staging: wilc1000: Replace semaphore txq_event with completion
authorBinoy Jayan <binoy.jayan@linaro.org>
Wed, 15 Jun 2016 05:30:34 +0000 (11:00 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2016 21:39:53 +0000 (14:39 -0700)
The semaphore 'txq_event' is used as completion, so convert it
to a struct completion type.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/linux_wlan.c
drivers/staging/wilc1000/wilc_wfi_netdevice.h
drivers/staging/wilc1000/wilc_wlan.c

index 274c390d17cd84eabac61d201c14cc08f3584d39..baf9326813629e3d3177edd58c8f43062595f977 100644 (file)
@@ -316,7 +316,7 @@ static int linux_wlan_txq_task(void *vp)
 
        complete(&wl->txq_thread_started);
        while (1) {
-               down(&wl->txq_event);
+               wait_for_completion(&wl->txq_event);
 
                if (wl->close) {
                        complete(&wl->txq_thread_started);
@@ -650,7 +650,7 @@ void wilc1000_wlan_deinit(struct net_device *dev)
                        mutex_unlock(&wl->hif_cs);
                }
                if (&wl->txq_event)
-                       up(&wl->txq_event);
+                       wait_for_completion(&wl->txq_event);
 
                wlan_deinitialize_threads(dev);
                deinit_irq(dev);
@@ -681,7 +681,7 @@ static int wlan_init_locks(struct net_device *dev)
        spin_lock_init(&wl->txq_spinlock);
        sema_init(&wl->txq_add_to_head_cs, 1);
 
-       sema_init(&wl->txq_event, 0);
+       init_completion(&wl->txq_event);
 
        sema_init(&wl->cfg_event, 0);
        sema_init(&wl->sync_event, 0);
@@ -738,7 +738,7 @@ static void wlan_deinitialize_threads(struct net_device *dev)
        wl->close = 1;
 
        if (&wl->txq_event)
-               up(&wl->txq_event);
+               complete(&wl->txq_event);
 
        if (wl->txq_thread) {
                kthread_stop(wl->txq_thread);
index 3a561df6d370b896a06b689de801ee7bba78ec01..12d7c7b1a5fe847067cac85ac40d806c66c98159 100644 (file)
@@ -42,6 +42,7 @@
 #include "host_interface.h"
 #include "wilc_wlan.h"
 #include <linux/wireless.h>
+#include <linux/completion.h>
 
 #define FLOW_CONTROL_LOWER_THRESHOLD   128
 #define FLOW_CONTROL_UPPER_THRESHOLD   256
@@ -178,7 +179,7 @@ struct wilc {
 
        struct semaphore cfg_event;
        struct semaphore sync_event;
-       struct semaphore txq_event;
+       struct completion txq_event;
        struct completion txq_thread_started;
 
        struct task_struct *txq_thread;
index 11e16d56ace701248bbd709d4ff0e2b87446b3d2..1a571352bc96412b8390a0535b777c5c6e8fae52 100644 (file)
@@ -1,3 +1,4 @@
+#include <linux/completion.h>
 #include "wilc_wlan_if.h"
 #include "wilc_wlan.h"
 #include "wilc_wfi_netdevice.h"
@@ -89,7 +90,7 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev,
 
        spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
 
-       up(&wilc->txq_event);
+       complete(&wilc->txq_event);
 }
 
 static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif,
@@ -119,7 +120,7 @@ static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif,
 
        spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
        up(&wilc->txq_add_to_head_cs);
-       up(&wilc->txq_event);
+       complete(&wilc->txq_event);
 
        return 0;
 }
@@ -287,7 +288,8 @@ static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev)
        spin_unlock_irqrestore(&wilc->txq_spinlock, wilc->txq_spinlock_flags);
 
        while (dropped > 0) {
-               wilc_lock_timeout(wilc, &wilc->txq_event, 1);
+               wait_for_completion_timeout(&wilc->txq_event,
+                                               msecs_to_jiffies(1));
                dropped--;
        }