Staging: wilc1000: coreconfigurator: Remove trailing whitespace
[firefly-linux-kernel-4.4.55.git] / drivers / staging / wilc1000 / wilc_wlan.c
index aa20f433b01137334d590ce951fe4e02b47fdcee..c0266574770521860aff9db94f70b882a66feb49 100644 (file)
@@ -8,7 +8,8 @@
 /* //////////////////////////////////////////////////////////////////////////// */
 
 #include "wilc_wlan_if.h"
-#include "wilc_wlan.h"
+#include "wilc_wfi_netdevice.h"
+#include "wilc_wlan_cfg.h"
 
 /********************************************
  *
  ********************************************/
 extern wilc_hif_func_t hif_sdio;
 extern wilc_hif_func_t hif_spi;
-extern wilc_cfg_func_t mac_cfg;
-extern void WILC_WFI_mgmt_rx(u8 *buff, u32 size);
 u32 wilc_get_chipid(u8 update);
-u16 Set_machw_change_vir_if(bool bValue);
 
 
 
@@ -30,7 +28,6 @@ typedef struct {
        /**
         *      input interface functions
         **/
-       wilc_wlan_os_func_t os_func;
        wilc_wlan_io_func_t io_func;
 
        /**
@@ -41,7 +38,6 @@ typedef struct {
        /**
         *      configuration interface functions
         **/
-       wilc_cfg_func_t cif_func;
        int cfg_frame_in_use;
        wilc_cfg_frame_t cfg_frame;
        u32 cfg_frame_offset;
@@ -143,8 +139,7 @@ static inline void release_bus(BUS_RELEASE_T release)
 static void wilc_wlan_txq_remove(struct txq_entry_t *tqe)
 {
 
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
-       /* unsigned long flags; */
+       wilc_wlan_dev_t *p = &g_wlan;
        if (tqe == p->txq_head) {
 
                p->txq_head = tqe->next;
@@ -167,16 +162,16 @@ static void wilc_wlan_txq_remove(struct txq_entry_t *tqe)
 static struct txq_entry_t *wilc_wlan_txq_remove_from_head(void)
 {
        struct txq_entry_t *tqe;
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        unsigned long flags;
 
        spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
        if (p->txq_head) {
                tqe = p->txq_head;
                p->txq_head = tqe->next;
-               if (p->txq_head) {
+               if (p->txq_head)
                        p->txq_head->prev = NULL;
-               }
+
                p->txq_entries -= 1;
 
 
@@ -191,7 +186,7 @@ static struct txq_entry_t *wilc_wlan_txq_remove_from_head(void)
 
 static void wilc_wlan_txq_add_to_tail(struct txq_entry_t *tqe)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        unsigned long flags;
        spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
 
@@ -221,10 +216,10 @@ static void wilc_wlan_txq_add_to_tail(struct txq_entry_t *tqe)
 
 static int wilc_wlan_txq_add_to_head(struct txq_entry_t *tqe)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        unsigned long flags;
-       if (p->os_func.os_wait(&g_linux_wlan->txq_add_to_head_cs,
-                              CFG_PKTS_TIMEOUT))
+       if (linux_wlan_lock_timeout(&g_linux_wlan->txq_add_to_head_cs,
+                                   CFG_PKTS_TIMEOUT))
                return -1;
 
        spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
@@ -281,9 +276,6 @@ typedef struct {
 struct Ack_session_info *Free_head;
 struct Ack_session_info *Alloc_head;
 
-#define TCP_FIN_MASK           (1 << 0)
-#define TCP_SYN_MASK           (1 << 1)
-#define TCP_Ack_MASK           (1 << 4)
 #define NOT_TCP_ACK                    (-1)
 
 #define MAX_TCP_SESSION                25
@@ -318,9 +310,8 @@ static inline int add_TCP_track_session(u32 src_prt, u32 dst_prt, u32 seq)
 static inline int Update_TCP_track_session(u32 index, u32 Ack)
 {
 
-       if (Ack > Acks_keep_track_info[index].Bigger_Ack_num) {
+       if (Ack > Acks_keep_track_info[index].Bigger_Ack_num)
                Acks_keep_track_info[index].Bigger_Ack_num = Ack;
-       }
        return 0;
 
 }
@@ -341,7 +332,7 @@ static inline int add_TCP_Pending_Ack(u32 Ack, u32 Session_index, struct txq_ent
 }
 static inline int remove_TCP_related(void)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        unsigned long flags;
 
        spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
@@ -350,17 +341,22 @@ static inline int remove_TCP_related(void)
        return 0;
 }
 
-static inline int tcp_process(struct txq_entry_t *tqe)
+static inline int tcp_process(struct net_device *dev, struct txq_entry_t *tqe)
 {
        int ret;
        u8 *eth_hdr_ptr;
        u8 *buffer = tqe->buffer;
        unsigned short h_proto;
        int i;
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        unsigned long flags;
+       perInterface_wlan_t *nic;
+       struct wilc *wilc;
 
-       spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
+       nic = netdev_priv(dev);
+       wilc = nic->wilc;
+
+       spin_lock_irqsave(&wilc->txq_spinlock, flags);
 
        eth_hdr_ptr = &buffer[0];
        h_proto = ntohs(*((unsigned short *)&eth_hdr_ptr[12]));
@@ -394,9 +390,9 @@ static inline int tcp_process(struct txq_entry_t *tqe)
                                                break;
                                        }
                                }
-                               if (i == Opened_TCP_session) {
+                               if (i == Opened_TCP_session)
                                        add_TCP_track_session(0, 0, seq_no);
-                               }
+
                                add_TCP_Pending_Ack(Ack_no, i, tqe);
 
 
@@ -408,19 +404,23 @@ static inline int tcp_process(struct txq_entry_t *tqe)
        } else {
                ret = 0;
        }
-       spin_unlock_irqrestore(&g_linux_wlan->txq_spinlock, flags);
+       spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
        return ret;
 }
 
 
-static int wilc_wlan_txq_filter_dup_tcp_ack(void)
+static int wilc_wlan_txq_filter_dup_tcp_ack(struct net_device *dev)
 {
-
+       perInterface_wlan_t *nic;
+       struct wilc *wilc;
        u32 i = 0;
        u32 Dropped = 0;
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
+
+       nic = netdev_priv(dev);
+       wilc = nic->wilc;
 
-       spin_lock_irqsave(&g_linux_wlan->txq_spinlock, p->txq_spinlock_flags);
+       spin_lock_irqsave(&wilc->txq_spinlock, p->txq_spinlock_flags);
        for (i = PendingAcks_arrBase; i < (PendingAcks_arrBase + Pending_Acks); i++) {
                if (Pending_Acks_info[i].ack_num < Acks_keep_track_info[Pending_Acks_info[i].Session_index].Bigger_Ack_num) {
                        struct txq_entry_t *tqe;
@@ -447,12 +447,11 @@ static int wilc_wlan_txq_filter_dup_tcp_ack(void)
                PendingAcks_arrBase = 0;
 
 
-       spin_unlock_irqrestore(&g_linux_wlan->txq_spinlock,
-                              p->txq_spinlock_flags);
+       spin_unlock_irqrestore(&wilc->txq_spinlock, p->txq_spinlock_flags);
 
        while (Dropped > 0) {
                /*consume the semaphore count of the removed packet*/
-               p->os_func.os_wait(&g_linux_wlan->txq_event, 1);
+               linux_wlan_lock_timeout(&wilc->txq_event, 1);
                Dropped--;
        }
 
@@ -474,7 +473,7 @@ bool is_TCP_ACK_Filter_Enabled(void)
 
 static int wilc_wlan_txq_add_cfg_pkt(u8 *buffer, u32 buffer_size)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        struct txq_entry_t *tqe;
 
        PRINT_D(TX_DBG, "Adding config packet ...\n");
@@ -508,9 +507,10 @@ static int wilc_wlan_txq_add_cfg_pkt(u8 *buffer, u32 buffer_size)
        return 1;
 }
 
-static int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size, wilc_tx_complete_func_t func)
+int wilc_wlan_txq_add_net_pkt(struct net_device *dev, void *priv, u8 *buffer,
+                             u32 buffer_size, wilc_tx_complete_func_t func)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        struct txq_entry_t *tqe;
 
        if (p->quit)
@@ -530,7 +530,7 @@ static int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size, wi
 #ifdef TCP_ACK_FILTER
        tqe->tcp_PendingAck_index = NOT_TCP_ACK;
        if (is_TCP_ACK_Filter_Enabled())
-               tcp_process(tqe);
+               tcp_process(dev, tqe);
 #endif
        wilc_wlan_txq_add_to_tail(tqe);
        /*return number of itemes in the queue*/
@@ -540,7 +540,7 @@ static int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size, wi
 int wilc_wlan_txq_add_mgmt_pkt(void *priv, u8 *buffer, u32 buffer_size, wilc_tx_complete_func_t func)
 {
 
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        struct txq_entry_t *tqe;
 
        if (p->quit)
@@ -565,7 +565,7 @@ int wilc_wlan_txq_add_mgmt_pkt(void *priv, u8 *buffer, u32 buffer_size, wilc_tx_
 
 static struct txq_entry_t *wilc_wlan_txq_get_first(void)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        struct txq_entry_t *tqe;
        unsigned long flags;
 
@@ -579,26 +579,27 @@ static struct txq_entry_t *wilc_wlan_txq_get_first(void)
        return tqe;
 }
 
-static struct txq_entry_t *wilc_wlan_txq_get_next(struct txq_entry_t *tqe)
+static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc,
+                                                 struct txq_entry_t *tqe)
 {
        unsigned long flags;
-       spin_lock_irqsave(&g_linux_wlan->txq_spinlock, flags);
+       spin_lock_irqsave(&wilc->txq_spinlock, flags);
 
        tqe = tqe->next;
-       spin_unlock_irqrestore(&g_linux_wlan->txq_spinlock, flags);
+       spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
 
 
        return tqe;
 }
 
-static int wilc_wlan_rxq_add(struct rxq_entry_t *rqe)
+static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
 
        if (p->quit)
                return 0;
 
-       mutex_lock(&g_linux_wlan->rxq_cs);
+       mutex_lock(&wilc->rxq_cs);
        if (p->rxq_head == NULL) {
                PRINT_D(RX_DBG, "Add to Queue head\n");
                rqe->next = NULL;
@@ -612,24 +613,24 @@ 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);
-       mutex_unlock(&g_linux_wlan->rxq_cs);
+       mutex_unlock(&wilc->rxq_cs);
        return p->rxq_entries;
 }
 
-static struct rxq_entry_t *wilc_wlan_rxq_remove(void)
+static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
 
        PRINT_D(RX_DBG, "Getting rxQ element\n");
        if (p->rxq_head) {
                struct rxq_entry_t *rqe;
 
-               mutex_lock(&g_linux_wlan->rxq_cs);
+               mutex_lock(&wilc->rxq_cs);
                rqe = p->rxq_head;
                p->rxq_head = p->rxq_head->next;
                p->rxq_entries -= 1;
                PRINT_D(RX_DBG, "RXQ entries decreased\n");
-               mutex_unlock(&g_linux_wlan->rxq_cs);
+               mutex_unlock(&wilc->rxq_cs);
                return rqe;
        }
        PRINT_D(RX_DBG, "Nothing to get from Q\n");
@@ -654,7 +655,7 @@ static inline void chip_allow_sleep(void)
        /* Clear bit 1 */
        g_wlan.hif_func.hif_read_reg(0xf0, &reg);
 
-       g_wlan.hif_func.hif_write_reg(0xf0, reg & ~(1 << 0));
+       g_wlan.hif_func.hif_write_reg(0xf0, reg & ~BIT(0));
 }
 
 static inline void chip_wakeup(void)
@@ -666,19 +667,19 @@ static inline void chip_wakeup(void)
                do {
                        g_wlan.hif_func.hif_read_reg(1, &reg);
                        /* Set bit 1 */
-                       g_wlan.hif_func.hif_write_reg(1, reg | (1 << 1));
+                       g_wlan.hif_func.hif_write_reg(1, reg | BIT(1));
 
                        /* Clear bit 1*/
-                       g_wlan.hif_func.hif_write_reg(1, reg & ~(1 << 1));
+                       g_wlan.hif_func.hif_write_reg(1, reg & ~BIT(1));
 
                        do {
                                /* Wait for the chip to stabilize*/
                                usleep_range(2 * 1000, 2 * 1000);
                                /* Make sure chip is awake. This is an extra step that can be removed */
                                /* later to avoid the bus access overhead */
-                               if ((wilc_get_chipid(true) == 0)) {
+                               if ((wilc_get_chipid(true) == 0))
                                        wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n");
-                               }
+
                        } while ((wilc_get_chipid(true) == 0) && ((++trials % 3) == 0));
 
                } while (wilc_get_chipid(true) == 0);
@@ -686,7 +687,7 @@ static inline void chip_wakeup(void)
                g_wlan.hif_func.hif_read_reg(0xf0, &reg);
                do {
                        /* Set bit 1 */
-                       g_wlan.hif_func.hif_write_reg(0xf0, reg | (1 << 0));
+                       g_wlan.hif_func.hif_write_reg(0xf0, reg | BIT(0));
 
                        /* Check the clock status */
                        g_wlan.hif_func.hif_read_reg(0xf1, &clk_status_reg);
@@ -702,14 +703,15 @@ static inline void chip_wakeup(void)
                                /* later to avoid the bus access overhead */
                                g_wlan.hif_func.hif_read_reg(0xf1, &clk_status_reg);
 
-                               if ((clk_status_reg & 0x1) == 0) {
+                               if ((clk_status_reg & 0x1) == 0)
                                        wilc_debug(N_ERR, "clocks still OFF. Wake up failed\n");
-                               }
+
                        }
                        /* in case of failure, Reset the wakeup bit to introduce a new edge on the next loop */
                        if ((clk_status_reg & 0x1) == 0) {
                                /* Reset bit 0 */
-                               g_wlan.hif_func.hif_write_reg(0xf0, reg & (~(1 << 0)));
+                               g_wlan.hif_func.hif_write_reg(0xf0, reg &
+                                                             (~BIT(0)));
                        }
                } while ((clk_status_reg & 0x1) == 0);
        }
