linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer
@ 2022-01-07 10:36 Michael Straube
  2022-01-07 10:36 ` [PATCH 01/19] staging: r8188eu: remove Firmware* from struct hal_data_8188e Michael Straube
                   ` (18 more replies)
  0 siblings, 19 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

This series starts to clean up firmware related code and moves
the firmware loading out of rtl8188e_hal_init.c into the new file
core/rtw_fw.c.

Tested on x86_64 with Inter-Tech DMG-02.

Michael Straube (19):
  staging: r8188eu: remove Firmware* from struct hal_data_8188e
  staging: r8188eu: remove rtl8188e_InitializeFirmwareVars()
  staging: r8188eu: release_firmware is not called if allocation fails
  staging: r8188eu: rename Exit label in load_firmware()
  staging: r8188eu: rename rtStatus in load_firmware()
  staging: r8188eu: convert type of return variable in load_firmware()
  staging: r8188eu: rename parameter pFirmware of load_firmware()
  staging: r8188eu: rename fields of struct rt_firmware
  staging: r8188eu: use kmemdup instead of kzalloc and memcpy
  staging: r8188eu: rename fw related functions to avoid camel case
  staging: r8188eu: clean up rtw_reset_8051()
  staging: r8188eu: convert two functions from s32 to int
  staging: r8188eu: rename Exit label in rtl8188e_firmware_download()
  staging: r8188eu: rename rtSatus in rtl8188e_firmware_download()
  staging: r8188eu: rename FWDL_ChkSum_rpt
  staging: r8188eu: rename writeFW_retry
  staging: r8188eu: rename pFwHdr in rtl8188e_firmware_download()
  staging: r8188eu: rename pFirmwareBuf and FirmwareLen
  staging: r8188eu: move firmware loading code out of the hal layer

 drivers/staging/r8188eu/Makefile              |   1 +
 drivers/staging/r8188eu/core/rtw_fw.c         | 284 ++++++++++++++++
 .../staging/r8188eu/hal/rtl8188e_hal_init.c   | 303 +-----------------
 drivers/staging/r8188eu/hal/usb_halinit.c     |   8 +-
 drivers/staging/r8188eu/include/drv_types.h   |   4 +-
 .../staging/r8188eu/include/rtl8188e_hal.h    |  10 -
 .../staging/r8188eu/include/rtl8188e_spec.h   |   2 +-
 drivers/staging/r8188eu/include/rtw_fw.h      |  14 +
 drivers/staging/r8188eu/os_dep/os_intfs.c     |   4 +-
 9 files changed, 311 insertions(+), 319 deletions(-)
 create mode 100644 drivers/staging/r8188eu/core/rtw_fw.c
 create mode 100644 drivers/staging/r8188eu/include/rtw_fw.h

-- 
2.34.1


^ permalink raw reply	[flat|nested] 23+ messages in thread

* [PATCH 01/19] staging: r8188eu: remove Firmware* from struct hal_data_8188e
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 02/19] staging: r8188eu: remove rtl8188e_InitializeFirmwareVars() Michael Straube
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

The fields FirmwareVersion, FirmwareSubVersion and FirmwareSignature
of struct hal_data_8188e are only used in the function
rtl8188e_FirmwareDownload(). Use local variables in that function and
remove the fields from struct hal_data_8188e. FirmwareVersionRev is
not used at all, remove it as well.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 11 +++++------
 drivers/staging/r8188eu/include/rtl8188e_hal.h  |  4 ----
 2 files changed, 5 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index b818872e0d19..20e4a12801cf 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -550,10 +550,10 @@ s32 rtl8188e_FirmwareDownload(struct adapter *padapter)
 	s32	rtStatus = _SUCCESS;
 	u8 writeFW_retry = 0;
 	u32 fwdl_start_time;
-	struct hal_data_8188e *pHalData = &padapter->haldata;
 	struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
 	struct device *device = dvobj_to_dev(dvobj);
 	struct rt_firmware_hdr *pFwHdr = NULL;
+	u16 fw_version, fw_subversion, fw_signature;
 	u8 *pFirmwareBuf;
 	u32 FirmwareLen;
 	static int log_version;
@@ -570,14 +570,13 @@ s32 rtl8188e_FirmwareDownload(struct adapter *padapter)
 	/*  To Check Fw header. Added by tynli. 2009.12.04. */
 	pFwHdr = (struct rt_firmware_hdr *)dvobj->firmware.szFwBuffer;
 
-	pHalData->FirmwareVersion =  le16_to_cpu(pFwHdr->Version);
-	pHalData->FirmwareSubVersion = pFwHdr->Subversion;
-	pHalData->FirmwareSignature = le16_to_cpu(pFwHdr->Signature);
+	fw_version = le16_to_cpu(pFwHdr->Version);
+	fw_subversion = pFwHdr->Subversion;
+	fw_signature = le16_to_cpu(pFwHdr->Signature);
 
 	if (!log_version++)
 		pr_info("%sFirmware Version %d, SubVersion %d, Signature 0x%x\n",
-			DRIVER_PREFIX, pHalData->FirmwareVersion,
-			pHalData->FirmwareSubVersion, pHalData->FirmwareSignature);
+			DRIVER_PREFIX, fw_version, fw_subversion, fw_signature);
 
 	if (IS_FW_HEADER_EXIST(pFwHdr)) {
 		/*  Shift 32 bytes for FW header */
diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h
index 8134a173ea07..9133f3b0acc1 100644
--- a/drivers/staging/r8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/r8188eu/include/rtl8188e_hal.h
@@ -162,10 +162,6 @@ struct txpowerinfo24g {
 
 struct hal_data_8188e {
 	struct HAL_VERSION	VersionID;
-	u16	FirmwareVersion;
-	u16	FirmwareVersionRev;
-	u16	FirmwareSubVersion;
-	u16	FirmwareSignature;
 	u8	PGMaxGroup;
 	/* current WIFI_PHY values */
 	u32	ReceiveConfig;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 02/19] staging: r8188eu: remove rtl8188e_InitializeFirmwareVars()
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
  2022-01-07 10:36 ` [PATCH 01/19] staging: r8188eu: remove Firmware* from struct hal_data_8188e Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 03/19] staging: r8188eu: release_firmware is not called if allocation fails Michael Straube
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Merge rtl8188e_InitializeFirmwareVars() into rtl8188eu_hal_init()
and remove rtl8188e_InitializeFirmwareVars().

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 11 -----------
 drivers/staging/r8188eu/hal/usb_halinit.c       |  4 +++-
 drivers/staging/r8188eu/include/rtl8188e_hal.h  |  1 -
 3 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index 20e4a12801cf..dc41682fd8d6 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -623,17 +623,6 @@ s32 rtl8188e_FirmwareDownload(struct adapter *padapter)
 	return rtStatus;
 }
 
-void rtl8188e_InitializeFirmwareVars(struct adapter *padapter)
-{
-	struct hal_data_8188e *pHalData = &padapter->haldata;
-
-	/*  Init Fw LPS related. */
-	padapter->pwrctrlpriv.bFwCurrentInPSMode = false;
-
-	/*  Init H2C counter. by tynli. 2009.12.09. */
-	pHalData->LastHMEBoxNum = 0;
-}
-
 /*  */
 /*			Efuse related code */
 /*  */
diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 96db9a8e7667..696beb29536f 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -636,7 +636,9 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter)
 		Adapter->bFWReady = true;
 		haldata->fw_ractrl = false;
 	}
-	rtl8188e_InitializeFirmwareVars(Adapter);
+	/* Initialize firmware vars */
+	Adapter->pwrctrlpriv.bFwCurrentInPSMode = false;
+	haldata->LastHMEBoxNum = 0;
 
 #if (HAL_MAC_ENABLE == 1)
 	status = PHY_MACConfig8188E(Adapter);
diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h
index 9133f3b0acc1..3da04751f25d 100644
--- a/drivers/staging/r8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/r8188eu/include/rtl8188e_hal.h
@@ -253,7 +253,6 @@ struct hal_data_8188e {
 /*  rtl8188e_hal_init.c */
 s32 rtl8188e_FirmwareDownload(struct adapter *padapter);
 void _8051Reset88E(struct adapter *padapter);
-void rtl8188e_InitializeFirmwareVars(struct adapter *padapter);
 
 s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 03/19] staging: r8188eu: release_firmware is not called if allocation fails
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
  2022-01-07 10:36 ` [PATCH 01/19] staging: r8188eu: remove Firmware* from struct hal_data_8188e Michael Straube
  2022-01-07 10:36 ` [PATCH 02/19] staging: r8188eu: remove rtl8188e_InitializeFirmwareVars() Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 11:15   ` Pavel Skripkin
  2022-01-07 10:36 ` [PATCH 04/19] staging: r8188eu: rename Exit label in load_firmware() Michael Straube
                   ` (15 subsequent siblings)
  18 siblings, 1 reply; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

In function load_firmware() release_firmware() is not called if the
allocation of pFirmware->szFwBuffer fails or if fw->size is greater
than FW_8188E_SIZE.

Move the call to release_firmware() to the exit label at the end of
the function to fix this.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index dc41682fd8d6..cfafbb6c42f7 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -538,10 +538,10 @@ static int load_firmware(struct rt_firmware *pFirmware, struct device *device)
 	}
 	memcpy(pFirmware->szFwBuffer, fw->data, fw->size);
 	pFirmware->ulFwLength = fw->size;
-	release_firmware(fw);
 	dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", pFirmware->ulFwLength);
 
 Exit:
+	release_firmware(fw);
 	return rtStatus;
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 04/19] staging: r8188eu: rename Exit label in load_firmware()
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (2 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 03/19] staging: r8188eu: release_firmware is not called if allocation fails Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 05/19] staging: r8188eu: rename rtStatus " Michael Straube
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename Exit label in load_firmware() to avoid camel case.

