staging: wilc1000: use list_head to maintain 'rxq_entry_t elements in rx queue
authorAjay Singh <ajay.kathat@microchip.com>
Mon, 4 Jun 2018 05:29:08 +0000 (10:59 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 17 Jun 2018 07:05:13 +0000 (09:05 +0200)
Make use of 'list_head' data structure to maintain the rx buffer queue.
Modified wilc_wlan_rxq_add() to add the element at the tail by using
list_head API and wilc_wlan_rxq_remove() to remove the element from
head.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/linux_wlan.c
drivers/staging/wilc1000/wilc_wfi_netdevice.h
drivers/staging/wilc1000/wilc_wlan.c
drivers/staging/wilc1000/wilc_wlan.h

index eac719b5ad703f730e6377dbdcf905e039842e1a..0019bb8df6c1ca2d5cff1cea03c96b545d0e25dd 100644 (file)
@@ -1119,6 +1119,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
        wl->gpio = gpio;
        wl->hif_func = ops;
        INIT_LIST_HEAD(&wl->txq_head.list);
+       INIT_LIST_HEAD(&wl->rxq_head.list);
 
        register_inetaddr_notifier(&g_dev_notifier);
 
index e1fab734c82a5f616fcebd4e1a8c69d8cbc0ef29..ba57f42755f581959e274dfc58023ccd751c2f00 100644 (file)
@@ -161,8 +161,7 @@ struct wilc {
        int txq_entries;
        int txq_exit;
 
-       struct rxq_entry_t *rxq_head;
-       struct rxq_entry_t *rxq_tail;
+       struct rxq_entry_t rxq_head;
        int rxq_entries;
        int rxq_exit;
 
index 857cc382b2d3f286478469a040d410c08226d57e..059c5c73ee68e36fdb686aeebc3e2dff238279a5 100644 (file)
@@ -404,15 +404,7 @@ static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe)
                return 0;
 
        mutex_lock(&wilc->rxq_cs);
-       if (!wilc->rxq_head) {
-               rqe->next = NULL;
-               wilc->rxq_head = rqe;
-               wilc->rxq_tail = rqe;
-       } else {
-               wilc->rxq_tail->next = rqe;
-               rqe->next = NULL;
-               wilc->rxq_tail = rqe;
-       }
+       list_add_tail(&rqe->list, &wilc->rxq_head.list);
        wilc->rxq_entries += 1;
        mutex_unlock(&wilc->rxq_cs);
        return wilc->rxq_entries;
@@ -420,17 +412,17 @@ static int wilc_wlan_rxq_add(struct wilc *wilc, struct rxq_entry_t *rqe)
 
 static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc)
 {
-       if (wilc->rxq_head) {
-               struct rxq_entry_t *rqe;
+       struct rxq_entry_t *rqe = NULL;
 
-               mutex_lock(&wilc->rxq_cs);
-               rqe = wilc->rxq_head;
-               wilc->rxq_head = wilc->rxq_head->next;
+       mutex_lock(&wilc->rxq_cs);
+       if (!list_empty(&wilc->rxq_head.list)) {
+               rqe = list_first_entry(&wilc->rxq_head.list, struct rxq_entry_t,
+                                      list);
+               list_del(&rqe->list);
                wilc->rxq_entries -= 1;
-               mutex_unlock(&wilc->rxq_cs);
-               return rqe;
        }
-       return NULL;
+       mutex_unlock(&wilc->rxq_cs);
+       return rqe;
 }
 
 void chip_allow_sleep(struct wilc *wilc)
index e0ff3e8c083628f95efa7b4481ec20bd184fe003..dbdebf009024501ad1bdd1d4bd932fbe6dc9d695 100644 (file)
@@ -218,7 +218,7 @@ struct txq_entry_t {
 };
 
 struct rxq_entry_t {
-       struct rxq_entry_t *next;
+       struct list_head list;
        u8 *buffer;
        int buffer_size;
 };