@@ -717,7 +719,7 @@ static inline void chip_wakeup(void)
 
        if (genuChipPSstate == CHIP_SLEEPING_MANUAL) {
                g_wlan.hif_func.hif_read_reg(0x1C0C, &reg);
-               reg &= ~(1 << 0);
+               reg &= ~BIT(0);
                g_wlan.hif_func.hif_write_reg(0x1C0C, reg);
 
                if (wilc_get_chipid(false) >= 0x1002b0) {
@@ -725,11 +727,11 @@ static inline void chip_wakeup(void)
                        u32 val32;
 
                        g_wlan.hif_func.hif_read_reg(0x1e1c, &val32);
-                       val32 |= (1 << 6);
+                       val32 |= BIT(6);
                        g_wlan.hif_func.hif_write_reg(0x1e1c, val32);
 
                        g_wlan.hif_func.hif_read_reg(0x1e9c, &val32);
-                       val32 |= (1 << 6);
+                       val32 |= BIT(6);
                        g_wlan.hif_func.hif_write_reg(0x1e9c, val32);
                }
        }
@@ -744,19 +746,19 @@ static inline void chip_wakeup(void)
                if ((g_wlan.io_func.io_type & 0x1) == HIF_SPI) {
                        g_wlan.hif_func.hif_read_reg(1, &reg);
                        /* Make sure bit 1 is 0 before we start. */
-                       g_wlan.hif_func.hif_write_reg(1, reg & ~(1 << 1));
+                       g_wlan.hif_func.hif_write_reg(1, reg & ~BIT(1));
                        /* Set bit 1 */
-                       g_wlan.hif_func.hif_write_reg(1, reg | (1 << 1));
+                       g_wlan.hif_func.hif_write_reg(1, reg | BIT(1));
                        /* Clear bit 1*/
-                       g_wlan.hif_func.hif_write_reg(1, reg  & ~(1 << 1));
+                       g_wlan.hif_func.hif_write_reg(1, reg  & ~BIT(1));
                } else if ((g_wlan.io_func.io_type & 0x1) == HIF_SDIO)   {
                        /* Make sure bit 0 is 0 before we start. */
                        g_wlan.hif_func.hif_read_reg(0xf0, &reg);
-                       g_wlan.hif_func.hif_write_reg(0xf0, reg & ~(1 << 0));
+                       g_wlan.hif_func.hif_write_reg(0xf0, reg & ~BIT(0));
                        /* Set bit 1 */
-                       g_wlan.hif_func.hif_write_reg(0xf0, reg | (1 << 0));
+                       g_wlan.hif_func.hif_write_reg(0xf0, reg | BIT(0));
                        /* Clear bit 1 */
-                       g_wlan.hif_func.hif_write_reg(0xf0, reg  & ~(1 << 0));
+                       g_wlan.hif_func.hif_write_reg(0xf0, reg  & ~BIT(0));
                }
 
                do {
@@ -765,16 +767,16 @@ static inline void chip_wakeup(void)
 
                        /* Make sure chip is awake. This is an extra step that can be removed */
                        /* later to avoid the bus access overhead */
-                       if ((wilc_get_chipid(true) == 0)) {
+                       if ((wilc_get_chipid(true) == 0))
                                wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n");
-                       }
+
                } while ((wilc_get_chipid(true) == 0) && ((++trials % 3) == 0));
 
        } while (wilc_get_chipid(true) == 0);
 
        if (genuChipPSstate == CHIP_SLEEPING_MANUAL) {
                g_wlan.hif_func.hif_read_reg(0x1C0C, &reg);
-               reg &= ~(1 << 0);
+               reg &= ~BIT(0);
                g_wlan.hif_func.hif_write_reg(0x1C0C, reg);
 
                if (wilc_get_chipid(false) >= 0x1002b0) {
@@ -782,11 +784,11 @@ static inline void chip_wakeup(void)
                        u32 val32;
 
                        g_wlan.hif_func.hif_read_reg(0x1e1c, &val32);
-                       val32 |= (1 << 6);
+                       val32 |= BIT(6);
                        g_wlan.hif_func.hif_write_reg(0x1e1c, val32);
 
                        g_wlan.hif_func.hif_read_reg(0x1e9c, &val32);
-                       val32 |= (1 << 6);
+                       val32 |= BIT(6);
                        g_wlan.hif_func.hif_write_reg(0x1e9c, val32);
                }
        }
@@ -819,7 +821,7 @@ void chip_sleep_manually(u32 u32SleepTime)
  *      Tx, Rx queue handle functions
  *
  ********************************************/
-static int wilc_wlan_handle_txq(u32 *pu32TxqCount)
+int wilc_wlan_handle_txq(struct net_device *dev, u32 *pu32TxqCount)
 {
        wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
        int i, entries = 0;
@@ -833,16 +835,21 @@ static int wilc_wlan_handle_txq(u32 *pu32TxqCount)
        int counter;
        int timeout;
        u32 vmm_table[WILC_VMM_TBL_SIZE];
+       perInterface_wlan_t *nic;
+       struct wilc *wilc;
+
+       nic = netdev_priv(dev);
+       wilc = nic->wilc;
 
        p->txq_exit = 0;
        do {
                if (p->quit)
                        break;
 
-               p->os_func.os_wait(&g_linux_wlan->txq_add_to_head_cs,
-                                  CFG_PKTS_TIMEOUT);
+               linux_wlan_lock_timeout(&wilc->txq_add_to_head_cs,
+                                       CFG_PKTS_TIMEOUT);
 #ifdef TCP_ACK_FILTER
-               wilc_wlan_txq_filter_dup_tcp_ack();
+               wilc_wlan_txq_filter_dup_tcp_ack(dev);
 #endif
                /**
                 *      build the vmm list
@@ -852,33 +859,31 @@ static int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                i = 0;
                sum = 0;
                do {
-                       /* if ((tqe != NULL) && (i < (8)) && */
-                       /* if ((tqe != NULL) && (i < (WILC_VMM_TBL_SIZE-1)) && */
                        if ((tqe != NULL) && (i < (WILC_VMM_TBL_SIZE - 1)) /* reserve last entry to 0 */) {
 
-                               if (tqe->type == WILC_CFG_PKT) {
+                               if (tqe->type == WILC_CFG_PKT)
                                        vmm_sz = ETH_CONFIG_PKT_HDR_OFFSET;
-                               }
-                               else if (tqe->type == WILC_NET_PKT) {
+
+                               else if (tqe->type == WILC_NET_PKT)
                                        vmm_sz = ETH_ETHERNET_HDR_OFFSET;
-                               }
-                               else {
+
+                               else
                                        vmm_sz = HOST_HDR_OFFSET;
-                               }
+
                                vmm_sz += tqe->buffer_size;
                                PRINT_D(TX_DBG, "VMM Size before alignment = %d\n", vmm_sz);
                                if (vmm_sz & 0x3) {                                                                                                     /* has to be word aligned */
                                        vmm_sz = (vmm_sz + 4) & ~0x3;
                                }
-                               if ((sum + vmm_sz) > LINUX_TX_SIZE) {
+                               if ((sum + vmm_sz) > LINUX_TX_SIZE)
                                        break;
-                               }
+
                                PRINT_D(TX_DBG, "VMM Size AFTER alignment = %d\n", vmm_sz);
                                vmm_table[i] = vmm_sz / 4;                                                                                /* table take the word size */
                                PRINT_D(TX_DBG, "VMMTable entry size = %d\n", vmm_table[i]);
 
                                if (tqe->type == WILC_CFG_PKT) {
-                                       vmm_table[i] |= (1 << 10);
+                                       vmm_table[i] |= BIT(10);
                                        PRINT_D(TX_DBG, "VMMTable entry changed for CFG packet = %d\n", vmm_table[i]);
                                }
 #ifdef BIG_ENDIAN
@@ -888,7 +893,7 @@ static int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                                i++;
                                sum += vmm_sz;
                                PRINT_D(TX_DBG, "sum = %d\n", sum);
-                               tqe = wilc_wlan_txq_get_next(tqe);
+                               tqe = wilc_wlan_txq_get_next(wilc, tqe);
                        } else {
                                break;
                        }
@@ -935,9 +940,8 @@ static int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                        }
                } while (!p->quit);
 
