From 5e150b52a5fadbf3ef27ce2eaa7c79b4b1436342 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 3 Sep 2015 19:32:11 -0700 Subject: [PATCH] staging: wilc1000: remove mutex_lock/unlock wrappers Just call the functions directly. Also fix the variable types to be correct, not void *, so we have a semblance of type safety happening now. Cc: Johnny Kim Cc: Rachel Kim Cc: Dean Lee Cc: Chris Park Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wilc1000/linux_wlan.c | 43 +++---------------------- drivers/staging/wilc1000/wilc_wlan.c | 20 ++++++------ drivers/staging/wilc1000/wilc_wlan_if.h | 4 +-- 3 files changed, 15 insertions(+), 52 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 734cabe698cb..14ea61665a85 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -601,39 +601,6 @@ static void linux_wlan_deinit_mutex(void *plock) mutex_destroy((struct mutex *)plock); } -static void linux_wlan_lock_mutex(void *vp) -{ - PRINT_D(LOCK_DBG, "Locking mutex %p\n", vp); - if (vp != NULL) { - /* - * if(mutex_is_locked((struct mutex*)vp)) - * { - * //PRINT_ER("Mutex already locked - %p \n",vp); - * } - */ - mutex_lock((struct mutex *)vp); - - } else { - PRINT_ER("Failed, mutex is NULL\n"); - } -} - -static void linux_wlan_unlock_mutex(void *vp) -{ - PRINT_D(LOCK_DBG, "Unlocking mutex %p\n", vp); - if (vp != NULL) { - - if (mutex_is_locked((struct mutex *)vp)) { - mutex_unlock((struct mutex *)vp); - } else { - /* PRINT_ER("Mutex already unlocked - %p\n",vp); */ - } - - } else { - PRINT_ER("Failed, mutex is NULL\n"); - } -} - /*Added by Amr - BugID_4720*/ static void linux_wlan_init_spin_lock(char *lockName, void *plock, int count) { @@ -1297,9 +1264,9 @@ void wilc1000_wlan_deinit(linux_wlan_t *nic) #if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31) #else - linux_wlan_lock_mutex((void *)&g_linux_wlan->hif_cs); + mutex_lock(&g_linux_wlan->hif_cs); disable_sdio_interrupt(); - linux_wlan_unlock_mutex((void *)&g_linux_wlan->hif_cs); + mutex_unlock(&g_linux_wlan->hif_cs); #endif #endif @@ -1337,9 +1304,9 @@ void wilc1000_wlan_deinit(linux_wlan_t *nic) #if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31) PRINT_D(INIT_DBG, "Disabling IRQ 2\n"); - linux_wlan_lock_mutex((void *)&g_linux_wlan->hif_cs); + mutex_lock(&g_linux_wlan->hif_cs); disable_sdio_interrupt(); - linux_wlan_unlock_mutex((void *)&g_linux_wlan->hif_cs); + mutex_unlock(&g_linux_wlan->hif_cs); #endif #endif @@ -1461,8 +1428,6 @@ void linux_to_wlan(wilc_wlan_inp_t *nwi, linux_wlan_t *nic) 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; - nwi->os_func.os_enter_cs = linux_wlan_lock_mutex; - nwi->os_func.os_leave_cs = linux_wlan_unlock_mutex; /*Added by Amr - BugID_4720*/ nwi->os_func.os_spin_lock = linux_wlan_spin_lock; diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c index 6bf1f4544adc..e1b248d8ae78 100644 --- a/drivers/staging/wilc1000/wilc_wlan.c +++ b/drivers/staging/wilc1000/wilc_wlan.c @@ -43,7 +43,7 @@ typedef struct { * host interface functions **/ wilc_hif_func_t hif_func; - void *hif_lock; + struct mutex *hif_lock; /** * configuration interface functions @@ -89,7 +89,7 @@ typedef struct { /** * RX queue **/ - void *rxq_lock; + struct mutex *rxq_lock; struct rxq_entry_t *rxq_head; struct rxq_entry_t *rxq_tail; int rxq_entries; @@ -135,7 +135,7 @@ static CHIP_PS_STATE_T genuChipPSstate = CHIP_WAKEDUP; INLINE void acquire_bus(BUS_ACQUIRE_T acquire) { - g_wlan.os_func.os_enter_cs(g_wlan.hif_lock); + mutex_lock(g_wlan.hif_lock); #ifndef WILC_OPTIMIZE_SLEEP_INT if (genuChipPSstate != CHIP_WAKEDUP) #endif @@ -151,7 +151,7 @@ INLINE void release_bus(BUS_RELEASE_T release) if (release == RELEASE_ALLOW_SLEEP) chip_allow_sleep(); #endif - g_wlan.os_func.os_leave_cs(g_wlan.hif_lock); + mutex_unlock(g_wlan.hif_lock); } /******************************************** * @@ -659,7 +659,7 @@ static int wilc_wlan_rxq_add(struct rxq_entry_t *rqe) if (p->quit) return 0; - p->os_func.os_enter_cs(p->rxq_lock); + mutex_lock(p->rxq_lock); if (p->rxq_head == NULL) { PRINT_D(RX_DBG, "Add to Queue head\n"); rqe->next = NULL; @@ -673,7 +673,7 @@ static int wilc_wlan_rxq_add(struct rxq_entry_t *rqe) } p->rxq_entries += 1; PRINT_D(RX_DBG, "Number of queue entries: %d\n", p->rxq_entries); - p->os_func.os_leave_cs(p->rxq_lock); + mutex_unlock(p->rxq_lock); return p->rxq_entries; } @@ -685,12 +685,12 @@ static struct rxq_entry_t *wilc_wlan_rxq_remove(void) if (p->rxq_head) { struct rxq_entry_t *rqe; - p->os_func.os_enter_cs(p->rxq_lock); + mutex_lock(p->rxq_lock); rqe = p->rxq_head; p->rxq_head = p->rxq_head->next; p->rxq_entries -= 1; PRINT_D(RX_DBG, "RXQ entries decreased\n"); - p->os_func.os_leave_cs(p->rxq_lock); + mutex_unlock(p->rxq_lock); return rqe; } PRINT_D(RX_DBG, "Nothing to get from Q\n"); @@ -2253,7 +2253,7 @@ u16 Set_machw_change_vir_if(bool bValue) u32 reg; /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/ - (&g_wlan)->os_func.os_enter_cs((&g_wlan)->hif_lock); + mutex_lock((&g_wlan)->hif_lock); ret = (&g_wlan)->hif_func.hif_read_reg(WILC_CHANGING_VIR_IF, ®); if (!ret) { PRINT_ER("Error while Reading reg WILC_CHANGING_VIR_IF\n"); @@ -2269,7 +2269,7 @@ u16 Set_machw_change_vir_if(bool bValue) if (!ret) { PRINT_ER("Error while writing reg WILC_CHANGING_VIR_IF\n"); } - (&g_wlan)->os_func.os_leave_cs((&g_wlan)->hif_lock); + mutex_unlock((&g_wlan)->hif_lock); return ret; } diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h index 7787e8f803ee..40050d7a991c 100644 --- a/drivers/staging/wilc1000/wilc_wlan_if.h +++ b/drivers/staging/wilc1000/wilc_wlan_if.h @@ -90,8 +90,6 @@ typedef struct { void (*os_unlock)(void *); int (*os_wait)(void *, u32); void (*os_signal)(void *); - void (*os_enter_cs)(void *); - void (*os_leave_cs)(void *); /*Added by Amr - BugID_4720*/ void (*os_spin_lock)(void *, unsigned long *); @@ -137,7 +135,7 @@ typedef struct { typedef struct { void *os_private; - void *hif_critical_section; + struct mutex *hif_critical_section; uint32_t tx_buffer_size; void *txq_critical_section; -- 2.39.2