staging: rtl8723au: Use kmalloc instead of vmalloc to allocate recv_frame pool
authorJes Sorensen <Jes.Sorensen@redhat.com>
Fri, 9 May 2014 13:03:55 +0000 (15:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 May 2014 20:12:00 +0000 (13:12 -0700)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/core/rtw_recv.c
drivers/staging/rtl8723au/include/rtw_recv.h

index 0999cf2311c7715319971c18cc4d8e856f986330..3f134320cc23ec450bd0bf5922332deaffdff499 100644 (file)
@@ -47,12 +47,6 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv,
        int i;
        int res = _SUCCESS;
 
-
-
-       /*  We don't need to memset padapter->XXX to zero, because
-           adapter is allocated by rtw_zvmalloc(). */
-       /* memset((unsigned char *)precvpriv, 0, sizeof (struct  recv_priv)); */
-
        spin_lock_init(&precvpriv->lock);
 
        _rtw_init_queue23a(&precvpriv->free_recv_queue);
@@ -61,19 +55,11 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv,
 
        precvpriv->adapter = padapter;
 
-       precvpriv->free_recvframe_cnt = NR_RECVFRAME;
-
-       precvpriv->pallocated_frame_buf =
-               rtw_zvmalloc(NR_RECVFRAME * sizeof(struct recv_frame));
-
-       if (precvpriv->pallocated_frame_buf == NULL) {
-               res = _FAIL;
-               goto exit;
-       }
-
-       precvframe = precvpriv->pallocated_frame_buf;
-
        for (i = 0; i < NR_RECVFRAME ; i++) {
+               precvframe = (struct recv_frame *)
+                       kzalloc(sizeof(struct recv_frame), GFP_KERNEL);
+               if (!precvframe)
+                       break;
                INIT_LIST_HEAD(&precvframe->list);
 
                list_add_tail(&precvframe->list,
@@ -83,6 +69,7 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv,
                precvframe++;
        }
 
+       precvpriv->free_recvframe_cnt = i;
        precvpriv->rx_pending_cnt = 1;
 
        sema_init(&precvpriv->allrxreturnevt, 0);
@@ -96,29 +83,24 @@ int _rtw_init_recv_priv23a(struct recv_priv *precvpriv,
 
        rtw_set_signal_stat_timer(precvpriv);
 
-exit:
-
-
-
        return res;
 }
 
 void _rtw_free_recv_priv23a (struct recv_priv *precvpriv)
 {
        struct rtw_adapter *padapter = precvpriv->adapter;
-
-
+       struct recv_frame *precvframe;
+       struct list_head *plist, *ptmp;
 
        rtw_free_uc_swdec_pending_queue23a(padapter);
 
-       if (precvpriv->pallocated_frame_buf) {
-               rtw_vmfree(precvpriv->pallocated_frame_buf,
-                          NR_RECVFRAME * sizeof(struct recv_frame));
+       list_for_each_safe(plist, ptmp, &precvpriv->free_recv_queue.queue) {
+               precvframe = container_of(plist, struct recv_frame, list);
+               list_del_init(&precvframe->list);
+               kfree(precvframe);
        }
 
        rtw_hal_free_recv_priv23a(padapter);
-
-
 }
 
 struct recv_frame *rtw_alloc_recvframe23a(struct rtw_queue *pfree_recv_queue)
index 0a88506ab859989c057d7a006cd75b94ab744c10..f47d159bfedea18d8e1ae6531f2e0177b2d0c1a1 100644 (file)
@@ -171,9 +171,7 @@ struct recv_priv {
        struct rtw_queue        recv_pending_queue;
        struct rtw_queue        uc_swdec_pending_queue;
 
-       void *pallocated_frame_buf;
-
-       uint free_recvframe_cnt;
+       int free_recvframe_cnt;
 
        struct rtw_adapter      *adapter;