From 642768eec5e5d8cd1e239828e3b5e23ae45b131a Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 3 Sep 2015 19:56:21 -0700 Subject: [PATCH] staging: wilc1000: remove wrappers around sema_init() Just call the function directly. Also remove a pointless "deinit" function that was empty to match the init function. This also fixes a bug where txq_add_to_head_cs was a mutex structure being used as a semaphore. See the fun things that happen when you use void pointers instead of "real" types? Amazing that this worked at all, someone got _very_ lucky. Whoever "Amr" is, they really didn't fix BugID_4720 correctly :( Cc: Johnny Kim Cc: Rachel Kim Cc: Dean Lee Cc: Chris Park Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 55 +++---------------- drivers/staging/wilc1000/wilc_wfi_netdevice.h | 2 +- 2 files changed, 10 insertions(+), 47 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 7b68d123d270..c3429774266c 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -545,18 +545,6 @@ static void linux_wlan_dbg(uint8_t *buff) PRINT_D(INIT_DBG, "%d\n", *buff); } -static void linux_wlan_init_lock(char *lockName, void *plock, int count) -{ - sema_init((struct semaphore *)plock, count); - PRINT_D(LOCK_DBG, "Initializing [%s][%p]\n", lockName, plock); - -} - -static void linux_wlan_deinit_lock(void *plock) -{ - /* mutex_destroy((struct mutex*)plock); */ -} - static void linux_wlan_lock(void *vp) { PRINT_D(LOCK_DBG, "Locking %p\n", vp); @@ -1311,21 +1299,19 @@ int wlan_init_locks(linux_wlan_t *p_nic) /*Added by Amr - BugID_4720*/ spin_lock_init(&g_linux_wlan->txq_spinlock); + sema_init(&g_linux_wlan->txq_add_to_head_cs, 1); - /*Added by Amr - BugID_4720*/ - linux_wlan_init_lock("txq_add_to_head_lock/txq_cs", &g_linux_wlan->txq_add_to_head_cs, 1); + sema_init(&g_linux_wlan->txq_event, 0); + sema_init(&g_linux_wlan->rxq_event, 0); - linux_wlan_init_lock("txq_wait/txq_event", &g_linux_wlan->txq_event, 0); - linux_wlan_init_lock("rxq_wait/rxq_event", &g_linux_wlan->rxq_event, 0); + sema_init(&g_linux_wlan->cfg_event, 0); + sema_init(&g_linux_wlan->sync_event, 0); - linux_wlan_init_lock("cfg_wait/cfg_event", &g_linux_wlan->cfg_event, 0); - linux_wlan_init_lock("sync_event", &g_linux_wlan->sync_event, 0); - - linux_wlan_init_lock("rxq_lock/rxq_started", &g_linux_wlan->rxq_thread_started, 0); - linux_wlan_init_lock("rxq_lock/txq_started", &g_linux_wlan->txq_thread_started, 0); + sema_init(&g_linux_wlan->rxq_thread_started, 0); + sema_init(&g_linux_wlan->txq_thread_started, 0); #if (RX_BH_TYPE == RX_BH_KTHREAD) - linux_wlan_init_lock("BH_SEM", &g_linux_wlan->rx_sem, 0); + sema_init(&g_linux_wlan->rx_sem, 0); #endif return 0; @@ -1344,28 +1330,6 @@ static int wlan_deinit_locks(linux_wlan_t *nic) if (&g_linux_wlan->txq_cs != NULL) mutex_destroy(&g_linux_wlan->txq_cs); - if (&g_linux_wlan->rxq_event != NULL) - linux_wlan_deinit_lock(&g_linux_wlan->rxq_event); - - if (&g_linux_wlan->txq_event != NULL) - linux_wlan_deinit_lock(&g_linux_wlan->txq_event); - - /*Added by Amr - BugID_4720*/ - if (&g_linux_wlan->txq_add_to_head_cs != NULL) - linux_wlan_deinit_lock(&g_linux_wlan->txq_add_to_head_cs); - - if (&g_linux_wlan->rxq_thread_started != NULL) - linux_wlan_deinit_lock(&g_linux_wlan->rxq_thread_started); - - if (&g_linux_wlan->txq_thread_started != NULL) - linux_wlan_deinit_lock(&g_linux_wlan->txq_thread_started); - - if (&g_linux_wlan->cfg_event != NULL) - linux_wlan_deinit_lock(&g_linux_wlan->cfg_event); - - if (&g_linux_wlan->sync_event != NULL) - linux_wlan_deinit_lock(&g_linux_wlan->sync_event); - return 0; } void linux_to_wlan(wilc_wlan_inp_t *nwi, linux_wlan_t *nic) @@ -2370,7 +2334,7 @@ int wilc_netdev_init(void) perInterface_wlan_t *nic; struct net_device *ndev; - linux_wlan_init_lock("close_exit_sync", &close_exit_sync, 0); + sema_init(&close_exit_sync, 0); /*create the common structure*/ g_linux_wlan = WILC_MALLOC(sizeof(linux_wlan_t)); @@ -2566,7 +2530,6 @@ static void __exit exit_wilc_driver(void) sdio_unregister_driver(&wilc_bus); #endif - linux_wlan_deinit_lock(&close_exit_sync); if (g_linux_wlan != NULL) { kfree(g_linux_wlan); g_linux_wlan = NULL; diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h index 77f320d125e8..d1de0321749a 100644 --- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h +++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h @@ -193,7 +193,7 @@ typedef struct { struct mutex txq_cs; /*Added by Amr - BugID_4720*/ - struct mutex txq_add_to_head_cs; + struct semaphore txq_add_to_head_cs; spinlock_t txq_spinlock; struct mutex rxq_cs; -- 2.30.2