Commit 3d9241d6 authored by Ajay Singh's avatar Ajay Singh Committed by Greg Kroah-Hartman

staging: wilc1000: use list_head to maintain 'txq_entry_t' elements of tx queue

Use list_head data structure for the doubly linked list instead of own
implementation.
Only 'txq_head' is required, so removed the txq_tail pointer from
'wilc' structure.

Following functions are modified to provide data using list_head API's
wilc_wlan_txq_remove()
wilc_wlan_txq_remove_from_head()
wilc_wlan_txq_add_to_tail()
wilc_wlan_txq_add_to_head()
wilc_wlan_txq_get_first()
wilc_wlan_txq_get_next()
Signed-off-by: default avatarAjay Singh <ajay.kathat@microchip.com>
Reviewed-by: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e986b667
...@@ -1118,6 +1118,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type, ...@@ -1118,6 +1118,7 @@ int wilc_netdev_init(struct wilc **wilc, struct device *dev, int io_type,
wl->io_type = io_type; wl->io_type = io_type;
wl->gpio = gpio; wl->gpio = gpio;
wl->hif_func = ops; wl->hif_func = ops;
INIT_LIST_HEAD(&wl->txq_head.list);
register_inetaddr_notifier(&g_dev_notifier); register_inetaddr_notifier(&g_dev_notifier);
......
...@@ -157,8 +157,7 @@ struct wilc { ...@@ -157,8 +157,7 @@ struct wilc {
unsigned long txq_spinlock_flags; unsigned long txq_spinlock_flags;
struct txq_entry_t *txq_head; struct txq_entry_t txq_head;
struct txq_entry_t *txq_tail;
int txq_entries; int txq_entries;
int txq_exit; int txq_exit;
......
...@@ -20,25 +20,14 @@ static inline void release_bus(struct wilc *wilc, enum bus_release release) ...@@ -20,25 +20,14 @@ static inline void release_bus(struct wilc *wilc, enum bus_release release)
static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe) static void wilc_wlan_txq_remove(struct wilc *wilc, struct txq_entry_t *tqe)
{ {
if (tqe == wilc->txq_head) { list_del(&tqe->list);
wilc->txq_head = tqe->next;
if (wilc->txq_head)
wilc->txq_head->prev = NULL;
} else if (tqe == wilc->txq_tail) {
wilc->txq_tail = (tqe->prev);
if (wilc->txq_tail)
wilc->txq_tail->next = NULL;
} else {
tqe->prev->next = tqe->next;
tqe->next->prev = tqe->prev;
}
wilc->txq_entries -= 1; wilc->txq_entries -= 1;
} }
static struct txq_entry_t * static struct txq_entry_t *
wilc_wlan_txq_remove_from_head(struct net_device *dev) wilc_wlan_txq_remove_from_head(struct net_device *dev)
{ {
struct txq_entry_t *tqe; struct txq_entry_t *tqe = NULL;
unsigned long flags; unsigned long flags;
struct wilc_vif *vif; struct wilc_vif *vif;
struct wilc *wilc; struct wilc *wilc;
...@@ -47,15 +36,12 @@ wilc_wlan_txq_remove_from_head(struct net_device *dev) ...@@ -47,15 +36,12 @@ wilc_wlan_txq_remove_from_head(struct net_device *dev)
wilc = vif->wilc; wilc = vif->wilc;
spin_lock_irqsave(&wilc->txq_spinlock, flags); spin_lock_irqsave(&wilc->txq_spinlock, flags);
if (wilc->txq_head) {
tqe = wilc->txq_head;
wilc->txq_head = tqe->next;
if (wilc->txq_head)
wilc->txq_head->prev = NULL;
if (!list_empty(&wilc->txq_head.list)) {
tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t,
list);
list_del(&tqe->list);
wilc->txq_entries -= 1; wilc->txq_entries -= 1;
} else {
tqe = NULL;
} }
spin_unlock_irqrestore(&wilc->txq_spinlock, flags); spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
return tqe; return tqe;
...@@ -73,17 +59,7 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev, ...@@ -73,17 +59,7 @@ static void wilc_wlan_txq_add_to_tail(struct net_device *dev,
spin_lock_irqsave(&wilc->txq_spinlock, flags); spin_lock_irqsave(&wilc->txq_spinlock, flags);
if (!wilc->txq_head) { list_add_tail(&tqe->list, &wilc->txq_head.list);
tqe->next = NULL;
tqe->prev = NULL;
wilc->txq_head = tqe;
wilc->txq_tail = tqe;
} else {
tqe->next = NULL;
tqe->prev = wilc->txq_tail;
wilc->txq_tail->next = tqe;
wilc->txq_tail = tqe;
}
wilc->txq_entries += 1; wilc->txq_entries += 1;
spin_unlock_irqrestore(&wilc->txq_spinlock, flags); spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
...@@ -101,17 +77,7 @@ static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif, ...@@ -101,17 +77,7 @@ static int wilc_wlan_txq_add_to_head(struct wilc_vif *vif,
spin_lock_irqsave(&wilc->txq_spinlock, flags); spin_lock_irqsave(&wilc->txq_spinlock, flags);
if (!wilc->txq_head) { list_add(&tqe->list, &wilc->txq_head.list);
tqe->next = NULL;
tqe->prev = NULL;
wilc->txq_head = tqe;
wilc->txq_tail = tqe;
} else {
tqe->next = wilc->txq_head;
tqe->prev = NULL;
wilc->txq_head->prev = tqe;
wilc->txq_head = tqe;
}
wilc->txq_entries += 1; wilc->txq_entries += 1;
spin_unlock_irqrestore(&wilc->txq_spinlock, flags); spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
...@@ -402,12 +368,14 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer, ...@@ -402,12 +368,14 @@ int wilc_wlan_txq_add_mgmt_pkt(struct net_device *dev, void *priv, u8 *buffer,
static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc) static struct txq_entry_t *wilc_wlan_txq_get_first(struct wilc *wilc)
{ {
struct txq_entry_t *tqe; struct txq_entry_t *tqe = NULL;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&wilc->txq_spinlock, flags); spin_lock_irqsave(&wilc->txq_spinlock, flags);
tqe = wilc->txq_head; if (!list_empty(&wilc->txq_head.list))
tqe = list_first_entry(&wilc->txq_head.list, struct txq_entry_t,
list);
spin_unlock_irqrestore(&wilc->txq_spinlock, flags); spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
...@@ -421,7 +389,10 @@ static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc, ...@@ -421,7 +389,10 @@ static struct txq_entry_t *wilc_wlan_txq_get_next(struct wilc *wilc,
spin_lock_irqsave(&wilc->txq_spinlock, flags); spin_lock_irqsave(&wilc->txq_spinlock, flags);
tqe = tqe->next; if (!list_is_last(&tqe->list, &wilc->txq_head.list))
tqe = list_next_entry(tqe, list);
else
tqe = NULL;
spin_unlock_irqrestore(&wilc->txq_spinlock, flags); spin_unlock_irqrestore(&wilc->txq_spinlock, flags);
return tqe; return tqe;
......
...@@ -207,8 +207,7 @@ ...@@ -207,8 +207,7 @@
********************************************/ ********************************************/
struct txq_entry_t { struct txq_entry_t {
struct txq_entry_t *next; struct list_head list;
struct txq_entry_t *prev;
int type; int type;
int tcp_pending_ack_idx; int tcp_pending_ack_idx;
u8 *buffer; u8 *buffer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment