From: Ajay Singh <ajay.kat...@microchip.com>

Avoid use of static variable 'hif_deinit_lock' and move it as part of
wilc struct.

Signed-off-by: Ajay Singh <ajay.kat...@microchip.com>
---
 drivers/staging/wilc1000/host_interface.c     | 20 +++++++++-----------
 drivers/staging/wilc1000/wilc_wfi_netdevice.h |  2 ++
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/wilc1000/host_interface.c 
b/drivers/staging/wilc1000/host_interface.c
index 115b6f25..0fb6ca3 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -130,8 +130,6 @@ struct wilc_join_bss_param {
        };
 } __packed;
 
-static struct mutex hif_deinit_lock;
-
 /* 'msg' should be free by the caller for syc */
 static struct host_if_msg*
 wilc_alloc_work(struct wilc_vif *vif, void (*work_fun)(struct work_struct *),
@@ -1645,7 +1643,7 @@ int wilc_init(struct net_device *dev, struct host_if_drv 
**hif_drv_handler)
        vif->obtaining_ip = false;
 
        if (wilc->clients_count == 0)
-               mutex_init(&hif_deinit_lock);
+               mutex_init(&wilc->deinit_lock);
 
        timer_setup(&vif->periodic_rssi, get_periodic_rssi, 0);
        mod_timer(&vif->periodic_rssi, jiffies + msecs_to_jiffies(5000));
@@ -1673,7 +1671,7 @@ int wilc_deinit(struct wilc_vif *vif)
                return -EFAULT;
        }
 
-       mutex_lock(&hif_deinit_lock);
+       mutex_lock(&vif->wilc->deinit_lock);
 
        del_timer_sync(&hif_drv->scan_timer);
        del_timer_sync(&hif_drv->connect_timer);
@@ -1693,7 +1691,7 @@ int wilc_deinit(struct wilc_vif *vif)
        kfree(hif_drv);
        vif->hif_drv = NULL;
        vif->wilc->clients_count--;
-       mutex_unlock(&hif_deinit_lock);
+       mutex_unlock(&vif->wilc->deinit_lock);
        return result;
 }
 
@@ -1746,31 +1744,31 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, 
u8 *buffer, u32 length)
        struct host_if_drv *hif_drv;
        struct wilc_vif *vif;
 
-       mutex_lock(&hif_deinit_lock);
+       mutex_lock(&wilc->deinit_lock);
 
        id = get_unaligned_le32(&buffer[length - 4]);
        vif = wilc_get_vif_from_idx(wilc, id);
        if (!vif) {
-               mutex_unlock(&hif_deinit_lock);
+               mutex_unlock(&wilc->deinit_lock);
                return;
        }
 
        hif_drv = vif->hif_drv;
 
        if (!hif_drv) {
-               mutex_unlock(&hif_deinit_lock);
+               mutex_unlock(&wilc->deinit_lock);
                return;
        }
 
        if (!hif_drv->conn_info.conn_result) {
                netdev_err(vif->ndev, "%s: conn_result is NULL\n", __func__);
-               mutex_unlock(&hif_deinit_lock);
+               mutex_unlock(&wilc->deinit_lock);
                return;
        }
 
        msg = wilc_alloc_work(vif, handle_rcvd_gnrl_async_info, false);
        if (IS_ERR(msg)) {
-               mutex_unlock(&hif_deinit_lock);
+               mutex_unlock(&wilc->deinit_lock);
                return;
        }
 
@@ -1781,7 +1779,7 @@ void wilc_gnrl_async_info_received(struct wilc *wilc, u8 
*buffer, u32 length)
                kfree(msg);
        }
 
-       mutex_unlock(&hif_deinit_lock);
+       mutex_unlock(&wilc->deinit_lock);
 }
 
 void wilc_scan_complete_received(struct wilc *wilc, u8 *buffer, u32 length)
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h 
b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
index a06b0c0..3a78ffd 100644
--- a/drivers/staging/wilc1000/wilc_wfi_netdevice.h
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -271,6 +271,8 @@ struct wilc {
        struct wilc_cfg cfg;
        void *bus_data;
        struct net_device *monitor_dev;
+       /* deinit lock */
+       struct mutex deinit_lock;
 };
 
 struct wilc_wfi_mon_priv {
-- 
2.7.4

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to