[PATCH 09/10] staging: rtl8723au: Simplify _BlockWrite() based on saner rtl8723au_writeN()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>

Signed-off-by: Jes Sorensen <Jes.Sorensen@xxxxxxxxxx>
---
 drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 89 ++---------------------
 1 file changed, 5 insertions(+), 84 deletions(-)

diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
index 8b3473f..2bc830f 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
@@ -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;
 }
 
-- 
1.9.3

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux