staging: wilc1000: remove wrappers around semaphore usage
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Sep 2015 03:07:58 +0000 (20:07 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Sep 2015 01:24:41 +0000 (18:24 -0700)
Just call up/down directly, no need for a wrapper function that hides
what is really happening.  Fix up some variable types to be the correct
structure pointers, not void *.

Cc: Johnny Kim <johnny.kim@atmel.com>
Cc: Rachel Kim <rachel.kim@atmel.com>
Cc: Dean Lee <dean.lee@atmel.com>
Cc: Chris Park <chris.park@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/linux_wlan.c
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
drivers/staging/wilc1000/wilc_wfi_netdevice.h
drivers/staging/wilc1000/wilc_wlan.c
drivers/staging/wilc1000/wilc_wlan_if.h

index c342977..84bdfc1 100644 (file)
@@ -147,8 +147,6 @@ unsigned int int_clrd;
 
 static int wlan_deinit_locks(linux_wlan_t *nic);
 static void wlan_deinitialize_threads(linux_wlan_t *nic);
-static void linux_wlan_lock(void *vp);
-void linux_wlan_unlock(void *vp);
 extern void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size);
 extern void WILC_WFI_p2p_rx(struct net_device *dev, uint8_t *buff, uint32_t size);
 
@@ -387,7 +385,7 @@ static irqreturn_t isr_uh_routine(int irq, void *user_data)
        schedule_work(&g_linux_wlan->rx_work_queue);
        return IRQ_HANDLED;
 #elif (RX_BH_TYPE == RX_BH_KTHREAD)
-       linux_wlan_unlock(&g_linux_wlan->rx_sem);
+       up(&g_linux_wlan->rx_sem);
        return IRQ_HANDLED;
 #elif (RX_BH_TYPE == RX_BH_THREADED_IRQ)
        return IRQ_WAKE_THREAD;