Exit -> exit

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index cfafbb6c42f7..b4f29c48d58d 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -518,29 +518,29 @@ static int load_firmware(struct rt_firmware *pFirmware, struct device *device)
 	if (err) {
 		pr_err("Request firmware failed with error 0x%x\n", err);
 		rtStatus = _FAIL;
-		goto Exit;
+		goto exit;
 	}
 	if (!fw) {
 		pr_err("Firmware %s not available\n", fw_name);
 		rtStatus = _FAIL;
-		goto Exit;
+		goto exit;
 	}
 	if (fw->size > FW_8188E_SIZE) {
 		rtStatus = _FAIL;
-		goto Exit;
+		goto exit;
 	}
 
 	pFirmware->szFwBuffer = kzalloc(FW_8188E_SIZE, GFP_KERNEL);
 	if (!pFirmware->szFwBuffer) {
 		pr_err("Failed to allocate pFirmware->szFwBuffer\n");
 		rtStatus = _FAIL;
-		goto Exit;
+		goto exit;
 	}
 	memcpy(pFirmware->szFwBuffer, fw->data, fw->size);
 	pFirmware->ulFwLength = fw->size;
 	dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", pFirmware->ulFwLength);
 
-Exit:
+exit:
 	release_firmware(fw);
 	return rtStatus;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 05/19] staging: r8188eu: rename rtStatus in load_firmware()
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (3 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 04/19] staging: r8188eu: rename Exit label in load_firmware() Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 06/19] staging: r8188eu: convert type of return variable " Michael Straube
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename the local variable rtStatus in load_firmware() to avoid camel
case.

rtStatus -> ret

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index b4f29c48d58d..edb56a9ae283 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -510,30 +510,30 @@ static s32 _FWFreeToGo(struct adapter *padapter)
 
 static int load_firmware(struct rt_firmware *pFirmware, struct device *device)
 {
-	s32	rtStatus = _SUCCESS;
+	s32 ret = _SUCCESS;
 	const struct firmware *fw;
 	const char *fw_name = "rtlwifi/rtl8188eufw.bin";
 	int err = request_firmware(&fw, fw_name, device);
 
 	if (err) {
 		pr_err("Request firmware failed with error 0x%x\n", err);
-		rtStatus = _FAIL;
+		ret = _FAIL;
 		goto exit;
 	}
 	if (!fw) {
 		pr_err("Firmware %s not available\n", fw_name);
-		rtStatus = _FAIL;
+		ret = _FAIL;
 		goto exit;
 	}
 	if (fw->size > FW_8188E_SIZE) {
-		rtStatus = _FAIL;
+		ret = _FAIL;
 		goto exit;
 	}
 
 	pFirmware->szFwBuffer = kzalloc(FW_8188E_SIZE, GFP_KERNEL);
 	if (!pFirmware->szFwBuffer) {
 		pr_err("Failed to allocate pFirmware->szFwBuffer\n");
-		rtStatus = _FAIL;
+		ret = _FAIL;
 		goto exit;
 	}
 	memcpy(pFirmware->szFwBuffer, fw->data, fw->size);
@@ -542,7 +542,7 @@ static int load_firmware(struct rt_firmware *pFirmware, struct device *device)
 
 exit:
 	release_firmware(fw);
-	return rtStatus;
+	return ret;
 }
 
 s32 rtl8188e_FirmwareDownload(struct adapter *padapter)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 06/19] staging: r8188eu: convert type of return variable in load_firmware()
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (4 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 05/19] staging: r8188eu: rename rtStatus " Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 07/19] staging: r8188eu: rename parameter pFirmware of load_firmware() Michael Straube
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

The return type of load_firmware() is int. Change the type of the
return variable from s32 to int to match the function return type.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index edb56a9ae283..bd7f3dc5878b 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -510,7 +510,7 @@ static s32 _FWFreeToGo(struct adapter *padapter)
 
 static int load_firmware(struct rt_firmware *pFirmware, struct device *device)
 {
-	s32 ret = _SUCCESS;
+	int ret = _SUCCESS;
 	const struct firmware *fw;
 	const char *fw_name = "rtlwifi/rtl8188eufw.bin";
 	int err = request_firmware(&fw, fw_name, device);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 07/19] staging: r8188eu: rename parameter pFirmware of load_firmware()
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (5 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 06/19] staging: r8188eu: convert type of return variable " Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 08/19] staging: r8188eu: rename fields of struct rt_firmware Michael Straube
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename the parameter pFirmware of load_firmware() to avoid camel case.

pFirmware -> rtfw

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index bd7f3dc5878b..5c1da9dd179b 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -508,7 +508,7 @@ static s32 _FWFreeToGo(struct adapter *padapter)
 	return _FAIL;
 }
 
-static int load_firmware(struct rt_firmware *pFirmware, struct device *device)
+static int load_firmware(struct rt_firmware *rtfw, struct device *device)
 {
 	int ret = _SUCCESS;
 	const struct firmware *fw;
@@ -530,15 +530,15 @@ static int load_firmware(struct rt_firmware *pFirmware, struct device *device)
 		goto exit;
 	}
 
-	pFirmware->szFwBuffer = kzalloc(FW_8188E_SIZE, GFP_KERNEL);
-	if (!pFirmware->szFwBuffer) {
-		pr_err("Failed to allocate pFirmware->szFwBuffer\n");
+	rtfw->szFwBuffer = kzalloc(FW_8188E_SIZE, GFP_KERNEL);
+	if (!rtfw->szFwBuffer) {
+		pr_err("Failed to allocate rtfw->szFwBuffer\n");
 		ret = _FAIL;
 		goto exit;
 	}
-	memcpy(pFirmware->szFwBuffer, fw->data, fw->size);
-	pFirmware->ulFwLength = fw->size;
-	dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", pFirmware->ulFwLength);
+	memcpy(rtfw->szFwBuffer, fw->data, fw->size);
+	rtfw->ulFwLength = fw->size;
+	dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", rtfw->ulFwLength);
 
 exit:
 	release_firmware(fw);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 08/19] staging: r8188eu: rename fields of struct rt_firmware
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (6 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 07/19] staging: r8188eu: rename parameter pFirmware of load_firmware() Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 09/19] staging: r8188eu: use kmemdup instead of kzalloc and memcpy Michael Straube
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename fields of struct rt_firmware to avoid camel case.

szFwBuffer -> data
ulFwLength -> size

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 .../staging/r8188eu/hal/rtl8188e_hal_init.c   | 22 +++++++++----------
 drivers/staging/r8188eu/include/drv_types.h   |  4 ++--
 drivers/staging/r8188eu/os_dep/os_intfs.c     |  4 ++--
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index 5c1da9dd179b..ee684b37ff91 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -530,15 +530,15 @@ static int load_firmware(struct rt_firmware *rtfw, struct device *device)
 		goto exit;
 	}
 
-	rtfw->szFwBuffer = kzalloc(FW_8188E_SIZE, GFP_KERNEL);
-	if (!rtfw->szFwBuffer) {
-		pr_err("Failed to allocate rtfw->szFwBuffer\n");
+	rtfw->data = kzalloc(FW_8188E_SIZE, GFP_KERNEL);
+	if (!rtfw->data) {
+		pr_err("Failed to allocate rtfw->data\n");
 		ret = _FAIL;
 		goto exit;
 	}
-	memcpy(rtfw->szFwBuffer, fw->data, fw->size);
-	rtfw->ulFwLength = fw->size;
-	dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", rtfw->ulFwLength);
+	memcpy(rtfw->data, fw->data, fw->size);
+	rtfw->size = fw->size;
+	dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", rtfw->size);
 
 exit:
 	release_firmware(fw);
@@ -558,17 +558,17 @@ s32 rtl8188e_FirmwareDownload(struct adapter *padapter)
 	u32 FirmwareLen;
 	static int log_version;
 
-	if (!dvobj->firmware.szFwBuffer)
+	if (!dvobj->firmware.data)
 		rtStatus = load_firmware(&dvobj->firmware, device);
 	if (rtStatus == _FAIL) {
-		dvobj->firmware.szFwBuffer = NULL;
+		dvobj->firmware.data = NULL;
 		goto Exit;
 	}
-	pFirmwareBuf = dvobj->firmware.szFwBuffer;
-	FirmwareLen = dvobj->firmware.ulFwLength;
+	pFirmwareBuf = dvobj->firmware.data;
+	FirmwareLen = dvobj->firmware.size;
 
 	/*  To Check Fw header. Added by tynli. 2009.12.04. */
-	pFwHdr = (struct rt_firmware_hdr *)dvobj->firmware.szFwBuffer;
+	pFwHdr = (struct rt_firmware_hdr *)dvobj->firmware.data;
 
 	fw_version = le16_to_cpu(pFwHdr->Version);
 	fw_subversion = pFwHdr->Subversion;
diff --git a/drivers/staging/r8188eu/include/drv_types.h b/drivers/staging/r8188eu/include/drv_types.h
index 2dd5ebaaa921..388822dd325d 100644
--- a/drivers/staging/r8188eu/include/drv_types.h
+++ b/drivers/staging/r8188eu/include/drv_types.h
@@ -117,8 +117,8 @@ struct registry_priv {
 #define MAX_CONTINUAL_URB_ERR		4
 
 struct rt_firmware {
-	u8			*szFwBuffer;
-	u32			ulFwLength;
+	u8 *data;
+	u32 size;
 };
 
 struct dvobj_priv {
diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c
index b65e44f97826..08d719822062 100644
--- a/drivers/staging/r8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/r8188eu/os_dep/os_intfs.c
@@ -789,8 +789,8 @@ int netdev_close(struct net_device *pnetdev)
 
 	rtw_p2p_enable(padapter, P2P_ROLE_DISABLE);
 
-	kfree(dvobj->firmware.szFwBuffer);
-	dvobj->firmware.szFwBuffer = NULL;
+	kfree(dvobj->firmware.data);
+	dvobj->firmware.data = NULL;
 
 	DBG_88E("-88eu_drv - drv_close, bup =%d\n", padapter->bup);
 	return 0;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 09/19] staging: r8188eu: use kmemdup instead of kzalloc and memcpy
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (7 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 08/19] staging: r8188eu: rename fields of struct rt_firmware Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 10/19] staging: r8188eu: rename fw related functions to avoid camel case Michael Straube
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Use kmemdup instead of kzalloc and memcpy in load_firmware().

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 7 +------
 drivers/staging/r8188eu/include/rtl8188e_hal.h  | 1 -
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index ee684b37ff91..f7ae2fc0d2b9 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -525,18 +525,13 @@ static int load_firmware(struct rt_firmware *rtfw, struct device *device)
 		ret = _FAIL;
 		goto exit;
 	}
