From d0b2f91bede3bd5e3d24dd6803e56eee959c1797 Mon Sep 17 00:00:00 2001 From: André Fabian Silva Delgado Date: Thu, 20 Oct 2016 00:10:27 -0300 Subject: Linux-libre 4.8.2-gnu --- drivers/staging/wilc1000/linux_wlan.c | 37 ++++++++++++++--------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'drivers/staging/wilc1000/linux_wlan.c') diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 9a7fa90dc..ad6684916 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -20,7 +20,7 @@ #include #include #include - +#include #include #include @@ -31,8 +31,6 @@ static struct notifier_block g_dev_notifier = { .notifier_call = dev_state_ev_handler }; -static struct semaphore close_exit_sync; - static int wlan_deinit_locks(struct net_device *dev); static void wlan_deinitialize_threads(struct net_device *dev); @@ -241,7 +239,7 @@ void wilc_mac_indicate(struct wilc *wilc, int flag) (unsigned char *)&status, 4); if (wilc->mac_status == WILC_MAC_STATUS_INIT) { wilc->mac_status = status; - up(&wilc->sync_event); + complete(&wilc->sync_event); } else { wilc->mac_status = status; } @@ -316,7 +314,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); @@ -362,7 +360,7 @@ int wilc_wlan_get_firmware(struct net_device *dev) goto _fail_; if (reject_firmware(&wilc_firmware, firmware, wilc->dev) != 0) { - netdev_err(dev, "%s - firmare not available\n", firmware); + netdev_err(dev, "%s - firmware not available\n", firmware); ret = -1; goto _fail_; } @@ -386,9 +384,9 @@ static int linux_wlan_start_firmware(struct net_device *dev) if (ret < 0) return ret; - ret = wilc_lock_timeout(wilc, &wilc->sync_event, 5000); - if (ret) - return ret; + if (!wait_for_completion_timeout(&wilc->sync_event, + msecs_to_jiffies(5000))) + return -ETIME; return 0; } @@ -650,7 +648,7 @@ void wilc1000_wlan_deinit(struct net_device *dev) mutex_unlock(&wl->hif_cs); } if (&wl->txq_event) - up(&wl->txq_event); + complete(&wl->txq_event); wlan_deinitialize_threads(dev); deinit_irq(dev); @@ -679,12 +677,12 @@ 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); - sema_init(&wl->txq_event, 0); + init_completion(&wl->txq_event); - sema_init(&wl->cfg_event, 0); - sema_init(&wl->sync_event, 0); + init_completion(&wl->cfg_event); + init_completion(&wl->sync_event); init_completion(&wl->txq_thread_started); return 0; @@ -717,10 +715,10 @@ static int wlan_initialize_threads(struct net_device *dev) wilc->txq_thread = kthread_run(linux_wlan_txq_task, (void *)dev, "K_TXQ_TASK"); - if (!wilc->txq_thread) { + if (IS_ERR(wilc->txq_thread)) { netdev_err(dev, "couldn't create TXQ thread\n"); wilc->close = 0; - return -ENOBUFS; + return PTR_ERR(wilc->txq_thread); } wait_for_completion(&wilc->txq_thread_started); @@ -738,7 +736,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); @@ -1088,7 +1086,6 @@ int wilc_mac_close(struct net_device *ndev) WILC_WFI_deinit_mon_interface(); } - up(&close_exit_sync); vif->mac_opened = 0; return 0; @@ -1232,8 +1229,6 @@ void wilc_netdev_cleanup(struct wilc *wilc) } if (wilc && (wilc->vif[0]->ndev || wilc->vif[1]->ndev)) { - wilc_lock_timeout(wilc, &close_exit_sync, 5 * 1000); - for (i = 0; i < NUM_CONCURRENT_IFC; i++) if (wilc->vif[i]->ndev) if (vif[i]->mac_opened) @@ -1258,8 +1253,6 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, struct net_device *ndev; struct wilc *wl; - sema_init(&close_exit_sync, 0); - wl = kzalloc(sizeof(*wl), GFP_KERNEL); if (!wl) return -ENOMEM; -- cgit v1.2.3-54-g00ecf