staging: rtl8723au: Use kmalloc() rather than vmalloc() to allocate xmit_frames
authorJes Sorensen <Jes.Sorensen@redhat.com>
Fri, 9 May 2014 13:03:52 +0000 (15:03 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 May 2014 20:11:59 +0000 (13:11 -0700)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/core/rtw_xmit.c
drivers/staging/rtl8723au/include/rtw_xmit.h

index c59f306a9efd19ce1a87517d1afe0ad3868d4cb6..f824b9ff2cd667eb23498f7ba7ada045482998d1 100644 (file)
@@ -81,42 +81,21 @@ s32 _rtw_init_xmit_priv23a(struct xmit_priv *pxmitpriv, struct rtw_adapter *pada
 
        _rtw_init_queue23a(&pxmitpriv->free_xmit_queue);
 
-       /*
-       Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME,
-       and initialize free_xmit_frame below.
-       Please also apply  free_txobj to link_up all the xmit_frames...
-       */
-
-       pxmitpriv->pallocated_frame_buf = rtw_zvmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4);
-
-       if (pxmitpriv->pallocated_frame_buf  == NULL) {
-               pxmitpriv->pxmit_frame_buf = NULL;
-               RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_frame fail!\n"));
-               res = _FAIL;
-               goto exit;
-       }
-       pxmitpriv->pxmit_frame_buf = PTR_ALIGN(pxmitpriv->pallocated_frame_buf, 4);
-
-       pxframe = (struct xmit_frame*) pxmitpriv->pxmit_frame_buf;
-
        for (i = 0; i < NR_XMITFRAME; i++) {
+               pxframe = (struct xmit_frame *)
+                       kzalloc(sizeof(struct xmit_frame), GFP_KERNEL);
+               if (!pxframe)
+                       break;
                INIT_LIST_HEAD(&pxframe->list);
 
                pxframe->padapter = padapter;
                pxframe->frame_tag = NULL_FRAMETAG;
 
-               pxframe->pkt = NULL;
-
-               pxframe->buf_addr = NULL;
-               pxframe->pxmitbuf = NULL;
-
                list_add_tail(&pxframe->list,
                              &pxmitpriv->free_xmit_queue.queue);
-
-               pxframe++;
        }
 
-       pxmitpriv->free_xmitframe_cnt = NR_XMITFRAME;
+       pxmitpriv->free_xmitframe_cnt = i;
 
        pxmitpriv->frag_len = MAX_FRAG_THRESHOLD;
 
@@ -242,7 +221,7 @@ fail:
 void _rtw_free_xmit_priv23a (struct xmit_priv *pxmitpriv)
 {
        struct rtw_adapter *padapter = pxmitpriv->adapter;
-       struct xmit_frame *pxmitframe = (struct xmit_frame*) pxmitpriv->pxmit_frame_buf;
+       struct xmit_frame *pxframe;
        struct xmit_buf *pxmitbuf;
        struct list_head *plist, *ptmp;
        u32 num_xmit_extbuf = NR_XMIT_EXTBUFF;
@@ -250,11 +229,11 @@ void _rtw_free_xmit_priv23a (struct xmit_priv *pxmitpriv)
 
        rtw_hal_free_xmit_priv23a(padapter);
 
-       if (pxmitpriv->pxmit_frame_buf == NULL)
-               return;
-       for (i = 0; i < NR_XMITFRAME; i++) {
-               rtw_os_xmit_complete23a(padapter, pxmitframe);
-               pxmitframe++;
+       list_for_each_safe(plist, ptmp, &pxmitpriv->free_xmit_queue.queue) {
+               pxframe = container_of(plist, struct xmit_frame, list);
+               list_del_init(&pxframe->list);
+               rtw_os_xmit_complete23a(padapter, pxframe);
+               kfree(pxframe);
        }
 
        list_for_each_safe(plist, ptmp, &pxmitpriv->xmitbuf_list) {
@@ -264,15 +243,11 @@ void _rtw_free_xmit_priv23a (struct xmit_priv *pxmitpriv)
                kfree(pxmitbuf);
        }
 
-       if (pxmitpriv->pallocated_frame_buf) {
-               rtw_vmfree(pxmitpriv->pallocated_frame_buf, NR_XMITFRAME * sizeof(struct xmit_frame) + 4);
-       }
-
        /* free xframe_ext queue,  the same count as extbuf  */
-       if ((pxmitframe = (struct xmit_frame*)pxmitpriv->xframe_ext)) {
+       if ((pxframe = (struct xmit_frame*)pxmitpriv->xframe_ext)) {
                for (i = 0; i<num_xmit_extbuf; i++) {
-                       rtw_os_xmit_complete23a(padapter, pxmitframe);
-                       pxmitframe++;
+                       rtw_os_xmit_complete23a(padapter, pxframe);
+                       pxframe++;
                }
        }
        if (pxmitpriv->xframe_ext_alloc_addr)
index ca516623a2babb03168dce50f43f36563ad2ec2b..e6d417c5e09aab91946400781c9d89683e87f7f6 100644 (file)
@@ -286,9 +286,7 @@ struct      xmit_priv {
        struct rtw_queue        vo_pending;
        struct rtw_queue        bm_pending;
 
-       u8 *pallocated_frame_buf;
-       u8 *pxmit_frame_buf;
-       uint free_xmitframe_cnt;
+       int free_xmitframe_cnt;
        struct rtw_queue        free_xmit_queue;
 
        u8 *xframe_ext_alloc_addr;