-	if (fw->size > FW_8188E_SIZE) {
-		ret = _FAIL;
-		goto exit;
-	}
 
-	rtfw->data = kzalloc(FW_8188E_SIZE, GFP_KERNEL);
+	rtfw->data = kmemdup(fw->data, fw->size, GFP_KERNEL);
 	if (!rtfw->data) {
 		pr_err("Failed to allocate rtfw->data\n");
 		ret = _FAIL;
 		goto exit;
 	}
-	memcpy(rtfw->data, fw->data, fw->size);
 	rtfw->size = fw->size;
 	dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", rtfw->size);
 
diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h
index 3da04751f25d..051f3b9fe726 100644
--- a/drivers/staging/r8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/r8188eu/include/rtl8188e_hal.h
@@ -35,7 +35,6 @@
 #define PageNum_128(_Len)	(u32)(((_Len)>>7) + ((_Len) & 0x7F ? 1 : 0))
 
 /*  download firmware related data structure */
-#define FW_8188E_SIZE			0x4000 /* 16384,16k */
 #define FW_8188E_START_ADDRESS		0x1000
 
 #define MAX_PAGE_SIZE			4096	/*  @ page : 4k bytes */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 10/19] staging: r8188eu: rename fw related functions to avoid camel case
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (8 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 09/19] staging: r8188eu: use kmemdup instead of kzalloc and memcpy Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 11/19] staging: r8188eu: clean up rtw_reset_8051() Michael Straube
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename firmware related functions to avoid camel case.

rtl8188e_FirmwareDownload -> rtl8188e_firmware_download
_FWDownloadEnable -> fw_download_enable
_8051Reset88E -> rtw_reset_8051
_FWFreeToGo -> fw_free_to_go
_BlockWrite -> block_write
_PageWrite -> page_write
_WriteFW -> write_fw

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 .../staging/r8188eu/hal/rtl8188e_hal_init.c   | 34 +++++++++----------
 drivers/staging/r8188eu/hal/usb_halinit.c     |  2 +-
 .../staging/r8188eu/include/rtl8188e_hal.h    |  4 +--
 3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index f7ae2fc0d2b9..b1f2d349c33a 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -21,7 +21,7 @@ static void iol_mode_enable(struct adapter *padapter, u8 enable)
 
 		if (!padapter->bFWReady) {
 			DBG_88E("bFWReady == false call reset 8051...\n");
-			_8051Reset88E(padapter);
+			rtw_reset_8051(padapter);
 		}
 
 	} else {
@@ -336,7 +336,7 @@ int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit
 	return ret;
 }
 
-static void _FWDownloadEnable(struct adapter *padapter, bool enable)
+static void fw_download_enable(struct adapter *padapter, bool enable)
 {
 	u8 tmp;
 
@@ -360,7 +360,7 @@ static void _FWDownloadEnable(struct adapter *padapter, bool enable)
 
 #define MAX_REG_BOLCK_SIZE	196
 
-static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize)
+static int block_write(struct adapter *padapter, void *buffer, u32 buffSize)
 {
 	int ret = _SUCCESS;
 	u32	blockSize_p1 = 4;	/*  (Default) Phase #1 : PCI muse use 4-byte write to download FW */
@@ -416,7 +416,7 @@ static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize)
 	return ret;
 }
 
-static int _PageWrite(struct adapter *padapter, u32 page, void *buffer, u32 size)
+static int page_write(struct adapter *padapter, u32 page, void *buffer, u32 size)
 {
 	u8 value8;
 	u8 u8Page = (u8)(page & 0x07);
@@ -424,10 +424,10 @@ static int _PageWrite(struct adapter *padapter, u32 page, void *buffer, u32 size
 	value8 = (rtw_read8(padapter, REG_MCUFWDL + 2) & 0xF8) | u8Page;
 	rtw_write8(padapter, REG_MCUFWDL + 2, value8);
 
-	return _BlockWrite(padapter, buffer, size);
+	return block_write(padapter, buffer, size);
 }
 
-static int _WriteFW(struct adapter *padapter, void *buffer, u32 size)
+static int write_fw(struct adapter *padapter, void *buffer, u32 size)
 {
 	/*  Since we need dynamic decide method of dwonload fw, so we call this function to get chip version. */
 	/*  We can remove _ReadChipVersion from ReadpadapterInfo8192C later. */
@@ -441,7 +441,7 @@ static int _WriteFW(struct adapter *padapter, void *buffer, u32 size)
 
 	for (page = 0; page < pageNums; page++) {
 		offset = page * MAX_PAGE_SIZE;
-		ret = _PageWrite(padapter, page, bufferPtr + offset, MAX_PAGE_SIZE);
+		ret = page_write(padapter, page, bufferPtr + offset, MAX_PAGE_SIZE);
 
 		if (ret == _FAIL)
 			goto exit;
@@ -449,7 +449,7 @@ static int _WriteFW(struct adapter *padapter, void *buffer, u32 size)
 	if (remainSize) {
 		offset = pageNums * MAX_PAGE_SIZE;
 		page = pageNums;
-		ret = _PageWrite(padapter, page, bufferPtr + offset, remainSize);
+		ret = page_write(padapter, page, bufferPtr + offset, remainSize);
 
 		if (ret == _FAIL)
 			goto exit;
@@ -458,7 +458,7 @@ static int _WriteFW(struct adapter *padapter, void *buffer, u32 size)
 	return ret;
 }
 
-void _8051Reset88E(struct adapter *padapter)
+void rtw_reset_8051(struct adapter *padapter)
 {
 	u8 u1bTmp;
 
@@ -468,7 +468,7 @@ void _8051Reset88E(struct adapter *padapter)
 	DBG_88E("=====> _8051Reset88E(): 8051 reset success .\n");
 }
 
-static s32 _FWFreeToGo(struct adapter *padapter)
+static s32 fw_free_to_go(struct adapter *padapter)
 {
 	u32	counter = 0;
 	u32	value32;
@@ -491,7 +491,7 @@ static s32 _FWFreeToGo(struct adapter *padapter)
 	value32 &= ~WINTINI_RDY;
 	rtw_write32(padapter, REG_MCUFWDL, value32);
 
-	_8051Reset88E(padapter);
+	rtw_reset_8051(padapter);
 
 	/*  polling for FW ready */
 	counter = 0;
@@ -540,7 +540,7 @@ static int load_firmware(struct rt_firmware *rtfw, struct device *device)
 	return ret;
 }
 
-s32 rtl8188e_FirmwareDownload(struct adapter *padapter)
+s32 rtl8188e_firmware_download(struct adapter *padapter)
 {
 	s32	rtStatus = _SUCCESS;
 	u8 writeFW_retry = 0;
@@ -583,16 +583,16 @@ s32 rtl8188e_FirmwareDownload(struct adapter *padapter)
 	/*  or it will cause download Fw fail. 2010.02.01. by tynli. */
 	if (rtw_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) { /* 8051 RAM code */
 		rtw_write8(padapter, REG_MCUFWDL, 0x00);
-		_8051Reset88E(padapter);
+		rtw_reset_8051(padapter);
 	}
 
-	_FWDownloadEnable(padapter, true);
+	fw_download_enable(padapter, true);
 	fwdl_start_time = jiffies;
 	while (1) {
 		/* reset the FWDL chksum */
 		rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_ChkSum_rpt);
 
-		rtStatus = _WriteFW(padapter, pFirmwareBuf, FirmwareLen);
+		rtStatus = write_fw(padapter, pFirmwareBuf, FirmwareLen);
 
 		if (rtStatus == _SUCCESS ||
 		    (rtw_get_passing_time_ms(fwdl_start_time) > 500 && writeFW_retry++ >= 3))
@@ -602,13 +602,13 @@ s32 rtl8188e_FirmwareDownload(struct adapter *padapter)
 			__func__, writeFW_retry, rtw_get_passing_time_ms(fwdl_start_time)
 		);
 	}
-	_FWDownloadEnable(padapter, false);
+	fw_download_enable(padapter, false);
 	if (_SUCCESS != rtStatus) {
 		DBG_88E("DL Firmware failed!\n");
 		goto Exit;
 	}
 
-	rtStatus = _FWFreeToGo(padapter);
+	rtStatus = fw_free_to_go(padapter);
 	if (_SUCCESS != rtStatus) {
 		DBG_88E("DL Firmware failed!\n");
 		goto Exit;
diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 696beb29536f..3dc1c432e8cf 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -625,7 +625,7 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter)
 
 	_InitTxBufferBoundary(Adapter, 0);
 
-	status = rtl8188e_FirmwareDownload(Adapter);
+	status = rtl8188e_firmware_download(Adapter);
 
 	if (status != _SUCCESS) {
 		DBG_88E("%s: Download Firmware failed!!\n", __func__);
diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h
index 051f3b9fe726..11d79606e120 100644
--- a/drivers/staging/r8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/r8188eu/include/rtl8188e_hal.h
@@ -250,8 +250,8 @@ struct hal_data_8188e {
 };
 
 /*  rtl8188e_hal_init.c */
-s32 rtl8188e_FirmwareDownload(struct adapter *padapter);
-void _8051Reset88E(struct adapter *padapter);
+s32 rtl8188e_firmware_download(struct adapter *padapter);
+void rtw_reset_8051(struct adapter *padapter);
 
 s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy);
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 11/19] staging: r8188eu: clean up rtw_reset_8051()
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (9 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 10/19] staging: r8188eu: rename fw related functions to avoid camel case Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 12/19] staging: r8188eu: convert two functions from s32 to int Michael Straube
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename the local variable u1bTmp in rtw_reset_8051() to avoid camel
case and remove a call to DBG_88E that contains no important
information.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index b1f2d349c33a..d219882fc4a2 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -460,12 +460,11 @@ static int write_fw(struct adapter *padapter, void *buffer, u32 size)
 
 void rtw_reset_8051(struct adapter *padapter)
 {
-	u8 u1bTmp;
+	u8 val8;
 
-	u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN + 1);
-	rtw_write8(padapter, REG_SYS_FUNC_EN + 1, u1bTmp & (~BIT(2)));
-	rtw_write8(padapter, REG_SYS_FUNC_EN + 1, u1bTmp | (BIT(2)));
-	DBG_88E("=====> _8051Reset88E(): 8051 reset success .\n");
+	val8 = rtw_read8(padapter, REG_SYS_FUNC_EN + 1);
+	rtw_write8(padapter, REG_SYS_FUNC_EN + 1, val8 & (~BIT(2)));
+	rtw_write8(padapter, REG_SYS_FUNC_EN + 1, val8 | (BIT(2)));
 }
 
 static s32 fw_free_to_go(struct adapter *padapter)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 12/19] staging: r8188eu: convert two functions from s32 to int
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (10 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 11/19] staging: r8188eu: clean up rtw_reset_8051() Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 13/19] staging: r8188eu: rename Exit label in rtl8188e_firmware_download() Michael Straube
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Convert the return type of fw_free_to_go() and
rtl8188e_firmware_download() from s32 to the more common int.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 6 +++---
 drivers/staging/r8188eu/include/rtl8188e_hal.h  | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index d219882fc4a2..f86b5cb2b6f9 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -467,7 +467,7 @@ void rtw_reset_8051(struct adapter *padapter)
 	rtw_write8(padapter, REG_SYS_FUNC_EN + 1, val8 | (BIT(2)));
 }
 