-               if (!ret) {
+               if (!ret)
                        goto _end_;
-               }
 
                timeout = 200;
                do {
@@ -976,7 +980,6 @@ static int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                                         *      Get the entries
                                         **/
                                        entries = ((reg >> 3) & 0x3f);
-                                       /* entries = ((reg>>3)&0x2f); */
                                        break;
                                } else {
                                        release_bus(RELEASE_ALLOW_SLEEP);
@@ -990,9 +993,8 @@ static int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                                break;
                        }
 
-                       if (!ret) {
+                       if (!ret)
                                break;
-                       }
 
                        if (entries == 0) {
                                PRINT_WRN(GENERIC_DBG, "[wilc txq]: no more buffer in the chip (reg: %08x), retry later [[ %d, %x ]]\n", reg, i, vmm_table[i - 1]);
@@ -1003,7 +1005,7 @@ static int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                                        wilc_debug(N_ERR, "[wilc txq]: fail can't read reg WILC_HOST_TX_CTRL..\n");
                                        break;
                                }
-                               reg &= ~(1ul << 0);
+                               reg &= ~BIT(0);
                                ret = p->hif_func.hif_write_reg(WILC_HOST_TX_CTRL, reg);
                                if (!ret) {
                                        wilc_debug(N_ERR, "[wilc txq]: fail can't write reg WILC_HOST_TX_CTRL..\n");
@@ -1015,9 +1017,9 @@ static int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                        }
                } while (1);
 
