staging: rtl8723au: Simplify _BlockWrite() based on saner rtl8723au_writeN()
authorJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 1 Jul 2014 08:11:22 +0000 (10:11 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Jul 2014 22:56:37 +0000 (15:56 -0700)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c

index 8b3473fd71028bd4cfd7613c4821d2e7559748ee..2bc830f9e51b8d3eb580b7d4770cd9b23af2aa34 100644 (file)
@@ -49,93 +49,14 @@ static void _FWDownloadEnable(struct rtw_adapter *padapter, bool enable)
 
 static int _BlockWrite(struct rtw_adapter *padapter, void *buffer, u32 buffSize)
 {
-       int ret = _SUCCESS;
-       /*  (Default) Phase #1 : PCI muse use 4-byte write to download FW */
-       u32 blockSize_p1 = 4;
-       /*  Phase #2 : Use 8-byte, if Phase#1 use big size to write FW. */
-       u32 blockSize_p2 = 8;
-       /*  Phase #3 : Use 1-byte, the remnant of FW image. */
-       u32 blockSize_p3 = 1;
-       u32 blockCount_p1 = 0, blockCount_p2 = 0, blockCount_p3 = 0;
-       u32 remainSize_p1 = 0, remainSize_p2 = 0;
-       u8 *bufferPtr = (u8 *) buffer;
-       u32 i = 0, offset = 0;
-
-       blockSize_p1 = 254;
-
-       /* 3 Phase #1 */
-       blockCount_p1 = buffSize / blockSize_p1;
-       remainSize_p1 = buffSize % blockSize_p1;
+       int ret;
 
-       if (blockCount_p1) {
-               RT_TRACE(_module_hal_init_c_, _drv_notice_,
-                        ("_BlockWrite: [P1] buffSize(%d) blockSize_p1(%d) "
-                         "blockCount_p1(%d) remainSize_p1(%d)\n",
-                         buffSize, blockSize_p1, blockCount_p1,
-                         remainSize_p1));
-       }
-
-       for (i = 0; i < blockCount_p1; i++) {
-               ret = rtl8723au_writeN(padapter, (FW_8723A_START_ADDRESS +
-                                                 i * blockSize_p1),
-                                      blockSize_p1,
-                                      (bufferPtr + i * blockSize_p1));
-               if (ret == _FAIL)
-                       goto exit;
-       }
-
-       /* 3 Phase #2 */
-       if (remainSize_p1) {
-               offset = blockCount_p1 * blockSize_p1;
-
-               blockCount_p2 = remainSize_p1 / blockSize_p2;
-               remainSize_p2 = remainSize_p1 % blockSize_p2;
-
-               if (blockCount_p2) {
-                       RT_TRACE(_module_hal_init_c_, _drv_notice_,
-                                ("_BlockWrite: [P2] buffSize_p2(%d) "
-                                 "blockSize_p2(%d) blockCount_p2(%d) "
-                                 "remainSize_p2(%d)\n",
-                                 (buffSize - offset), blockSize_p2,
-                                 blockCount_p2, remainSize_p2));
-               }
-
-               for (i = 0; i < blockCount_p2; i++) {
-                       ret = rtl8723au_writeN(padapter,
-                                              (FW_8723A_START_ADDRESS +
-                                               offset + i * blockSize_p2),
-                                              blockSize_p2,
-                                              (bufferPtr + offset +
-                                               i * blockSize_p2));
-
-                       if (ret == _FAIL)
-                               goto exit;
-               }
-       }
-
-       /* 3 Phase #3 */
-       if (remainSize_p2) {
-               offset = (blockCount_p1 * blockSize_p1) +
-                       (blockCount_p2 * blockSize_p2);
-
-               blockCount_p3 = remainSize_p2 / blockSize_p3;
-
-               RT_TRACE(_module_hal_init_c_, _drv_notice_,
-                        ("_BlockWrite: [P3] buffSize_p3(%d) blockSize_p3(%d) "
-                         "blockCount_p3(%d)\n",
-                         (buffSize - offset), blockSize_p3, blockCount_p3));
-
-               for (i = 0; i < blockCount_p3; i++) {
-                       ret = rtl8723au_write8(padapter,
-                                              (FW_8723A_START_ADDRESS + offset + i),
-                                              *(bufferPtr + offset + i));
+       if (buffSize > MAX_PAGE_SIZE)
+               return _FAIL;
 
-                       if (ret == _FAIL)
-                               goto exit;
-               }
-       }
+       ret = rtl8723au_writeN(padapter, FW_8723A_START_ADDRESS,
+                              buffSize, buffer);
 
-exit:
        return ret;
 }