Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[firefly-linux-kernel-4.4.55.git] / drivers / staging / wilc1000 / wilc_wlan.c
index 747374291bdd9bf14e99f33de7bd7787b30c6924..c0266574770521860aff9db94f70b882a66feb49 100644 (file)
@@ -19,7 +19,6 @@
 extern wilc_hif_func_t hif_sdio;
 extern wilc_hif_func_t hif_spi;
 u32 wilc_get_chipid(u8 update);
-u16 Set_machw_change_vir_if(bool bValue);
 
 
 
@@ -342,7 +341,7 @@ 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;
@@ -351,8 +350,13 @@ static inline int tcp_process(struct txq_entry_t *tqe)
        int i;
        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]));
@@ -400,7 +404,7 @@ 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;
 }
 
@@ -503,8 +507,8 @@ static int wilc_wlan_txq_add_cfg_pkt(u8 *buffer, u32 buffer_size)
        return 1;
 }
 
-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 = &g_wlan;
        struct txq_entry_t *tqe;
@@ -526,7 +530,7 @@ int wilc_wlan_txq_add_net_pkt(void *priv, u8 *buffer, u32 buffer_size,
 #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*/
@@ -575,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 = &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;
@@ -608,11 +613,11 @@ 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 = &g_wlan;
 
@@ -620,12 +625,12 @@ static struct rxq_entry_t *wilc_wlan_rxq_remove(void)
        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");
@@ -888,7 +893,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, 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;
                        }
@@ -1132,7 +1137,7 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc)
                        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;
@@ -1184,7 +1189,8 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc)
 
                                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;
@@ -1349,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
@@ -1654,6 +1660,11 @@ void wilc_wlan_cleanup(struct net_device *dev)
        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 {
@@ -1666,7 +1677,7 @@ void wilc_wlan_cleanup(struct net_device *dev)
        } while (1);
 
        do {
-               rqe = wilc_wlan_rxq_remove();
+               rqe = wilc_wlan_rxq_remove(wilc);
                if (rqe == NULL)
                        break;
 #ifndef MEMORY_STATIC
@@ -2027,13 +2038,18 @@ _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)
                PRINT_ER("Error while Reading reg WILC_CHANGING_VIR_IF\n");
@@ -2048,7 +2064,7 @@ u16 Set_machw_change_vir_if(bool bValue)
        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;
 }