-               if (!ret) {
+               if (!ret)
                        goto _end_;
-               }
+
                if (entries == 0) {
                        ret = WILC_TX_ERR_NO_BUF;
                        goto _end_;
@@ -1044,9 +1046,9 @@ static int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                                vmm_sz *= 4;
                                header = (tqe->type << 31) | (tqe->buffer_size << 15) | vmm_sz;
                                if (tqe->type == WILC_MGMT_PKT)
-                                       header |= (1 << 30);
+                                       header |= BIT(30);
                                else
-                                       header &= ~(1 << 30);
+                                       header &= ~BIT(30);
 
 #ifdef BIG_ENDIAN
                                header = BYTE_SWAP(header);
@@ -1073,9 +1075,8 @@ static int wilc_wlan_handle_txq(u32 *pu32TxqCount)
                                if (tqe->tx_complete_func)
                                        tqe->tx_complete_func(tqe->priv, tqe->status);
                                #ifdef TCP_ACK_FILTER
-                               if (tqe->tcp_PendingAck_index != NOT_TCP_ACK) {
+                               if (tqe->tcp_PendingAck_index != NOT_TCP_ACK)
                                        Pending_Acks_info[tqe->tcp_PendingAck_index].txqe = NULL;
-                               }
                                #endif
                                kfree(tqe);
                        } else {
@@ -1109,7 +1110,7 @@ _end_:
                if (ret != 1)
                        break;
        } while (0);
-       up(&g_linux_wlan->txq_add_to_head_cs);
+       up(&wilc->txq_add_to_head_cs);
 
        p->txq_exit = 1;
        PRINT_D(TX_DBG, "THREAD: Exiting txq\n");
@@ -1118,9 +1119,9 @@ _end_:
        return ret;
 }
 
-static void wilc_wlan_handle_rxq(void)
+static void wilc_wlan_handle_rxq(struct wilc *wilc)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        int offset = 0, size, has_packet = 0;
        u8 *buffer;
        struct rxq_entry_t *rqe;
@@ -1133,10 +1134,10 @@ static void wilc_wlan_handle_rxq(void)
        do {
                if (p->quit) {
                        PRINT_D(RX_DBG, "exit 1st do-while due to Clean_UP function\n");
-                       up(&g_linux_wlan->cfg_event);
+                       up(&wilc->cfg_event);
                        break;
                }
-               rqe = wilc_wlan_rxq_remove();
+               rqe = wilc_wlan_rxq_remove(wilc);
                if (rqe == NULL) {
                        PRINT_D(RX_DBG, "nothing in the queue - exit 1st do-while\n");
                        break;
@@ -1172,7 +1173,6 @@ static void wilc_wlan_handle_rxq(void)
                                break;
                        }
 
-/*bug 3887: [AP] Allow Management frames to be passed to the host*/
                        #define IS_MANAGMEMENT                          0x100
                        #define IS_MANAGMEMENT_CALLBACK                 0x080
                        #define IS_MGMT_STATUS_SUCCES                   0x040
@@ -1182,15 +1182,15 @@ static void wilc_wlan_handle_rxq(void)
                                /* reset mgmt indicator bit, to use pkt_offeset in furthur calculations */
                                pkt_offset &= ~(IS_MANAGMEMENT | IS_MANAGMEMENT_CALLBACK | IS_MGMT_STATUS_SUCCES);
 
-                               WILC_WFI_mgmt_rx(&buffer[offset + HOST_HDR_OFFSET], pkt_len);
+                               WILC_WFI_mgmt_rx(wilc, &buffer[offset + HOST_HDR_OFFSET], pkt_len);
                        }
-                       /* BUG4530 fix */
                        else
                        {
 
                                if (!is_cfg_packet) {
                                        if (pkt_len > 0) {
-                                               frmw_to_linux(&buffer[offset],
+                                               frmw_to_linux(wilc,
+                                                             &buffer[offset],
                                                              pkt_len,
                                                              pkt_offset);
                                                has_packet = 1;
@@ -1200,23 +1200,22 @@ static void wilc_wlan_handle_rxq(void)
 
 
 
-                                       p->cif_func.rx_indicate(&buffer[pkt_offset + offset], pkt_len, &rsp);
+                                       wilc_wlan_cfg_indicate_rx(&buffer[pkt_offset + offset], pkt_len, &rsp);
                                        if (rsp.type == WILC_CFG_RSP) {
                                                /**
                                                 *      wake up the waiting task...
                                                 **/
                                                PRINT_D(RX_DBG, "p->cfg_seq_no = %d - rsp.seq_no = %d\n", p->cfg_seq_no, rsp.seq_no);
-                                               if (p->cfg_seq_no == rsp.seq_no) {
-                                                       up(&g_linux_wlan->cfg_event);
-                                               }
+                                               if (p->cfg_seq_no == rsp.seq_no)
+                                                       up(&wilc->cfg_event);
                                        } else if (rsp.type == WILC_CFG_RSP_STATUS) {
                                                /**
                                                 *      Call back to indicate status...
                                                 **/
-                                               linux_wlan_mac_indicate(WILC_MAC_INDICATE_STATUS);
+                                               linux_wlan_mac_indicate(wilc, WILC_MAC_INDICATE_STATUS);
 
                                        } else if (rsp.type == WILC_CFG_RSP_SCAN) {
-                                               linux_wlan_mac_indicate(WILC_MAC_INDICATE_SCAN);
+                                               linux_wlan_mac_indicate(wilc, WILC_MAC_INDICATE_SCAN);
                                        }
                                }
                        }
@@ -1231,9 +1230,9 @@ static void wilc_wlan_handle_rxq(void)
 #endif
                kfree(rqe);
 
-               if (has_packet) {
+               if (has_packet)
                        linux_wlan_rx_complete();
-               }
+
        } while (1);
 
        p->rxq_exit = 1;
@@ -1274,9 +1273,9 @@ static void wilc_sleeptimer_isr_ext(u32 int_stats1)
 #endif
 }
 
-static void wilc_wlan_handle_isr_ext(u32 int_status)
+static void wilc_wlan_handle_isr_ext(struct wilc *wilc, u32 int_status)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
 #ifdef MEMORY_STATIC
        u32 offset = p->rx_buffer_offset;
 #endif
@@ -1356,7 +1355,7 @@ _end_:
                                rqe->buffer = buffer;
                                rqe->buffer_size = size;
                                PRINT_D(RX_DBG, "rxq entery Size= %d - Address = %p\n", rqe->buffer_size, rqe->buffer);
-                               wilc_wlan_rxq_add(rqe);
+                               wilc_wlan_rxq_add(wilc, rqe);
                        }
                } else {
 #ifndef MEMORY_STATIC
@@ -1364,29 +1363,28 @@ _end_:
 #endif
                }
        }
-       wilc_wlan_handle_rxq();
+       wilc_wlan_handle_rxq(wilc);
 }
 
-void wilc_handle_isr(void)
+void wilc_handle_isr(void *wilc)
 {
        u32 int_status;
 
        acquire_bus(ACQUIRE_AND_WAKEUP);
        g_wlan.hif_func.hif_read_int(&int_status);
 
-       if (int_status & PLL_INT_EXT) {
+       if (int_status & PLL_INT_EXT)
                wilc_pllupdate_isr_ext(int_status);
-       }
+
        if (int_status & DATA_INT_EXT) {
-               wilc_wlan_handle_isr_ext(int_status);
+               wilc_wlan_handle_isr_ext(wilc, int_status);
        #ifndef WILC_OPTIMIZE_SLEEP_INT
                /* Chip is up and talking*/
                genuChipPSstate = CHIP_WAKEDUP;
        #endif
        }
-       if (int_status & SLEEP_INT_EXT) {
+       if (int_status & SLEEP_INT_EXT)
                wilc_sleeptimer_isr_ext(int_status);
-       }
 
        if (!(int_status & (ALL_INT_EXT))) {
 #ifdef WILC_SDIO
@@ -1402,15 +1400,15 @@ void wilc_handle_isr(void)
  *      Firmware download
  *
  ********************************************/
-static int wilc_wlan_firmware_download(const u8 *buffer, u32 buffer_size)
+int wilc_wlan_firmware_download(const u8 *buffer, u32 buffer_size)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        u32 offset;
        u32 addr, size, size2, blksz;
        u8 *dma_buffer;
        int ret = 0;
 
-       blksz = (1ul << 12);
+       blksz = BIT(12);
        /* Allocate a DMA coherent  buffer. */
 
        dma_buffer = kmalloc(blksz, GFP_KERNEL);
@@ -1475,9 +1473,9 @@ _fail_1:
  *      Common
  *
  ********************************************/
-static int wilc_wlan_start(void)
+int wilc_wlan_start(void)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        u32 reg = 0;
        int ret;
        u32 chipid;
@@ -1487,7 +1485,7 @@ static int wilc_wlan_start(void)
         **/
        if (p->io_func.io_type == HIF_SDIO) {
                reg = 0;
-               reg |= (1 << 3); /* bug 4456 and 4557 */
+               reg |= BIT(3); /* bug 4456 and 4557 */
        } else if (p->io_func.io_type == HIF_SPI) {
                reg = 1;
        }
@@ -1562,13 +1560,13 @@ static int wilc_wlan_start(void)
 
 
        p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
-       if ((reg & (1ul << 10)) == (1ul << 10)) {
-               reg &= ~(1ul << 10);
+       if ((reg & BIT(10)) == BIT(10)) {
+               reg &= ~BIT(10);
                p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
                p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
        }
 
-       reg |= (1ul << 10);
+       reg |= BIT(10);
        ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
        p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
        release_bus(RELEASE_ONLY);
@@ -1579,15 +1577,15 @@ static int wilc_wlan_start(void)
 void wilc_wlan_global_reset(void)
 {
 
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
 
        acquire_bus(ACQUIRE_AND_WAKEUP);
        p->hif_func.hif_write_reg(WILC_GLB_RESET_0, 0x0);
        release_bus(RELEASE_ONLY);
 }
-static int wilc_wlan_stop(void)
+int wilc_wlan_stop(void)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        u32 reg = 0;
        int ret;
        u8 timeout = 10;
@@ -1603,7 +1601,7 @@ static int wilc_wlan_stop(void)
                return ret;
        }
 
-       reg &= ~(1 << 10);
+       reg &= ~BIT(10);
 
 
        ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
@@ -1624,9 +1622,9 @@ static int wilc_wlan_stop(void)
                }
                PRINT_D(GENERIC_DBG, "Read RESET Reg %x : Retry%d\n", reg, timeout);
                /*Workaround to ensure that the chip is actually reset*/
-               if ((reg & (1 << 10))) {
+               if ((reg & BIT(10))) {
                        PRINT_D(GENERIC_DBG, "Bit 10 not reset : Retry %d\n", timeout);
-                       reg &= ~(1 << 10);
+                       reg &= ~BIT(10);
                        ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
                        timeout--;
                } else {
@@ -1642,26 +1640,31 @@ static int wilc_wlan_stop(void)
                }
 
        } while (timeout);
-       reg = ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 8) | (1 << 9) | (1 << 26) | (1 << 29) | (1 << 30) | (1 << 31)); /**/
-       /**/
-       p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);                                 /**/
-       reg = ~(1 << 10);                                                                                               /**/
-       /**/
-       ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);                                 /**/
-/******************************************************************************/
+       reg = (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(8) | BIT(9) | BIT(26) |
+              BIT(29) | BIT(30) | BIT(31));
+
+       p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
+       reg = (u32)~BIT(10);
+
+       ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
 
        release_bus(RELEASE_ALLOW_SLEEP);
 
        return ret;
 }
 
