staging: wilc1000: avoid use of 'hif_deinit_lock' static variable
authorAjay Singh <ajay.kathat@microchip.com>
Tue, 5 Feb 2019 07:15:54 +0000 (07:15 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 7 Feb 2019 12:31:20 +0000 (13:31 +0100)
Avoid use of static variable 'hif_deinit_lock' and move it as part of
wilc struct.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/host_interface.c
drivers/staging/wilc1000/wilc_wfi_netdevice.h

index 115b6f25d99413070d7ac4d3f69c0350db97ceac..0fb6ca3133bbc43118a50d3990f1797fd6d5ff12 100644 (file)
@@ -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)
index a06b0c0193885f7177e58da59c868e1ae5369a55..3a78ffd217bbaeef07933b988e00b2945598f280 100644 (file)
@@ -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 {