-static s32 fw_free_to_go(struct adapter *padapter)
+static int fw_free_to_go(struct adapter *padapter)
 {
 	u32	counter = 0;
 	u32	value32;
@@ -539,9 +539,9 @@ static int load_firmware(struct rt_firmware *rtfw, struct device *device)
 	return ret;
 }
 
-s32 rtl8188e_firmware_download(struct adapter *padapter)
+int rtl8188e_firmware_download(struct adapter *padapter)
 {
-	s32	rtStatus = _SUCCESS;
+	int rtStatus = _SUCCESS;
 	u8 writeFW_retry = 0;
 	u32 fwdl_start_time;
 	struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h
index 11d79606e120..4b67e11024a1 100644
--- a/drivers/staging/r8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/r8188eu/include/rtl8188e_hal.h
@@ -250,7 +250,7 @@ struct hal_data_8188e {
 };
 
 /*  rtl8188e_hal_init.c */
-s32 rtl8188e_firmware_download(struct adapter *padapter);
+int rtl8188e_firmware_download(struct adapter *padapter);
 void rtw_reset_8051(struct adapter *padapter);
 
 s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 13/19] staging: r8188eu: rename Exit label in rtl8188e_firmware_download()
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (11 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 12/19] staging: r8188eu: convert two functions from s32 to int Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 14/19] staging: r8188eu: rename rtSatus " Michael Straube
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename the Exit label in rtl8188e_firmware_download() to avoid camel
case.

Exit -> exit

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index f86b5cb2b6f9..f158bbf44094 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -556,7 +556,7 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 		rtStatus = load_firmware(&dvobj->firmware, device);
 	if (rtStatus == _FAIL) {
 		dvobj->firmware.data = NULL;
-		goto Exit;
+		goto exit;
 	}
 	pFirmwareBuf = dvobj->firmware.data;
 	FirmwareLen = dvobj->firmware.size;
@@ -604,16 +604,16 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 	fw_download_enable(padapter, false);
 	if (_SUCCESS != rtStatus) {
 		DBG_88E("DL Firmware failed!\n");
-		goto Exit;
+		goto exit;
 	}
 
 	rtStatus = fw_free_to_go(padapter);
 	if (_SUCCESS != rtStatus) {
 		DBG_88E("DL Firmware failed!\n");
-		goto Exit;
+		goto exit;
 	}
 
-Exit:
+exit:
 	return rtStatus;
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 14/19] staging: r8188eu: rename rtSatus in rtl8188e_firmware_download()
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (12 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 13/19] staging: r8188eu: rename Exit label in rtl8188e_firmware_download() Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 15/19] staging: r8188eu: rename FWDL_ChkSum_rpt Michael Straube
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename the variable rtStatus in rtl8188e_firmware_download() to avoid
camel case.

rtStatus -> ret

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 .../staging/r8188eu/hal/rtl8188e_hal_init.c    | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index f158bbf44094..1685386a7015 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -541,7 +541,7 @@ static int load_firmware(struct rt_firmware *rtfw, struct device *device)
 
 int rtl8188e_firmware_download(struct adapter *padapter)
 {
-	int rtStatus = _SUCCESS;
+	int ret = _SUCCESS;
 	u8 writeFW_retry = 0;
 	u32 fwdl_start_time;
 	struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
@@ -553,8 +553,8 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 	static int log_version;
 
 	if (!dvobj->firmware.data)
-		rtStatus = load_firmware(&dvobj->firmware, device);
-	if (rtStatus == _FAIL) {
+		ret = load_firmware(&dvobj->firmware, device);
+	if (ret == _FAIL) {
 		dvobj->firmware.data = NULL;
 		goto exit;
 	}
@@ -591,9 +591,9 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 		/* reset the FWDL chksum */
 		rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_ChkSum_rpt);
 
-		rtStatus = write_fw(padapter, pFirmwareBuf, FirmwareLen);
+		ret = write_fw(padapter, pFirmwareBuf, FirmwareLen);
 
-		if (rtStatus == _SUCCESS ||
+		if (ret == _SUCCESS ||
 		    (rtw_get_passing_time_ms(fwdl_start_time) > 500 && writeFW_retry++ >= 3))
 			break;
 
@@ -602,19 +602,19 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 		);
 	}
 	fw_download_enable(padapter, false);
-	if (_SUCCESS != rtStatus) {
+	if (ret != _SUCCESS) {
 		DBG_88E("DL Firmware failed!\n");
 		goto exit;
 	}
 
-	rtStatus = fw_free_to_go(padapter);
-	if (_SUCCESS != rtStatus) {
+	ret = fw_free_to_go(padapter);
+	if (ret != _SUCCESS) {
 		DBG_88E("DL Firmware failed!\n");
 		goto exit;
 	}
 
 exit:
-	return rtStatus;
+	return ret;
 }
 
 /*  */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 15/19] staging: r8188eu: rename FWDL_ChkSum_rpt
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (13 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 14/19] staging: r8188eu: rename rtSatus " Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 16/19] staging: r8188eu: rename writeFW_retry Michael Straube
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename FWDL_ChkSum_rpt to avoid camel case.

FWDL_ChkSum_rpt -> FWDL_CHKSUM_RPT

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 4 ++--
 drivers/staging/r8188eu/include/rtl8188e_spec.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index 1685386a7015..6c23966ec785 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -475,7 +475,7 @@ static int fw_free_to_go(struct adapter *padapter)
 	/*  polling CheckSum report */
 	do {
 		value32 = rtw_read32(padapter, REG_MCUFWDL);
-		if (value32 & FWDL_ChkSum_rpt)
+		if (value32 & FWDL_CHKSUM_RPT)
 			break;
 	} while (counter++ < POLLING_READY_TIMEOUT_COUNT);
 
@@ -589,7 +589,7 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 	fwdl_start_time = jiffies;
 	while (1) {
 		/* reset the FWDL chksum */
-		rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_ChkSum_rpt);
+		rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_CHKSUM_RPT);
 
 		ret = write_fw(padapter, pFirmwareBuf, FirmwareLen);
 
diff --git a/drivers/staging/r8188eu/include/rtl8188e_spec.h b/drivers/staging/r8188eu/include/rtl8188e_spec.h
index 009222b4a95d..edae053e350e 100644
--- a/drivers/staging/r8188eu/include/rtl8188e_spec.h
+++ b/drivers/staging/r8188eu/include/rtl8188e_spec.h
@@ -794,7 +794,7 @@ Current IOREG MAP
 /* 2 MCUFWDL */
 #define MCUFWDL_EN			BIT(0)
 #define MCUFWDL_RDY			BIT(1)
-#define FWDL_ChkSum_rpt			BIT(2)
+#define FWDL_CHKSUM_RPT			BIT(2)
 #define MACINI_RDY			BIT(3)
 #define BBINI_RDY			BIT(4)
 #define RFINI_RDY			BIT(5)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 16/19] staging: r8188eu: rename writeFW_retry
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (14 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 15/19] staging: r8188eu: rename FWDL_ChkSum_rpt Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 17/19] staging: r8188eu: rename pFwHdr in rtl8188e_firmware_download() Michael Straube
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename the variable writeFW_retry in rtl8188e_firmware_download()
to avoid camel case.