-static void wilc_wlan_cleanup(void)
+void wilc_wlan_cleanup(struct net_device *dev)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        struct txq_entry_t *tqe;
        struct rxq_entry_t *rqe;
        u32 reg = 0;
        int ret;
+       perInterface_wlan_t *nic;
+       struct wilc *wilc;
+
+       nic = netdev_priv(dev);
+       wilc = nic->wilc;
 
        p->quit = 1;
        do {
@@ -1674,7 +1677,7 @@ static void wilc_wlan_cleanup(void)
        } while (1);
 
        do {
-               rqe = wilc_wlan_rxq_remove();
+               rqe = wilc_wlan_rxq_remove(wilc);
                if (rqe == NULL)
                        break;
 #ifndef MEMORY_STATIC
@@ -1717,7 +1720,7 @@ static void wilc_wlan_cleanup(void)
 
 static int wilc_wlan_cfg_commit(int type, u32 drvHandler)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        wilc_cfg_frame_t *cfg = &p->cfg_frame;
        int total_len = p->cfg_frame_offset + 4 + DRIVER_HANDLER_SIZE;
        int seq_no = p->cfg_seq_no % 256;
@@ -1751,9 +1754,10 @@ static int wilc_wlan_cfg_commit(int type, u32 drvHandler)
        return 0;
 }
 
-static int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size, int commit, u32 drvHandler)
+int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size,
+                     int commit, u32 drvHandler)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        u32 offset;
        int ret_size;
 
@@ -1765,7 +1769,8 @@ static int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size, in
                p->cfg_frame_offset = 0;
 
        offset = p->cfg_frame_offset;
-       ret_size = p->cif_func.cfg_wid_set(p->cfg_frame.frame, offset, (u16)wid, buffer, buffer_size);
+       ret_size = wilc_wlan_cfg_set_wid(p->cfg_frame.frame, offset, (u16)wid,
+                                        buffer, buffer_size);
        offset += ret_size;
        p->cfg_frame_offset = offset;
 
@@ -1777,8 +1782,8 @@ static int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size, in
                if (wilc_wlan_cfg_commit(WILC_CFG_SET, drvHandler))
                        ret_size = 0;
 
-               if (p->os_func.os_wait(&g_linux_wlan->cfg_event,
-                                      CFG_PKTS_TIMEOUT)) {
+               if (linux_wlan_lock_timeout(&g_linux_wlan->cfg_event,
+                                           CFG_PKTS_TIMEOUT)) {
                        PRINT_D(TX_DBG, "Set Timed Out\n");
                        ret_size = 0;
                }
@@ -1790,9 +1795,9 @@ static int wilc_wlan_cfg_set(int start, u32 wid, u8 *buffer, u32 buffer_size, in
 
        return ret_size;
 }
-static int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drvHandler)
+int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drvHandler)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+       wilc_wlan_dev_t *p = &g_wlan;
        u32 offset;
        int ret_size;
 
@@ -1804,7 +1809,7 @@ static int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drvHandler)
                p->cfg_frame_offset = 0;
 
        offset = p->cfg_frame_offset;
-       ret_size = p->cif_func.cfg_wid_get(p->cfg_frame.frame, offset, (u16)wid);
+       ret_size = wilc_wlan_cfg_get_wid(p->cfg_frame.frame, offset, (u16)wid);
        offset += ret_size;
        p->cfg_frame_offset = offset;
 
@@ -1815,8 +1820,8 @@ static int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drvHandler)
                        ret_size = 0;
 
 