@@ -441,7 +439,7 @@ static int isr_bh_routine(void *vp)
        nic = (linux_wlan_t *)vp;
 
        while (1) {
-               linux_wlan_lock(&nic->rx_sem);
+               down(&nic->rx_sem);
                if (g_linux_wlan->close) {
 
                        while (!kthread_should_stop())
@@ -545,17 +543,6 @@ static void linux_wlan_dbg(uint8_t *buff)
        PRINT_D(INIT_DBG, "%d\n", *buff);
 }
 
-static void linux_wlan_lock(void *vp)
-{
-       PRINT_D(LOCK_DBG, "Locking %p\n", vp);
-       if (vp != NULL) {
-               while (down_interruptible((struct semaphore *) vp))
-                       ;
-       } else {
-               PRINT_ER("Failed, mutex is NULL\n");
-       }
-}
-
 static int linux_wlan_lock_timeout(void *vp, u32 timeout)
 {
        int error = -1;
@@ -568,15 +555,6 @@ static int linux_wlan_lock_timeout(void *vp, u32 timeout)
        return error;
 }
 
-void linux_wlan_unlock(void *vp)
-{
-       PRINT_D(LOCK_DBG, "Unlocking %p\n", vp);
-       if (vp != NULL)
-               up((struct semaphore *)vp);
-       else
-               PRINT_ER("Failed, mutex is NULL\n");
-}
-
 static void linux_wlan_spin_lock(void *vp, unsigned long *flags)
 {
        unsigned long lflags;
@@ -614,7 +592,7 @@ static void linux_wlan_mac_indicate(int flag)
                pd->oup.wlan_cfg_get_value(WID_STATUS, (unsigned char *)&status, 4);
                if (pd->mac_status == WILC_MAC_STATUS_INIT) {
                        pd->mac_status = status;
-                       linux_wlan_unlock(&pd->sync_event);
+                       up(&pd->sync_event);
                } else {
                        pd->mac_status = status;
                }
@@ -695,14 +673,14 @@ static int linux_wlan_rxq_task(void *vp)
 {
 
        /* inform wilc1000_wlan_init that RXQ task is started. */
-       linux_wlan_unlock(&g_linux_wlan->rxq_thread_started);
+       up(&g_linux_wlan->rxq_thread_started);
        while (1) {
-               linux_wlan_lock(&g_linux_wlan->rxq_event);
+               down(&g_linux_wlan->rxq_event);
                /* wait_for_completion(&g_linux_wlan->rxq_event); */
 
                if (g_linux_wlan->close) {
                        /*Unlock the mutex in the mac_close function to indicate the exiting of the RX thread */
-                       linux_wlan_unlock(&g_linux_wlan->rxq_thread_started);
+                       up(&g_linux_wlan->rxq_thread_started);
 
                        while (!kthread_should_stop())
                                schedule();
@@ -733,17 +711,17 @@ static int linux_wlan_txq_task(void *vp)
 #endif
 
        /* inform wilc1000_wlan_init that TXQ task is started. */
-       linux_wlan_unlock(&g_linux_wlan->txq_thread_started);
+       up(&g_linux_wlan->txq_thread_started);
        while (1) {
 
                PRINT_D(TX_DBG, "txq_task Taking a nap :)\n");
-               linux_wlan_lock(&g_linux_wlan->txq_event);
+               down(&g_linux_wlan->txq_event);
                /* wait_for_completion(&pd->txq_event); */
                PRINT_D(TX_DBG, "txq_task Who waked me up :$\n");
 
                if (g_linux_wlan->close) {
                        /*Unlock the mutex in the mac_close function to indicate the exiting of the TX thread */
-                       linux_wlan_unlock(&g_linux_wlan->txq_thread_started);
+                       up(&g_linux_wlan->txq_thread_started);
 
                        while (!kthread_should_stop())
                                schedule();
@@ -1236,10 +1214,10 @@ void wilc1000_wlan_deinit(linux_wlan_t *nic)
 
                /* not sure if the following unlocks are needed or not*/
                if (&g_linux_wlan->rxq_event != NULL)
-                       linux_wlan_unlock(&g_linux_wlan->rxq_event);
+                       up(&g_linux_wlan->rxq_event);
 
                if (&g_linux_wlan->txq_event != NULL)
-                       linux_wlan_unlock(&g_linux_wlan->txq_event);
+                       up(&g_linux_wlan->txq_event);
 
        #if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
                /*Removing the work struct from the linux kernel workqueue*/
@@ -1248,7 +1226,7 @@ void wilc1000_wlan_deinit(linux_wlan_t *nic)
 
        #elif (RX_BH_TYPE == RX_BH_KTHREAD)
                /* if(&nic->rx_sem != NULL) */
-               /* linux_wlan_unlock(&nic->rx_sem); */
+               /* up(&nic->rx_sem); */
        #endif
 
                PRINT_D(INIT_DBG, "Deinitializing Threads\n");
@@ -1359,10 +1337,7 @@ void linux_to_wlan(wilc_wlan_inp_t *nwi, linux_wlan_t *nic)
 
        nwi->os_func.os_sleep = linux_wlan_msleep;
        nwi->os_func.os_debug = linux_wlan_dbg;
-       nwi->os_func.os_lock = linux_wlan_lock;
-       nwi->os_func.os_unlock = linux_wlan_unlock;
        nwi->os_func.os_wait = linux_wlan_lock_timeout;
-       nwi->os_func.os_signal = linux_wlan_unlock;
 
        /*Added by Amr - BugID_4720*/
        nwi->os_func.os_spin_lock = linux_wlan_spin_lock;
@@ -1428,7 +1403,7 @@ int wlan_initialize_threads(perInterface_wlan_t *nic)
        }
 
        /* wait for RXQ task to start. */
-       linux_wlan_lock(&g_linux_wlan->rxq_thread_started);
+       down(&g_linux_wlan->rxq_thread_started);
 
 #endif
 
@@ -1450,14 +1425,14 @@ int wlan_initialize_threads(perInterface_wlan_t *nic)
        }
 #endif
        /* wait for TXQ task to start. */
-       linux_wlan_lock(&g_linux_wlan->txq_thread_started);
+       down(&g_linux_wlan->txq_thread_started);
 
        return 0;
 
 _fail_2:
        /*De-Initialize 2nd thread*/
        g_linux_wlan->close = 1;
-       linux_wlan_unlock(&g_linux_wlan->rxq_event);
+       up(&g_linux_wlan->rxq_event);
        kthread_stop(g_linux_wlan->rxq_thread);
 
 #ifndef TCP_ENHANCEMENTS
@@ -1466,7 +1441,7 @@ _fail_1:
        #if (RX_BH_TYPE == RX_BH_KTHREAD)
        /*De-Initialize 1st thread*/
        g_linux_wlan->close = 1;
-       linux_wlan_unlock(&g_linux_wlan->rx_sem);
+       up(&g_linux_wlan->rx_sem);
        kthread_stop(g_linux_wlan->rx_bh_thread);
 _fail_:
        #endif
@@ -1480,7 +1455,7 @@ static void wlan_deinitialize_threads(linux_wlan_t *nic)
        g_linux_wlan->close = 1;
        PRINT_D(INIT_DBG, "Deinitializing Threads\n");
        if (&g_linux_wlan->rxq_event != NULL)
-               linux_wlan_unlock(&g_linux_wlan->rxq_event);
+               up(&g_linux_wlan->rxq_event);
 
        if (g_linux_wlan->rxq_thread != NULL) {
                kthread_stop(g_linux_wlan->rxq_thread);
@@ -1488,7 +1463,7 @@ static void wlan_deinitialize_threads(linux_wlan_t *nic)
        }
 
        if (&g_linux_wlan->txq_event != NULL)
-               linux_wlan_unlock(&g_linux_wlan->txq_event);
+               up(&g_linux_wlan->txq_event);
 
        if (g_linux_wlan->txq_thread != NULL) {
                kthread_stop(g_linux_wlan->txq_thread);
@@ -1497,7 +1472,7 @@ static void wlan_deinitialize_threads(linux_wlan_t *nic)
 
        #if (RX_BH_TYPE == RX_BH_KTHREAD)
        if (&g_linux_wlan->rx_sem != NULL)
-               linux_wlan_unlock(&g_linux_wlan->rx_sem);
+               up(&g_linux_wlan->rx_sem);
 
        if (g_linux_wlan->rx_bh_thread != NULL) {
                kthread_stop(g_linux_wlan->rx_bh_thread);
@@ -1919,7 +1894,7 @@ int mac_open(struct net_device *ndev)
        /* Start the network interface queue for this device */
        PRINT_D(INIT_DBG, "Starting netifQ\n");
        netif_start_queue(ndev);
-/*     linux_wlan_lock(&close_exit_sync); */
+/*     down(&close_exit_sync); */
        return 0;
 }
 #endif
@@ -2133,7 +2108,7 @@ int mac_close(struct net_device *ndev)
                #endif
        }
 
-       linux_wlan_unlock(&close_exit_sync);
+       up(&close_exit_sync);
        nic->mac_opened = 0;
 
        return 0;
index ead1291..75e1687 100644 (file)
@@ -23,7 +23,6 @@
 #define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
 
 extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
-extern void linux_wlan_unlock(void *vp);
 extern u16 Set_machw_change_vir_if(bool bValue);
 
 extern int mac_open(struct net_device *ndev);
@@ -2898,7 +2897,7 @@ static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev
 
                        /*BugID_5213*/
                        /*Eliminate host interface blocking state*/
-                       linux_wlan_unlock((void *)&g_linux_wlan->cfg_event);
+                       up(&g_linux_wlan->cfg_event);
 
                        wilc1000_wlan_deinit(g_linux_wlan);
                        wilc1000_wlan_init(dev, nic);
index d1de032..8047dd9 100644 (file)
@@ -199,13 +199,10 @@ typedef struct {
        struct mutex rxq_cs;
        struct mutex hif_cs;
 
-       /* struct mutex txq_event; */
        struct semaphore rxq_event;
        struct semaphore cfg_event;
        struct semaphore sync_event;
-
        struct semaphore txq_event;
-       /* struct completion txq_event; */
 
 #if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
        struct work_struct rx_work_queue;
index e1b248d..e34ce53 100644 (file)
@@ -76,7 +76,7 @@ typedef struct {
        void *txq_lock;
 
        /*Added by Amr - BugID_4720*/
-       void *txq_add_to_head_lock;
+       struct semaphore *txq_add_to_head_lock;
        void *txq_spinlock;
        unsigned long txq_spinlock_flags;
 
@@ -238,9 +238,7 @@ static void wilc_wlan_txq_add_to_tail(struct txq_entry_t *tqe)
         **/
        PRINT_D(TX_DBG, "Wake the txq_handling\n");
 
-       p->os_func.os_signal(p->txq_wait);
-
-
+       up(p->txq_wait);
 }
 
 static int wilc_wlan_txq_add_to_head(struct txq_entry_t *tqe)
@@ -269,13 +267,13 @@ static int wilc_wlan_txq_add_to_head(struct txq_entry_t *tqe)
 
        /*Added by Amr - BugID_4720*/
        p->os_func.os_spin_unlock(p->txq_spinlock, &flags);
-       p->os_func.os_signal(p->txq_add_to_head_lock);
+       up(p->txq_add_to_head_lock);
 
 
        /**
         *      wake up TX queue
         **/
-       p->os_func.os_signal(p->txq_wait);
+       up(p->txq_wait);
        PRINT_D(TX_DBG, "Wake up the txq_handler\n");
 
        /*Added by Amr - BugID_4720*/
@@ -507,7 +505,7 @@ static int wilc_wlan_txq_add_cfg_pkt(uint8_t *buffer, uint32_t buffer_size)
        PRINT_D(TX_DBG, "Adding config packet ...\n");
        if (p->quit) {
                PRINT_D(TX_DBG, "Return due to clear function\n");
-               p->os_func.os_signal(p->cfg_wait);
+               up(p->cfg_wait);
                return 0;
        }
 
@@ -1193,7 +1191,7 @@ _end_:
                        break;
        } while (0);
        /*Added by Amr - BugID_4720*/
-       p->os_func.os_signal(p->txq_add_to_head_lock);
+       up(p->txq_add_to_head_lock);
 
        p->txq_exit = 1;
        PRINT_D(TX_DBG, "THREAD: Exiting txq\n");
@@ -1217,7 +1215,7 @@ static void wilc_wlan_handle_rxq(void)
        do {
                if (p->quit) {
                        PRINT_D(RX_DBG, "exit 1st do-while due to Clean_UP function\n");
-                       p->os_func.os_signal(p->cfg_wait);
+                       up(p->cfg_wait);
                        break;
                }
                rqe = wilc_wlan_rxq_remove();
@@ -1298,7 +1296,7 @@ static void wilc_wlan_handle_rxq(void)
                                                 **/
                                                PRINT_D(RX_DBG, "p->cfg_seq_no = %d - rsp.seq_no = %d\n", p->cfg_seq_no, rsp.seq_no);
                                                if (p->cfg_seq_no == rsp.seq_no) {
-                                                       p->os_func.os_signal(p->cfg_wait);
+                                                       up(p->cfg_wait);
                                                }
                                        } else if (rsp.type == WILC_CFG_RSP_STATUS) {
                                                /**
@@ -1452,7 +1450,7 @@ _end_:
                                rqe->buffer_size = size;
                                PRINT_D(RX_DBG, "rxq entery Size= %d - Address = %p\n", rqe->buffer_size, rqe->buffer);
                                wilc_wlan_rxq_add(rqe);
-                               p->os_func.os_signal(p->rxq_wait);
+                               up(p->rxq_wait);
                        }
                } else {
 #ifndef MEMORY_STATIC
index 40050d7..3519b22 100644 (file)
@@ -86,10 +86,7 @@ typedef struct {
 typedef struct {
        void (*os_sleep)(uint32_t);
        void (*os_debug)(uint8_t *);
-       void (*os_lock)(void *);
-       void (*os_unlock)(void *);
        int (*os_wait)(void *, u32);
-       void (*os_signal)(void *);
 
        /*Added by Amr - BugID_4720*/
        void (*os_spin_lock)(void *, unsigned long *);
@@ -152,7 +149,7 @@ typedef struct {
        void *rxq_critical_section;
        void *rxq_wait_event;
 
-       void *cfg_wait_event;
+       struct semaphore *cfg_wait_event;
 } wilc_wlan_os_context_t;
 
 typedef struct {