writeFW_retry -> write_fw_retry

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index 6c23966ec785..15e8dc0b9a37 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -542,7 +542,7 @@ static int load_firmware(struct rt_firmware *rtfw, struct device *device)
 int rtl8188e_firmware_download(struct adapter *padapter)
 {
 	int ret = _SUCCESS;
-	u8 writeFW_retry = 0;
+	u8 write_fw_retry = 0;
 	u32 fwdl_start_time;
 	struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
 	struct device *device = dvobj_to_dev(dvobj);
@@ -594,11 +594,11 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 		ret = write_fw(padapter, pFirmwareBuf, FirmwareLen);
 
 		if (ret == _SUCCESS ||
-		    (rtw_get_passing_time_ms(fwdl_start_time) > 500 && writeFW_retry++ >= 3))
+		    (rtw_get_passing_time_ms(fwdl_start_time) > 500 && write_fw_retry++ >= 3))
 			break;
 
-		DBG_88E("%s writeFW_retry:%u, time after fwdl_start_time:%ums\n",
-			__func__, writeFW_retry, rtw_get_passing_time_ms(fwdl_start_time)
+		DBG_88E("%s write_fw_retry:%u, time after fwdl_start_time:%ums\n",
+			__func__, write_fw_retry, rtw_get_passing_time_ms(fwdl_start_time)
 		);
 	}
 	fw_download_enable(padapter, false);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 17/19] staging: r8188eu: rename pFwHdr in rtl8188e_firmware_download()
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (15 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 16/19] staging: r8188eu: rename writeFW_retry Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 18/19] staging: r8188eu: rename pFirmwareBuf and FirmwareLen Michael Straube
  2022-01-07 10:36 ` [PATCH 19/19] staging: r8188eu: move firmware loading code out of the hal layer Michael Straube
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename the variable pFwHdr in rtl8188e_firmware_download() to avoid
camel case.

pFwHdr -> fwhdr

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index 15e8dc0b9a37..c2112df0ac82 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -546,7 +546,7 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 	u32 fwdl_start_time;
 	struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
 	struct device *device = dvobj_to_dev(dvobj);
-	struct rt_firmware_hdr *pFwHdr = NULL;
+	struct rt_firmware_hdr *fwhdr = NULL;
 	u16 fw_version, fw_subversion, fw_signature;
 	u8 *pFirmwareBuf;
 	u32 FirmwareLen;
@@ -562,17 +562,17 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 	FirmwareLen = dvobj->firmware.size;
 
 	/*  To Check Fw header. Added by tynli. 2009.12.04. */
-	pFwHdr = (struct rt_firmware_hdr *)dvobj->firmware.data;
+	fwhdr = (struct rt_firmware_hdr *)dvobj->firmware.data;
 
-	fw_version = le16_to_cpu(pFwHdr->Version);
-	fw_subversion = pFwHdr->Subversion;
-	fw_signature = le16_to_cpu(pFwHdr->Signature);
+	fw_version = le16_to_cpu(fwhdr->Version);
+	fw_subversion = fwhdr->Subversion;
+	fw_signature = le16_to_cpu(fwhdr->Signature);
 
 	if (!log_version++)
 		pr_info("%sFirmware Version %d, SubVersion %d, Signature 0x%x\n",
 			DRIVER_PREFIX, fw_version, fw_subversion, fw_signature);
 
-	if (IS_FW_HEADER_EXIST(pFwHdr)) {
+	if (IS_FW_HEADER_EXIST(fwhdr)) {
 		/*  Shift 32 bytes for FW header */
 		pFirmwareBuf = pFirmwareBuf + 32;
 		FirmwareLen = FirmwareLen - 32;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 18/19] staging: r8188eu: rename pFirmwareBuf and FirmwareLen
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (16 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 17/19] staging: r8188eu: rename pFwHdr in rtl8188e_firmware_download() Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  2022-01-07 10:36 ` [PATCH 19/19] staging: r8188eu: move firmware loading code out of the hal layer Michael Straube
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename the variables pFirmwareBuf and FirmwareLen in
rtl8188e_firmware_download() to avoid camel case.

pFirmwareBuf -> fw_data
FirmwareLen -> fw_size

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index c2112df0ac82..3c9ddbe16754 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -548,8 +548,8 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 	struct device *device = dvobj_to_dev(dvobj);
 	struct rt_firmware_hdr *fwhdr = NULL;
 	u16 fw_version, fw_subversion, fw_signature;
-	u8 *pFirmwareBuf;
-	u32 FirmwareLen;
+	u8 *fw_data;
+	u32 fw_size;
 	static int log_version;
 
 	if (!dvobj->firmware.data)
@@ -558,8 +558,8 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 		dvobj->firmware.data = NULL;
 		goto exit;
 	}
-	pFirmwareBuf = dvobj->firmware.data;
-	FirmwareLen = dvobj->firmware.size;
+	fw_data = dvobj->firmware.data;
+	fw_size = dvobj->firmware.size;
 
 	/*  To Check Fw header. Added by tynli. 2009.12.04. */
 	fwhdr = (struct rt_firmware_hdr *)dvobj->firmware.data;
@@ -574,8 +574,8 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 
 	if (IS_FW_HEADER_EXIST(fwhdr)) {
 		/*  Shift 32 bytes for FW header */
-		pFirmwareBuf = pFirmwareBuf + 32;
-		FirmwareLen = FirmwareLen - 32;
+		fw_data = fw_data + 32;
+		fw_size = fw_size - 32;
 	}
 
 	/*  Suggested by Filen. If 8051 is running in RAM code, driver should inform Fw to reset by itself, */
@@ -591,7 +591,7 @@ int rtl8188e_firmware_download(struct adapter *padapter)
 		/* reset the FWDL chksum */
 		rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_CHKSUM_RPT);
 
-		ret = write_fw(padapter, pFirmwareBuf, FirmwareLen);
+		ret = write_fw(padapter, fw_data, fw_size);
 
 		if (ret == _SUCCESS ||
 		    (rtw_get_passing_time_ms(fwdl_start_time) > 500 && write_fw_retry++ >= 3))
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* [PATCH 19/19] staging: r8188eu: move firmware loading code out of the hal layer
  2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
                   ` (17 preceding siblings ...)
  2022-01-07 10:36 ` [PATCH 18/19] staging: r8188eu: rename pFirmwareBuf and FirmwareLen Michael Straube