-               if (p->os_func.os_wait(&g_linux_wlan->cfg_event,
-                                      CFG_PKTS_TIMEOUT)) {
+               if (linux_wlan_lock_timeout(&g_linux_wlan->cfg_event,
+                                           CFG_PKTS_TIMEOUT)) {
                        PRINT_D(TX_DBG, "Get Timed Out\n");
                        ret_size = 0;
                }
@@ -1829,12 +1834,11 @@ static int wilc_wlan_cfg_get(int start, u32 wid, int commit, u32 drvHandler)
        return ret_size;
 }
 
-static int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 buffer_size)
+int wilc_wlan_cfg_get_val(u32 wid, u8 *buffer, u32 buffer_size)
 {
-       wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
        int ret;
 
-       ret = p->cif_func.cfg_wid_get_val((u16)wid, buffer, buffer_size);
+       ret = wilc_wlan_cfg_get_wid_value((u16)wid, buffer, buffer_size);
 
        return ret;
 }
@@ -1874,7 +1878,7 @@ u32 init_chip(void)
                        wilc_debug(N_ERR, "[wilc start]: fail read reg 0x1118 ...\n");
                        return ret;
                }
-               reg |= (1 << 0);
+               reg |= BIT(0);
                ret = g_wlan.hif_func.hif_write_reg(0x1118, reg);
                if (!ret) {
                        wilc_debug(N_ERR, "[wilc start]: fail write reg 0x1118 ...\n");
@@ -1933,25 +1937,7 @@ _fail_:
        return chipid;
 }
 
-#ifdef COMPLEMENT_BOOT
-u8 core_11b_ready(void)
-{
-       u32 reg_val;
-
-       acquire_bus(ACQUIRE_ONLY);
-       g_wlan.hif_func.hif_write_reg(0x16082c, 1);
-       g_wlan.hif_func.hif_write_reg(0x161600, 0x90);
-       g_wlan.hif_func.hif_read_reg(0x161600, &reg_val);
-       release_bus(RELEASE_ONLY);
-
-       if (reg_val == 0x90)
-               return 0;
-       else
-               return 1;
-}
-#endif
-
-int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup)
+int wilc_wlan_init(wilc_wlan_inp_t *inp)
 {
 
        int ret = 0;
@@ -1963,7 +1949,6 @@ int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup)
        /**
         *      store the input
         **/
-       memcpy((void *)&g_wlan.os_func, (void *)&inp->os_func, sizeof(wilc_wlan_os_func_t));
        memcpy((void *)&g_wlan.io_func, (void *)&inp->io_func, sizeof(wilc_wlan_io_func_t));
        /***
         *      host interface init
@@ -1996,13 +1981,11 @@ int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup)
        /***
         *      mac interface init
         **/
-       if (!mac_cfg.cfg_init(wilc_debug)) {
+       if (!wilc_wlan_cfg_init(wilc_debug)) {
                /* ENOBUFS      105 */
                ret = -105;
                goto _fail_;
        }
-       memcpy((void *)&g_wlan.cif_func, &mac_cfg, sizeof(wilc_cfg_func_t));
-
 
        /**
         *      alloc tx, rx buffer
@@ -2031,22 +2014,6 @@ int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup)
        }
 #endif
 
-       /**
-        *      export functions
-        **/
-       oup->wlan_firmware_download = wilc_wlan_firmware_download;
-       oup->wlan_start = wilc_wlan_start;
-       oup->wlan_stop = wilc_wlan_stop;
-       oup->wlan_add_to_tx_que = wilc_wlan_txq_add_net_pkt;
-       oup->wlan_handle_tx_que = wilc_wlan_handle_txq;
-       oup->wlan_handle_rx_isr = wilc_handle_isr;
-       oup->wlan_cleanup = wilc_wlan_cleanup;
-       oup->wlan_cfg_set = wilc_wlan_cfg_set;
-       oup->wlan_cfg_get = wilc_wlan_cfg_get;
-       oup->wlan_cfg_get_value = wilc_wlan_cfg_get_val;
-
-       oup->wlan_add_mgmt_to_tx_que = wilc_wlan_txq_add_mgmt_pkt;
-
        if (!init_chip()) {
                /* EIO  5 */
                ret = -5;
@@ -2071,17 +2038,21 @@ _fail_:
 
 }
 
-u16 Set_machw_change_vir_if(bool bValue)
+u16 Set_machw_change_vir_if(struct net_device *dev, bool bValue)
 {
        u16 ret;
        u32 reg;
+       perInterface_wlan_t *nic;
+       struct wilc *wilc;
+
+       nic = netdev_priv(dev);
+       wilc = nic->wilc;
 
        /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
-       mutex_lock(&g_linux_wlan->hif_cs);
+       mutex_lock(&wilc->hif_cs);
        ret = (&g_wlan)->hif_func.hif_read_reg(WILC_CHANGING_VIR_IF, &reg);
-       if (!ret) {
+       if (!ret)
                PRINT_ER("Error while Reading reg WILC_CHANGING_VIR_IF\n");
-       }
 
        if (bValue)
                reg |= BIT(31);
@@ -2090,10 +2061,10 @@ u16 Set_machw_change_vir_if(bool bValue)
 
        ret = (&g_wlan)->hif_func.hif_write_reg(WILC_CHANGING_VIR_IF, reg);
 
-       if (!ret) {
+       if (!ret)
                PRINT_ER("Error while writing reg WILC_CHANGING_VIR_IF\n");
-       }
-       mutex_unlock(&g_linux_wlan->hif_cs);
+
+       mutex_unlock(&wilc->hif_cs);
 
        return ret;
 }