unsigned long irqL;
struct cmd_obj *obj;
- spin_lock_irqsave(&(queue->lock), irqL);
- if (list_empty(&(queue->queue))) {
- obj = NULL;
- } else {
- obj = LIST_CONTAINOR(queue->queue.next,
- struct cmd_obj, list);
+ spin_lock_irqsave(&queue->lock, irqL);
+ obj = list_first_entry_or_null(&queue->queue,
+ struct cmd_obj, list);
+ if (obj)
list_del_init(&obj->list);
- }
- spin_unlock_irqrestore(&(queue->lock), irqL);
+ spin_unlock_irqrestore(&queue->lock, irqL);
return obj;
}
unsigned long irqL;
struct wlan_network *pnetwork;
struct __queue *free_queue = &pmlmepriv->free_bss_pool;
- struct list_head *plist = NULL;
- if (list_empty(&free_queue->queue))
- return NULL;
spin_lock_irqsave(&free_queue->lock, irqL);
- plist = free_queue->queue.next;
- pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
- list_del_init(&pnetwork->list);
- pnetwork->last_scanned = jiffies;
- pmlmepriv->num_of_scanned++;
+ pnetwork = list_first_entry_or_null(&free_queue->queue,
+ struct wlan_network, list);
+ if (pnetwork) {
+ list_del_init(&pnetwork->list);
+ pnetwork->last_scanned = jiffies;
+ pmlmepriv->num_of_scanned++;
+ }
spin_unlock_irqrestore(&free_queue->lock, irqL);
return pnetwork;
}
r8712_free_recv_priv(precvpriv);
}
-union recv_frame *r8712_alloc_recvframe(struct __queue *pfree_recv_queue)
+union recv_frame *r8712_alloc_recvframe(struct __queue *pfree_recv_queue)
{
unsigned long irqL;
union recv_frame *precvframe;
- struct list_head *plist, *phead;
struct _adapter *padapter;
struct recv_priv *precvpriv;
spin_lock_irqsave(&pfree_recv_queue->lock, irqL);
- if (list_empty(&pfree_recv_queue->queue)) {
- precvframe = NULL;
- } else {
- phead = &pfree_recv_queue->queue;
- plist = phead->next;
- precvframe = LIST_CONTAINOR(plist, union recv_frame, u);
+ precvframe = list_first_entry_or_null(&pfree_recv_queue->queue,
+ union recv_frame, u.hdr.list);
+ if (precvframe) {
list_del_init(&precvframe->u.hdr.list);
padapter = precvframe->u.hdr.adapter;
if (padapter != NULL) {
unsigned long flags;
pfree_sta_queue = &pstapriv->free_sta_queue;
- spin_lock_irqsave(&(pfree_sta_queue->lock), flags);
- if (list_empty(&pfree_sta_queue->queue)) {
- psta = NULL;
- } else {
- psta = LIST_CONTAINOR(pfree_sta_queue->queue.next,
- struct sta_info, list);
- list_del_init(&(psta->list));
+ spin_lock_irqsave(&pfree_sta_queue->lock, flags);
+ psta = list_first_entry_or_null(&pfree_sta_queue->queue,
+ struct sta_info, list);
+ if (psta) {
+ list_del_init(&psta->list);
_init_stainfo(psta);
memcpy(psta->hwaddr, hwaddr, ETH_ALEN);
index = wifi_mac_hash(hwaddr);
psta = NULL;
goto exit;
}
- phash_list = &(pstapriv->sta_hash[index]);
+ phash_list = &pstapriv->sta_hash[index];
list_add_tail(&psta->hash_list, phash_list);
pstapriv->asoc_sta_count++;
}
}
exit:
- spin_unlock_irqrestore(&(pfree_sta_queue->lock), flags);
+ spin_unlock_irqrestore(&pfree_sta_queue->lock, flags);
return psta;
}
struct xmit_buf *r8712_alloc_xmitbuf(struct xmit_priv *pxmitpriv)
{
unsigned long irqL;
- struct xmit_buf *pxmitbuf = NULL;
- struct list_head *plist, *phead;
+ struct xmit_buf *pxmitbuf;
struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue;
spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irqL);
- if (list_empty(&pfree_xmitbuf_queue->queue)) {
- pxmitbuf = NULL;
- } else {
- phead = &pfree_xmitbuf_queue->queue;
- plist = phead->next;
- pxmitbuf = LIST_CONTAINOR(plist, struct xmit_buf, list);
- list_del_init(&(pxmitbuf->list));
- }
- if (pxmitbuf != NULL)
+ pxmitbuf = list_first_entry_or_null(&pfree_xmitbuf_queue->queue,
+ struct xmit_buf, list);
+ if (pxmitbuf) {
+ list_del_init(&pxmitbuf->list);
pxmitpriv->free_xmitbuf_cnt--;
+ }
spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irqL);
return pxmitbuf;
}
pfree_xmit_queue
*/
unsigned long irqL;
- struct xmit_frame *pxframe = NULL;
- struct list_head *plist, *phead;
+ struct xmit_frame *pxframe;
struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue;
spin_lock_irqsave(&pfree_xmit_queue->lock, irqL);
- if (list_empty(&pfree_xmit_queue->queue)) {
- pxframe = NULL;
- } else {
- phead = &pfree_xmit_queue->queue;
- plist = phead->next;
- pxframe = LIST_CONTAINOR(plist, struct xmit_frame, list);
- list_del_init(&(pxframe->list));
- }
- if (pxframe != NULL) {
+ pxframe = list_first_entry_or_null(&pfree_xmit_queue->queue,
+ struct xmit_frame, list);
+ if (pxframe) {
+ list_del_init(&pxframe->list);
pxmitpriv->free_xmitframe_cnt--;
pxframe->buf_addr = NULL;
pxframe->pxmitbuf = NULL;