@ 2022-01-07 10:36 ` Michael Straube
  18 siblings, 0 replies; 23+ messages in thread
From: Michael Straube @ 2022-01-07 10:36 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Move the firmware loading functions from rtl8188e_hal_init.c into the
new file core/rtw_fw.c.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
 drivers/staging/r8188eu/Makefile              |   1 +
 drivers/staging/r8188eu/core/rtw_fw.c         | 284 ++++++++++++++++++
 .../staging/r8188eu/hal/rtl8188e_hal_init.c   | 283 +----------------
 drivers/staging/r8188eu/hal/usb_halinit.c     |   2 +-
 .../staging/r8188eu/include/rtl8188e_hal.h    |   4 -
 drivers/staging/r8188eu/include/rtw_fw.h      |  14 +
 6 files changed, 301 insertions(+), 287 deletions(-)
 create mode 100644 drivers/staging/r8188eu/core/rtw_fw.c
 create mode 100644 drivers/staging/r8188eu/include/rtw_fw.h

diff --git a/drivers/staging/r8188eu/Makefile b/drivers/staging/r8188eu/Makefile
index a7a486cc16dd..84627fc89ec9 100644
--- a/drivers/staging/r8188eu/Makefile
+++ b/drivers/staging/r8188eu/Makefile
@@ -37,6 +37,7 @@ r8188eu-y = \
 		core/rtw_br_ext.o \
 		core/rtw_cmd.o \
 		core/rtw_efuse.o \
+		core/rtw_fw.o \
 		core/rtw_ieee80211.o \
 		core/rtw_ioctl_set.o \
 		core/rtw_iol.o \
diff --git a/drivers/staging/r8188eu/core/rtw_fw.c b/drivers/staging/r8188eu/core/rtw_fw.c
new file mode 100644
index 000000000000..fa29d47bf165
--- /dev/null
+++ b/drivers/staging/r8188eu/core/rtw_fw.c
@@ -0,0 +1,284 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright(c) 2007 - 2011 Realtek Corporation. */
+
+#include <linux/firmware.h>
+#include "../include/rtw_fw.h"
+
+static void fw_download_enable(struct adapter *padapter, bool enable)
+{
+	u8 tmp;
+
+	if (enable) {
+		/*  MCU firmware download enable. */
+		tmp = rtw_read8(padapter, REG_MCUFWDL);
+		rtw_write8(padapter, REG_MCUFWDL, tmp | 0x01);
+
+		/*  8051 reset */
+		tmp = rtw_read8(padapter, REG_MCUFWDL + 2);
+		rtw_write8(padapter, REG_MCUFWDL + 2, tmp & 0xf7);
+	} else {
+		/*  MCU firmware download disable. */
+		tmp = rtw_read8(padapter, REG_MCUFWDL);
+		rtw_write8(padapter, REG_MCUFWDL, tmp & 0xfe);
+
+		/*  Reserved for fw extension. */
+		rtw_write8(padapter, REG_MCUFWDL + 1, 0x00);
+	}
+}
+
+static int block_write(struct adapter *padapter, void *buffer, u32 buffSize)
+{
+	int ret = _SUCCESS;
+	u32	blockSize_p1 = 4;	/*  (Default) Phase #1 : PCI muse use 4-byte write to download FW */
+	u32	blockSize_p2 = 8;	/*  Phase #2 : Use 8-byte, if Phase#1 use big size to write FW. */
+	u32	blockSize_p3 = 1;	/*  Phase #3 : Use 1-byte, the remnant of FW image. */
+	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 = MAX_REG_BOLCK_SIZE;
+
+	/* 3 Phase #1 */
+	blockCount_p1 = buffSize / blockSize_p1;
+	remainSize_p1 = buffSize % blockSize_p1;
+
+	for (i = 0; i < blockCount_p1; i++) {
+		ret = rtw_writeN(padapter, (FW_8188E_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;
+
+		for (i = 0; i < blockCount_p2; i++) {
+			ret = rtw_writeN(padapter, (FW_8188E_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;
+
+		for (i = 0; i < blockCount_p3; i++) {
+			ret = rtw_write8(padapter, (FW_8188E_START_ADDRESS + offset + i), *(bufferPtr + offset + i));
+
+			if (ret == _FAIL)
+				goto exit;
+		}
+	}
+
+exit:
+	return ret;
+}
+
+static int page_write(struct adapter *padapter, u32 page, void *buffer, u32 size)
+{
+	u8 value8;
+	u8 u8Page = (u8)(page & 0x07);
+
+	value8 = (rtw_read8(padapter, REG_MCUFWDL + 2) & 0xF8) | u8Page;
+	rtw_write8(padapter, REG_MCUFWDL + 2, value8);
+
+	return block_write(padapter, buffer, size);
+}
+
+static int write_fw(struct adapter *padapter, void *buffer, u32 size)
+{
+	/*  Since we need dynamic decide method of dwonload fw, so we call this function to get chip version. */
+	/*  We can remove _ReadChipVersion from ReadpadapterInfo8192C later. */
+	int ret = _SUCCESS;
+	u32	pageNums, remainSize;
+	u32	page, offset;
+	u8 *bufferPtr = (u8 *)buffer;
+
+	pageNums = size / MAX_PAGE_SIZE;
+	remainSize = size % MAX_PAGE_SIZE;
+
+	for (page = 0; page < pageNums; page++) {
+		offset = page * MAX_PAGE_SIZE;
+		ret = page_write(padapter, page, bufferPtr + offset, MAX_PAGE_SIZE);
+
+		if (ret == _FAIL)
+			goto exit;
+	}
+	if (remainSize) {
+		offset = pageNums * MAX_PAGE_SIZE;
+		page = pageNums;
+		ret = page_write(padapter, page, bufferPtr + offset, remainSize);
+
+		if (ret == _FAIL)
+			goto exit;
+	}
+exit:
+	return ret;
+}
+
+void rtw_reset_8051(struct adapter *padapter)
+{
+	u8 val8;
+
+	val8 = rtw_read8(padapter, REG_SYS_FUNC_EN + 1);
+	rtw_write8(padapter, REG_SYS_FUNC_EN + 1, val8 & (~BIT(2)));
+	rtw_write8(padapter, REG_SYS_FUNC_EN + 1, val8 | (BIT(2)));
+}
+
+static int fw_free_to_go(struct adapter *padapter)
+{
+	u32	counter = 0;
+	u32	value32;
+
+	/*  polling CheckSum report */
+	do {
+		value32 = rtw_read32(padapter, REG_MCUFWDL);
+		if (value32 & FWDL_CHKSUM_RPT)
+			break;
+	} while (counter++ < POLLING_READY_TIMEOUT_COUNT);
+
+	if (counter >= POLLING_READY_TIMEOUT_COUNT) {
+		DBG_88E("%s: chksum report fail! REG_MCUFWDL:0x%08x\n", __func__, value32);
+		return _FAIL;
+	}
+	DBG_88E("%s: Checksum report OK! REG_MCUFWDL:0x%08x\n", __func__, value32);
+
+	value32 = rtw_read32(padapter, REG_MCUFWDL);
+	value32 |= MCUFWDL_RDY;
+	value32 &= ~WINTINI_RDY;
+	rtw_write32(padapter, REG_MCUFWDL, value32);
+
+	rtw_reset_8051(padapter);
+
+	/*  polling for FW ready */
+	counter = 0;
+	do {
+		value32 = rtw_read32(padapter, REG_MCUFWDL);
+		if (value32 & WINTINI_RDY) {
+			DBG_88E("%s: Polling FW ready success!! REG_MCUFWDL:0x%08x\n", __func__, value32);
+			return _SUCCESS;
+		}
+		udelay(5);
+	} while (counter++ < POLLING_READY_TIMEOUT_COUNT);
+
+	DBG_88E("%s: Polling FW ready fail!! REG_MCUFWDL:0x%08x\n", __func__, value32);
+	return _FAIL;
+}
+
+static int load_firmware(struct rt_firmware *rtfw, struct device *device)
+{
+	int ret = _SUCCESS;
+	const struct firmware *fw;
+	const char *fw_name = "rtlwifi/rtl8188eufw.bin";
+	int err = request_firmware(&fw, fw_name, device);
+
+	if (err) {
+		pr_err("Request firmware failed with error 0x%x\n", err);
+		ret = _FAIL;
+		goto exit;
+	}
+	if (!fw) {
+		pr_err("Firmware %s not available\n", fw_name);
+		ret = _FAIL;
+		goto exit;
+	}
+
+	rtfw->data = kmemdup(fw->data, fw->size, GFP_KERNEL);
+	if (!rtfw->data) {
+		pr_err("Failed to allocate rtfw->data\n");
+		ret = _FAIL;
+		goto exit;
+	}
+	rtfw->size = fw->size;
+	dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", rtfw->size);
+
+exit:
+	release_firmware(fw);
+	return ret;
+}
+
+int rtl8188e_firmware_download(struct adapter *padapter)
+{
+	int ret = _SUCCESS;
+	u8 write_fw_retry = 0;
+	u32 fwdl_start_time;
+	struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
+	struct device *device = dvobj_to_dev(dvobj);
+	struct rt_firmware_hdr *fwhdr = NULL;
+	u16 fw_version, fw_subversion, fw_signature;
+	u8 *fw_data;
+	u32 fw_size;
+	static int log_version;
+
+	if (!dvobj->firmware.data)
+		ret = load_firmware(&dvobj->firmware, device);
+	if (ret == _FAIL) {
+		dvobj->firmware.data = NULL;
+		goto exit;
+	}
+	fw_data = dvobj->firmware.data;
+	fw_size = dvobj->firmware.size;
+
+	/*  To Check Fw header. Added by tynli. 2009.12.04. */
+	fwhdr = (struct rt_firmware_hdr *)dvobj->firmware.data;
+
+	fw_version = le16_to_cpu(fwhdr->Version);
+	fw_subversion = fwhdr->Subversion;
+	fw_signature = le16_to_cpu(fwhdr->Signature);
+
+	if (!log_version++)
+		pr_info("%sFirmware Version %d, SubVersion %d, Signature 0x%x\n",
+			DRIVER_PREFIX, fw_version, fw_subversion, fw_signature);
+
+	if (IS_FW_HEADER_EXIST(fwhdr)) {
+		/*  Shift 32 bytes for FW header */
+		fw_data = fw_data + 32;
+		fw_size = fw_size - 32;
+	}
+
+	/*  Suggested by Filen. If 8051 is running in RAM code, driver should inform Fw to reset by itself, */
+	/*  or it will cause download Fw fail. 2010.02.01. by tynli. */
+	if (rtw_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) { /* 8051 RAM code */
+		rtw_write8(padapter, REG_MCUFWDL, 0x00);
+		rtw_reset_8051(padapter);
+	}
+
+	fw_download_enable(padapter, true);
+	fwdl_start_time = jiffies;
+	while (1) {
+		/* reset the FWDL chksum */
+		rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_CHKSUM_RPT);
+
+		ret = write_fw(padapter, fw_data, fw_size);
+
+		if (ret == _SUCCESS ||
+		    (rtw_get_passing_time_ms(fwdl_start_time) > 500 && write_fw_retry++ >= 3))
+			break;
+
+		DBG_88E("%s write_fw_retry:%u, time after fwdl_start_time:%ums\n",
+			__func__, write_fw_retry, rtw_get_passing_time_ms(fwdl_start_time)
+		);
+	}
+	fw_download_enable(padapter, false);
+	if (ret != _SUCCESS) {
+		DBG_88E("DL Firmware failed!\n");
+		goto exit;
+	}
+
+	ret = fw_free_to_go(padapter);
+	if (ret != _SUCCESS) {
+		DBG_88E("DL Firmware failed!\n");
+		goto exit;
+	}
+
+exit:
+	return ret;
+}
diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
index 3c9ddbe16754..dd89973928cf 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
@@ -3,12 +3,12 @@
 
 #define _HAL_INIT_C_
 
-#include "../include/linux/firmware.h"
 #include "../include/drv_types.h"
 #include "../include/rtw_efuse.h"
 #include "../include/rtl8188e_hal.h"
 #include "../include/rtw_iol.h"
 #include "../include/usb_ops.h"
+#include "../include/rtw_fw.h"
 
 static void iol_mode_enable(struct adapter *padapter, u8 enable)
 {
@@ -336,287 +336,6 @@ int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit
 	return ret;
 }
 
-static void fw_download_enable(struct adapter *padapter, bool enable)
-{
-	u8 tmp;
-
-	if (enable) {
-		/*  MCU firmware download enable. */
-		tmp = rtw_read8(padapter, REG_MCUFWDL);
-		rtw_write8(padapter, REG_MCUFWDL, tmp | 0x01);
-
-		/*  8051 reset */
-		tmp = rtw_read8(padapter, REG_MCUFWDL + 2);
-		rtw_write8(padapter, REG_MCUFWDL + 2, tmp & 0xf7);
-	} else {
-		/*  MCU firmware download disable. */
-		tmp = rtw_read8(padapter, REG_MCUFWDL);
-		rtw_write8(padapter, REG_MCUFWDL, tmp & 0xfe);
-
-		/*  Reserved for fw extension. */
-		rtw_write8(padapter, REG_MCUFWDL + 1, 0x00);
-	}
-}
-
-#define MAX_REG_BOLCK_SIZE	196
-
-static int block_write(struct adapter *padapter, void *buffer, u32 buffSize)
-{
-	int ret = _SUCCESS;
-	u32	blockSize_p1 = 4;	/*  (Default) Phase #1 : PCI muse use 4-byte write to download FW */
-	u32	blockSize_p2 = 8;	/*  Phase #2 : Use 8-byte, if Phase#1 use big size to write FW. */
-	u32	blockSize_p3 = 1;	/*  Phase #3 : Use 1-byte, the remnant of FW image. */
-	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 = MAX_REG_BOLCK_SIZE;
-
-	/* 3 Phase #1 */
-	blockCount_p1 = buffSize / blockSize_p1;
-	remainSize_p1 = buffSize % blockSize_p1;
-
-	for (i = 0; i < blockCount_p1; i++) {
-		ret = rtw_writeN(padapter, (FW_8188E_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;
-
-		for (i = 0; i < blockCount_p2; i++) {
-			ret = rtw_writeN(padapter, (FW_8188E_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;
-
-		for (i = 0; i < blockCount_p3; i++) {
-			ret = rtw_write8(padapter, (FW_8188E_START_ADDRESS + offset + i), *(bufferPtr + offset + i));
-
-			if (ret == _FAIL)
-				goto exit;
-		}
-	}
-
-exit:
-	return ret;
-}
-
-static int page_write(struct adapter *padapter, u32 page, void *buffer, u32 size)
-{
-	u8 value8;
-	u8 u8Page = (u8)(page & 0x07);
-
-	value8 = (rtw_read8(padapter, REG_MCUFWDL + 2) & 0xF8) | u8Page;
-	rtw_write8(padapter, REG_MCUFWDL + 2, value8);
-
-	return block_write(padapter, buffer, size);
-}
-
-static int write_fw(struct adapter *padapter, void *buffer, u32 size)
-{
-	/*  Since we need dynamic decide method of dwonload fw, so we call this function to get chip version. */
-	/*  We can remove _ReadChipVersion from ReadpadapterInfo8192C later. */
-	int ret = _SUCCESS;
-	u32	pageNums, remainSize;
-	u32	page, offset;
-	u8 *bufferPtr = (u8 *)buffer;
-
-	pageNums = size / MAX_PAGE_SIZE;
-	remainSize = size % MAX_PAGE_SIZE;
-
-	for (page = 0; page < pageNums; page++) {
-		offset = page * MAX_PAGE_SIZE;
-		ret = page_write(padapter, page, bufferPtr + offset, MAX_PAGE_SIZE);
-
-		if (ret == _FAIL)
-			goto exit;
-	}
-	if (remainSize) {
-		offset = pageNums * MAX_PAGE_SIZE;
-		page = pageNums;
-		ret = page_write(padapter, page, bufferPtr + offset, remainSize);
-
-		if (ret == _FAIL)
-			goto exit;
-	}
-exit:
-	return ret;
-}
-
-void rtw_reset_8051(struct adapter *padapter)
-{
-	u8 val8;
-
-	val8 = rtw_read8(padapter, REG_SYS_FUNC_EN + 1);
-	rtw_write8(padapter, REG_SYS_FUNC_EN + 1, val8 & (~BIT(2)));
-	rtw_write8(padapter, REG_SYS_FUNC_EN + 1, val8 | (BIT(2)));
-}
-
-static int fw_free_to_go(struct adapter *padapter)
-{
-	u32	counter = 0;
-	u32	value32;
-
-	/*  polling CheckSum report */
-	do {
-		value32 = rtw_read32(padapter, REG_MCUFWDL);
-		if (value32 & FWDL_CHKSUM_RPT)
-			break;
-	} while (counter++ < POLLING_READY_TIMEOUT_COUNT);
-
-	if (counter >= POLLING_READY_TIMEOUT_COUNT) {
-		DBG_88E("%s: chksum report fail! REG_MCUFWDL:0x%08x\n", __func__, value32);
-		return _FAIL;
-	}
-	DBG_88E("%s: Checksum report OK! REG_MCUFWDL:0x%08x\n", __func__, value32);
-
-	value32 = rtw_read32(padapter, REG_MCUFWDL);
-	value32 |= MCUFWDL_RDY;
-	value32 &= ~WINTINI_RDY;
-	rtw_write32(padapter, REG_MCUFWDL, value32);
-
-	rtw_reset_8051(padapter);
-
-	/*  polling for FW ready */
-	counter = 0;
-	do {
-		value32 = rtw_read32(padapter, REG_MCUFWDL);
-		if (value32 & WINTINI_RDY) {
-			DBG_88E("%s: Polling FW ready success!! REG_MCUFWDL:0x%08x\n", __func__, value32);
-			return _SUCCESS;
-		}
-		udelay(5);
-	} while (counter++ < POLLING_READY_TIMEOUT_COUNT);
-
-	DBG_88E("%s: Polling FW ready fail!! REG_MCUFWDL:0x%08x\n", __func__, value32);
-	return _FAIL;
-}
-
-static int load_firmware(struct rt_firmware *rtfw, struct device *device)
-{
-	int ret = _SUCCESS;
-	const struct firmware *fw;
-	const char *fw_name = "rtlwifi/rtl8188eufw.bin";
-	int err = request_firmware(&fw, fw_name, device);
-
-	if (err) {
-		pr_err("Request firmware failed with error 0x%x\n", err);
-		ret = _FAIL;
-		goto exit;
-	}
-	if (!fw) {
-		pr_err("Firmware %s not available\n", fw_name);
-		ret = _FAIL;
-		goto exit;
-	}
-
-	rtfw->data = kmemdup(fw->data, fw->size, GFP_KERNEL);
-	if (!rtfw->data) {
-		pr_err("Failed to allocate rtfw->data\n");
-		ret = _FAIL;
-		goto exit;
-	}
-	rtfw->size = fw->size;
-	dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", rtfw->size);
-
-exit:
-	release_firmware(fw);
-	return ret;
-}
-
-int rtl8188e_firmware_download(struct adapter *padapter)
-{
-	int ret = _SUCCESS;
-	u8 write_fw_retry = 0;
-	u32 fwdl_start_time;
-	struct dvobj_priv *dvobj = adapter_to_dvobj(padapter);
-	struct device *device = dvobj_to_dev(dvobj);
-	struct rt_firmware_hdr *fwhdr = NULL;
-	u16 fw_version, fw_subversion, fw_signature;
-	u8 *fw_data;
-	u32 fw_size;
-	static int log_version;
-
-	if (!dvobj->firmware.data)
-		ret = load_firmware(&dvobj->firmware, device);
-	if (ret == _FAIL) {
-		dvobj->firmware.data = NULL;
-		goto exit;
-	}
-	fw_data = dvobj->firmware.data;
-	fw_size = dvobj->firmware.size;
-
-	/*  To Check Fw header. Added by tynli. 2009.12.04. */
-	fwhdr = (struct rt_firmware_hdr *)dvobj->firmware.data;
-
-	fw_version = le16_to_cpu(fwhdr->Version);
-	fw_subversion = fwhdr->Subversion;
-	fw_signature = le16_to_cpu(fwhdr->Signature);
-
-	if (!log_version++)
-		pr_info("%sFirmware Version %d, SubVersion %d, Signature 0x%x\n",
-			DRIVER_PREFIX, fw_version, fw_subversion, fw_signature);
-
-	if (IS_FW_HEADER_EXIST(fwhdr)) {
-		/*  Shift 32 bytes for FW header */
-		fw_data = fw_data + 32;
-		fw_size = fw_size - 32;
-	}
-
-	/*  Suggested by Filen. If 8051 is running in RAM code, driver should inform Fw to reset by itself, */
-	/*  or it will cause download Fw fail. 2010.02.01. by tynli. */
-	if (rtw_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) { /* 8051 RAM code */
-		rtw_write8(padapter, REG_MCUFWDL, 0x00);
-		rtw_reset_8051(padapter);
-	}
-
-	fw_download_enable(padapter, true);
-	fwdl_start_time = jiffies;
-	while (1) {
-		/* reset the FWDL chksum */
-		rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_CHKSUM_RPT);
-
-		ret = write_fw(padapter, fw_data, fw_size);
-
-		if (ret == _SUCCESS ||
-		    (rtw_get_passing_time_ms(fwdl_start_time) > 500 && write_fw_retry++ >= 3))
-			break;
-
-		DBG_88E("%s write_fw_retry:%u, time after fwdl_start_time:%ums\n",
-			__func__, write_fw_retry, rtw_get_passing_time_ms(fwdl_start_time)
-		);
-	}
-	fw_download_enable(padapter, false);
-	if (ret != _SUCCESS) {
-		DBG_88E("DL Firmware failed!\n");
-		goto exit;
-	}
-
-	ret = fw_free_to_go(padapter);
-	if (ret != _SUCCESS) {
-		DBG_88E("DL Firmware failed!\n");
-		goto exit;
-	}
-
-exit:
-	return ret;
-}
-
 /*  */
 /*			Efuse related code */
 /*  */
diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c
index 3dc1c432e8cf..fc62019143ba 100644
--- a/drivers/staging/r8188eu/hal/usb_halinit.c
+++ b/drivers/staging/r8188eu/hal/usb_halinit.c
@@ -6,7 +6,7 @@
 #include "../include/osdep_service.h"
 #include "../include/drv_types.h"
 #include "../include/rtw_efuse.h"
-
+#include "../include/rtw_fw.h"
 #include "../include/rtl8188e_hal.h"
 #include "../include/rtw_iol.h"
 #include "../include/usb_ops.h"
diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h
index 4b67e11024a1..c614faf188bb 100644
--- a/drivers/staging/r8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/r8188eu/include/rtl8188e_hal.h
@@ -249,10 +249,6 @@ struct hal_data_8188e {
 	u8	UsbRxAggPageTimeout;
 };
 
-/*  rtl8188e_hal_init.c */
-int rtl8188e_firmware_download(struct adapter *padapter);
-void rtw_reset_8051(struct adapter *padapter);
-
 s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy);
 
 /*  EFuse */
diff --git a/drivers/staging/r8188eu/include/rtw_fw.h b/drivers/staging/r8188eu/include/rtw_fw.h
new file mode 100644
index 000000000000..749157704251
--- /dev/null
+++ b/drivers/staging/r8188eu/include/rtw_fw.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
+/* Copyright(c) 2007 - 2011 Realtek Corporation. */
+
+#ifndef __RTW_FW_H__
+#define __RTW_FW_H__
+
+#include "drv_types.h"
+
+#define MAX_REG_BOLCK_SIZE 196
+
+int rtl8188e_firmware_download(struct adapter *padapter);
+void rtw_reset_8051(struct adapter *padapter);
+
+#endif
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 23+ messages in thread

* Re: [PATCH 03/19] staging: r8188eu: release_firmware is not called if allocation fails
  2022-01-07 10:36 ` [PATCH 03/19] staging: r8188eu: release_firmware is not called if allocation fails Michael Straube
