staging: rtl8712: use container_of() instead of LIST_CONTAINOR()
authorGeliang Tang <geliangtang@163.com>
Tue, 5 Apr 2016 01:58:04 +0000 (09:58 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Apr 2016 00:53:47 +0000 (17:53 -0700)
This patch drops the local definition of LIST_CONTAINOR(), and uses
container_of() instead of it.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8712/osdep_service.h
drivers/staging/rtl8712/rtl8712_recv.c
drivers/staging/rtl8712/rtl8712_xmit.c
drivers/staging/rtl8712/rtl871x_ioctl_linux.c
drivers/staging/rtl8712/rtl871x_mlme.c
drivers/staging/rtl8712/rtl871x_recv.c
drivers/staging/rtl8712/rtl871x_sta_mgt.c
drivers/staging/rtl8712/rtl871x_xmit.c

index 076d5083c723685839f7a1beab4880efeec22db4..ad041c96fdb84817a6e7e19cb60b33d197f535ef 100644 (file)
@@ -57,9 +57,6 @@ struct        __queue {
                spin_lock_init(&((pqueue)->lock));      \
        } while (0)
 
-#define LIST_CONTAINOR(ptr, type, member) \
-       ((type *)((char *)(ptr)-(SIZE_T)(&((type *)0)->member)))
-
 static inline u32 _down_sema(struct semaphore *sema)
 {
        if (down_interruptible(sema))
index d187508dd1e0af956454d07b31f8bd4a1a176af5..f25b34c7d11520765096bc5cb7af890882270de5 100644 (file)
@@ -204,7 +204,7 @@ static union recv_frame *recvframe_defrag(struct _adapter *adapter,
        pfree_recv_queue = &adapter->recvpriv.free_recv_queue;
        phead = &defrag_q->queue;
        plist = phead->next;
-       prframe = LIST_CONTAINOR(plist, union recv_frame, u);
+       prframe = container_of(plist, union recv_frame, u.list);
        list_del_init(&prframe->u.list);
        pfhdr = &prframe->u.hdr;
        curfragnum = 0;
@@ -219,7 +219,7 @@ static union recv_frame *recvframe_defrag(struct _adapter *adapter,
        plist = &defrag_q->queue;
        plist = plist->next;
        while (!end_of_queue_search(phead, plist)) {
-               pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u);
+               pnextrframe = container_of(plist, union recv_frame, u.list);
                pnfhdr = &pnextrframe->u.hdr;
                /*check the fragment sequence  (2nd ~n fragment frame) */
                if (curfragnum != pnfhdr->attrib.frag_num) {
@@ -492,7 +492,7 @@ static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl,
        phead = &ppending_recvframe_queue->queue;
        plist = phead->next;
        while (!end_of_queue_search(phead, plist)) {
-               pnextrframe = LIST_CONTAINOR(plist, union recv_frame, u);
+               pnextrframe = container_of(plist, union recv_frame, u.list);
                pnextattrib = &pnextrframe->u.hdr.attrib;
                if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num))
                        plist = plist->next;
@@ -525,14 +525,14 @@ int r8712_recv_indicatepkts_in_order(struct _adapter *padapter,
                if (list_empty(phead))
                        return true;
 
-               prframe = LIST_CONTAINOR(plist, union recv_frame, u);
+               prframe = container_of(plist, union recv_frame, u.list);
                pattrib = &prframe->u.hdr.attrib;
                preorder_ctrl->indicate_seq = pattrib->seq_num;
        }
        /* Prepare indication list and indication.
         * Check if there is any packet need indicate. */
        while (!list_empty(phead)) {
-               prframe = LIST_CONTAINOR(plist, union recv_frame, u);
+               prframe = container_of(plist, union recv_frame, u.list);
                pattrib = &prframe->u.hdr.attrib;
                if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) {
                        plist = plist->next;
index b21a60e9f8a9b9d7e30b405f93c986ca70f1d62d..7e0b94503dfc4f2d9ee791238e1f2d535f3b506b 100644 (file)
@@ -169,8 +169,8 @@ static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv,
        xmitframe_phead = &pframe_queue->queue;
        xmitframe_plist = xmitframe_phead->next;
        if (!end_of_queue_search(xmitframe_phead, xmitframe_plist)) {
-               pxmitframe = LIST_CONTAINOR(xmitframe_plist,
-                            struct xmit_frame, list);
+               pxmitframe = container_of(xmitframe_plist,
+                                         struct xmit_frame, list);
                list_del_init(&pxmitframe->list);
                ptxservq->qcnt--;
                phwxmit->txcmdcnt++;
@@ -209,8 +209,8 @@ static struct xmit_frame *dequeue_xframe_ex(struct xmit_priv *pxmitpriv,
                sta_phead = &phwxmit->sta_queue->queue;
                sta_plist = sta_phead->next;
                while (!end_of_queue_search(sta_phead, sta_plist)) {
-                       ptxservq = LIST_CONTAINOR(sta_plist, struct tx_servq,
-                                 tx_pending);
+                       ptxservq = container_of(sta_plist, struct tx_servq,
+                                               tx_pending);
                        pframe_queue = &ptxservq->sta_pending;
                        pxmitframe = dequeue_one_xmitframe(pxmitpriv, phwxmit,
                                     ptxservq, pframe_queue);
index 6c02e9b29e2d232ff7f0e1a80427ee403b94641e..e205adf24da27b0fac122e847e620cc487b5cf88 100644 (file)
@@ -1060,8 +1060,8 @@ static int r8711_wx_set_wap(struct net_device *dev,
        while (1) {
                if (end_of_queue_search(phead, pmlmepriv->pscanned))
                        break;
-               pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned,
-                          struct wlan_network, list);
+               pnetwork = container_of(pmlmepriv->pscanned,
+                                       struct wlan_network, list);
                pmlmepriv->pscanned = pmlmepriv->pscanned->next;
                dst_bssid = pnetwork->network.MacAddress;
                if (!memcmp(dst_bssid, temp->sa_data, ETH_ALEN)) {
@@ -1216,7 +1216,7 @@ static int r8711_wx_get_scan(struct net_device *dev,
                        ret = -E2BIG;
                        break;
                }
-               pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
+               pnetwork = container_of(plist, struct wlan_network, list);
                ev = translate_scan(padapter, a, pnetwork, ev, stop);
                plist = plist->next;
        }
@@ -1271,8 +1271,8 @@ static int r8711_wx_set_essid(struct net_device *dev,
                while (1) {
                        if (end_of_queue_search(phead, pmlmepriv->pscanned))
                                break;
-                       pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned,
-                                  struct wlan_network, list);
+                       pnetwork = container_of(pmlmepriv->pscanned,
+                                               struct wlan_network, list);
                        pmlmepriv->pscanned = pmlmepriv->pscanned->next;
                        dst_ssid = pnetwork->network.Ssid.Ssid;
                        if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength))
@@ -1986,7 +1986,7 @@ static int r871x_get_ap_info(struct net_device *dev,
        while (1) {
                if (end_of_queue_search(phead, plist))
                        break;
-               pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
+               pnetwork = container_of(plist, struct wlan_network, list);
                if (!mac_pton(data, bssid)) {
                        netdev_info(dev, "r8712u: Invalid BSSID '%s'.\n",
                                    (u8 *)data);
index f8b1c896019259223fde8e0861a2855531ff916a..772bf9fa95920e7cb3c973743a4ab777a5f63b03 100644 (file)
@@ -155,7 +155,7 @@ static struct wlan_network *_r8712_find_network(struct  __queue *scanned_queue,
        phead = &scanned_queue->queue;
        plist = phead->next;
        while (plist != phead) {
-               pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
+               pnetwork = container_of(plist, struct wlan_network, list);
                plist = plist->next;
                if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN))
                        break;
@@ -176,7 +176,7 @@ static void _free_network_queue(struct _adapter *padapter)
        phead = &scanned_queue->queue;
        plist = phead->next;
        while (!end_of_queue_search(phead, plist)) {
-               pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
+               pnetwork = container_of(plist, struct wlan_network, list);
                plist = plist->next;
                _free_network(pmlmepriv, pnetwork);
        }
@@ -304,7 +304,7 @@ struct      wlan_network *r8712_get_oldest_wlan_network(
        while (1) {
                if (end_of_queue_search(phead, plist) ==  true)
                        break;
-               pwlan = LIST_CONTAINOR(plist, struct wlan_network, list);
+               pwlan = container_of(plist, struct wlan_network, list);
                if (pwlan->fixed != true) {
                        if (oldest == NULL ||
                            time_after((unsigned long)oldest->last_scanned,
@@ -390,7 +390,7 @@ static void update_scanned_network(struct _adapter *adapter,
                if (end_of_queue_search(phead, plist))
                        break;
 
-               pnetwork = LIST_CONTAINOR(plist, struct wlan_network, list);
+               pnetwork = container_of(plist, struct wlan_network, list);
                if (is_same_network(&pnetwork->network, target))
                        break;
                if ((oldest == ((struct wlan_network *)0)) ||
@@ -1135,8 +1135,8 @@ int r8712_select_and_join_from_scan(struct mlme_priv *pmlmepriv)
                        }
                        return _FAIL;
                }
-               pnetwork = LIST_CONTAINOR(pmlmepriv->pscanned,
-                                         struct wlan_network, list);
+               pnetwork = container_of(pmlmepriv->pscanned,
+                                       struct wlan_network, list);
                if (pnetwork == NULL)
                        return _FAIL;
                pmlmepriv->pscanned = pmlmepriv->pscanned->next;
index 616ca396591983b94227d4874d1c4c71482da78a..23c1438902523837d21e95f1522331d944ad1746 100644 (file)
@@ -142,7 +142,7 @@ void r8712_free_recvframe_queue(struct  __queue *pframequeue,
        phead = &pframequeue->queue;
        plist = phead->next;
        while (!end_of_queue_search(phead, plist)) {
-               precvframe = LIST_CONTAINOR(plist, union recv_frame, u);
+               precvframe = container_of(plist, union recv_frame, u.list);
                plist = plist->next;
                r8712_free_recvframe(precvframe, pfree_recv_queue);
        }
index e90c00de7499be54d501d4110f336f876188714e..e11ce2896893648729b7aa6b80f6df847e1f26ef 100644 (file)
@@ -216,8 +216,8 @@ void r8712_free_all_stainfo(struct _adapter *padapter)
                phead = &(pstapriv->sta_hash[index]);
                plist = phead->next;
                while (!end_of_queue_search(phead, plist)) {
-                       psta = LIST_CONTAINOR(plist,
-                                             struct sta_info, hash_list);
+                       psta = container_of(plist,
+                                           struct sta_info, hash_list);
                        plist = plist->next;
                        if (pbcmc_stainfo != psta)
                                r8712_free_stainfo(padapter, psta);
@@ -241,7 +241,7 @@ struct sta_info *r8712_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr)
        phead = &(pstapriv->sta_hash[index]);
        plist = phead->next;
        while (!end_of_queue_search(phead, plist)) {
-               psta = LIST_CONTAINOR(plist, struct sta_info, hash_list);
+               psta = container_of(plist, struct sta_info, hash_list);
                if ((!memcmp(psta->hwaddr, hwaddr, ETH_ALEN))) {
                        /* if found the matched address */
                        break;
index c6d952f5d8f908d804df9ca1ce1701bd864a9250..99256baafd3885a0ee929ff64fabbeaf4ff158fc 100644 (file)
@@ -848,7 +848,7 @@ void r8712_free_xmitframe_queue(struct xmit_priv *pxmitpriv,
        phead = &pframequeue->queue;
        plist = phead->next;
        while (!end_of_queue_search(phead, plist)) {
-               pxmitframe = LIST_CONTAINOR(plist, struct xmit_frame, list);
+               pxmitframe = container_of(plist, struct xmit_frame, list);
                plist = plist->next;
                r8712_free_xmitframe(pxmitpriv, pxmitframe);
        }