]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: wilc1000: Replace semaphore txq_add_to_head_cs with mutex
authorBinoy Jayan <binoy.jayan@linaro.org>
Wed, 15 Jun 2016 05:30:35 +0000 (11:00 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 25 Jun 2016 21:39:53 +0000 (14:39 -0700)
The semaphore 'txq_add_to_head_cs' is a simple mutex, so it should be
written as one. Semaphores are going away in the future. Also, removing
the timeout scenario as the error handling code does not propagate the
timeout properly.

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 baf9326813629e3d3177edd58c8f43062595f977..5dc645c539a823f508eece19f0dc24a218ce2e68 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/skbuff.h>
-
+#include <linux/mutex.h>
 #include <linux/semaphore.h>
 #include <linux/completion.h>
 
@@ -679,7 +679,7 @@ static int wlan_init_locks(struct net_device *dev)
        mutex_init(&wl->rxq_cs);
 
        spin_lock_init(&wl->txq_spinlock);
-       sema_init(&wl->txq_add_to_head_cs, 1);
+       mutex_init(&wl->txq_add_to_head_cs);
 
        init_completion(&wl->txq_event);
 
index 12d7c7b1a5fe847067cac85ac40d806c66c98159..239cd436861cfb7f95cf5771dbbe16348663d1b0 100644 (file)
@@ -43,6 +43,7 @@
 #include "wilc_wlan.h"
 #include <linux/wireless.h>
 #include <linux/completion.h>
+#include <linux/mutex.h>
 
 #define FLOW_CONTROL_LOWER_THRESHOLD   128
 #define FLOW_CONTROL_UPPER_THRESHOLD   256
@@ -171,7 +172,7 @@ struct wilc {
        struct wilc_vif *vif[NUM_CONCURRENT_IFC];
        u8 open_ifcs;
 
-       struct semaphore txq_add_to_head_cs;
+       struct mutex txq_add_to_head_cs;
        spinlock_t txq_spinlock;
 
        struct mutex rxq_cs;
index 1a571352bc96412b8390a0535b777c5c6e8fae52..9afbe8dc327f61548dbff3ef8adb31f323b89438 100644 (file)
@@ -99,9 +99,7 @@ static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif,
        unsigned long flags;
        struct wilc *wilc = vif->wilc;
 
-       if (wilc_lock_timeout(wilc, &wilc->txq_add_to_head_cs,
-                                   CFG_PKTS_TIMEOUT))
-               return -1;
+       mutex_lock(&wilc->txq_add_to_head_cs);
 
        spin_lock_irqsave(&wilc->txq_spinlock, flags);
 
@@ -119,7 +117,7 @@ static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif,
        wilc->txq_entries += 1;
 
        spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
-       up(&wilc->txq_add_to_head_cs);
+       mutex_unlock(&wilc->txq_add_to_head_cs);
        complete(&wilc->txq_event);
 
        return 0;
@@ -573,8 +571,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
                if (wilc->quit)
                        break;
 
-               wilc_lock_timeout(wilc, &wilc->txq_add_to_head_cs,
-                                       CFG_PKTS_TIMEOUT);
+               mutex_lock(&wilc->txq_add_to_head_cs);
                wilc_wlan_txq_filter_dup_tcp_ack(dev);
                tqe = wilc_wlan_txq_get_first(wilc);
                i = 0;
@@ -755,7 +752,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
                if (ret != 1)
                        break;
        } while (0);
-       up(&wilc->txq_add_to_head_cs);
+       mutex_unlock(&wilc->txq_add_to_head_cs);
 
        wilc->txq_exit = 1;
        *txq_count = wilc->txq_entries;