@ 2022-01-07 11:15   ` Pavel Skripkin
  2022-01-07 11:25     ` Greg KH
  0 siblings, 1 reply; 23+ messages in thread
From: Pavel Skripkin @ 2022-01-07 11:15 UTC (permalink / raw)
  To: Michael Straube, gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel

Hi Michael,

On 1/7/22 13:36, Michael Straube wrote:
> In function load_firmware() release_firmware() is not called if the
> allocation of pFirmware->szFwBuffer fails or if fw->size is greater
> than FW_8188E_SIZE.
> 
> Move the call to release_firmware() to the exit label at the end of
> the function to fix this.
> 
> Signed-off-by: Michael Straube <straube.linux@gmail.com>
> ---
>   drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
> index dc41682fd8d6..cfafbb6c42f7 100644
> --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
> +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
> @@ -538,10 +538,10 @@ static int load_firmware(struct rt_firmware *pFirmware, struct device *device)
>   	}
>   	memcpy(pFirmware->szFwBuffer, fw->data, fw->size);
>   	pFirmware->ulFwLength = fw->size;
> -	release_firmware(fw);
>   	dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", pFirmware->ulFwLength);
>   
>   Exit:
> +	release_firmware(fw);
>   	return rtStatus;
>   }
>   


This patch looks like a bug fix and it should go to stable kernels as 
well. The problem is this patch is made on top of 2 previous clean up 
patches, so it can't go to stable as is.

I think, the less painful way is to move this patch on the first place 
in this series. On the other hand you can just resend this one separately.


Or, maybe, Greg knows some magic that will help here, we can wait him 
before you resend 20 patch series :)

If you will somehow resend, please, add following tag:

Fixes: 8cd574e6af54 ("staging: r8188eu: introduce new hal dir for 
RTL8188eu driver")


Thanks for you clean up work on this driver!


With regards,
Pavel Skripkin

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 03/19] staging: r8188eu: release_firmware is not called if allocation fails
  2022-01-07 11:15   ` Pavel Skripkin
@ 2022-01-07 11:25     ` Greg KH
  2022-01-07 11:26       ` Pavel Skripkin
  0 siblings, 1 reply; 23+ messages in thread
From: Greg KH @ 2022-01-07 11:25 UTC (permalink / raw)
  To: Pavel Skripkin
  Cc: Michael Straube, Larry.Finger, phil, linux-staging, linux-kernel

On Fri, Jan 07, 2022 at 02:15:19PM +0300, Pavel Skripkin wrote:
> Hi Michael,
> 
> On 1/7/22 13:36, Michael Straube wrote:
> > In function load_firmware() release_firmware() is not called if the
> > allocation of pFirmware->szFwBuffer fails or if fw->size is greater
> > than FW_8188E_SIZE.
> > 
> > Move the call to release_firmware() to the exit label at the end of
> > the function to fix this.
> > 
> > Signed-off-by: Michael Straube <straube.linux@gmail.com>
> > ---
> >   drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
> > index dc41682fd8d6..cfafbb6c42f7 100644
> > --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
> > +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c
> > @@ -538,10 +538,10 @@ static int load_firmware(struct rt_firmware *pFirmware, struct device *device)
> >   	}
> >   	memcpy(pFirmware->szFwBuffer, fw->data, fw->size);
> >   	pFirmware->ulFwLength = fw->size;
> > -	release_firmware(fw);
> >   	dev_dbg(device, "!bUsedWoWLANFw, FmrmwareLen:%d+\n", pFirmware->ulFwLength);
> >   Exit:
> > +	release_firmware(fw);
> >   	return rtStatus;
> >   }
> 
> 
> This patch looks like a bug fix and it should go to stable kernels as well.
> The problem is this patch is made on top of 2 previous clean up patches, so
> it can't go to stable as is.
> 
> I think, the less painful way is to move this patch on the first place in
> this series. On the other hand you can just resend this one separately.
> 
> 
> Or, maybe, Greg knows some magic that will help here, we can wait him before
> you resend 20 patch series :)

It's just not worth it for this staging driver, and for an allocation
failure, to be backported here.  Allocation failures almost never happen
in real-world situations, and if they do, they are not alone, so this
would be the least of the problems happening here.

So no need to care about it, I can take this as-is.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 23+ messages in thread

* Re: [PATCH 03/19] staging: r8188eu: release_firmware is not called if allocation fails
  2022-01-07 11:25     ` Greg KH
@ 2022-01-07 11:26       ` Pavel Skripkin
  0 siblings, 0 replies; 23+ messages in thread
From: Pavel Skripkin @ 2022-01-07 11:26 UTC (permalink / raw)
  To: Greg KH; +Cc: Michael Straube, Larry.Finger, phil, linux-staging, linux-kernel

Hi Greg,

On 1/7/22 14:25, Greg KH wrote:
>> Or, maybe, Greg knows some magic that will help here, we can wait him before
>> you resend 20 patch series :)
> 
> It's just not worth it for this staging driver, and for an allocation
> failure, to be backported here.  Allocation failures almost never happen
> in real-world situations, and if they do, they are not alone, so this
> would be the least of the problems happening here.
> 
> So no need to care about it, I can take this as-is.
> 

Got it, thanks.


With regards,
Pavel Skripkin

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2022-01-07 11:27 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-07 10:36 [PATCH 00/19] staging: r8188eu: move firmware loading out of the hal layer Michael Straube
2022-01-07 10:36 ` [PATCH 01/19] staging: r8188eu: remove Firmware* from struct hal_data_8188e Michael Straube
2022-01-07 10:36 ` [PATCH 02/19] staging: r8188eu: remove rtl8188e_InitializeFirmwareVars() Michael Straube
2022-01-07 10:36 ` [PATCH 03/19] staging: r8188eu: release_firmware is not called if allocation fails Michael Straube
2022-01-07 11:15   ` Pavel Skripkin
2022-01-07 11:25     ` Greg KH
2022-01-07 11:26       ` Pavel Skripkin
2022-01-07 10:36 ` [PATCH 04/19] staging: r8188eu: rename Exit label in load_firmware() Michael Straube
2022-01-07 10:36 ` [PATCH 05/19] staging: r8188eu: rename rtStatus " Michael Straube
2022-01-07 10:36 ` [PATCH 06/19] staging: r8188eu: convert type of return variable " Michael Straube
2022-01-07 10:36 ` [PATCH 07/19] staging: r8188eu: rename parameter pFirmware of load_firmware() Michael Straube
2022-01-07 10:36 ` [PATCH 08/19] staging: r8188eu: rename fields of struct rt_firmware Michael Straube
2022-01-07 10:36 ` [PATCH 09/19] staging: r8188eu: use kmemdup instead of kzalloc and memcpy Michael Straube
2022-01-07 10:36 ` [PATCH 10/19] staging: r8188eu: rename fw related functions to avoid camel case Michael Straube
2022-01-07 10:36 ` [PATCH 11/19] staging: r8188eu: clean up rtw_reset_8051() Michael Straube
2022-01-07 10:36 ` [PATCH 12/19] staging: r8188eu: convert two functions from s32 to int Michael Straube
2022-01-07 10:36 ` [PATCH 13/19] staging: r8188eu: rename Exit label in rtl8188e_firmware_download() Michael Straube
2022-01-07 10:36 ` [PATCH 14/19] staging: r8188eu: rename rtSatus " Michael Straube
2022-01-07 10:36 ` [PATCH 15/19] staging: r8188eu: rename FWDL_ChkSum_rpt Michael Straube
2022-01-07 10:36 ` [PATCH 16/19] staging: r8188eu: rename writeFW_retry Michael Straube
2022-01-07 10:36 ` [PATCH 17/19] staging: r8188eu: rename pFwHdr in rtl8188e_firmware_download() Michael Straube
2022-01-07 10:36 ` [PATCH 18/19] staging: r8188eu: rename pFirmwareBuf and FirmwareLen Michael Straube
2022-01-07 10:36 ` [PATCH 19/19] staging: r8188eu: move firmware loading code out of the hal layer Michael Straube

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).