Skip to contentSkip to conversation

staging: r8188eu: move firmware loading out of the hal layer

PATCH In review Michael Straube 3 participants 23 messages Jan 7, 2022 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: r8188eu: move firmware loading out of the hal layer

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
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/19 staging: r8188eu: remove Firmware* from struct hal_data_8188e

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.

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 11 +++++------
 drivers/staging/r8188eu/include/rtl8188e_hal.h  |  4 ----
 2 files changed, 5 insertions(+), 10 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +5 -6
index b818872e0d19..20e4a12801cf 100644
@@ -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 */
drivers/staging/r8188eu/include/rtl8188e_hal.h +0 -4
index 8134a173ea07..9133f3b0acc1 100644
@@ -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;
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/19 staging: r8188eu: remove rtl8188e_InitializeFirmwareVars()

In reply to Michael Straube

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

---
 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(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +0 -11
index 20e4a12801cf..dc41682fd8d6 100644
@@ -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 */
 /*  */
drivers/staging/r8188eu/hal/usb_halinit.c +3 -1
index 96db9a8e7667..696beb29536f 100644
@@ -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);
drivers/staging/r8188eu/include/rtl8188e_hal.h +0 -1
index 9133f3b0acc1..3da04751f25d 100644
@@ -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);
 
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/19 staging: r8188eu: release_firmware is not called if allocation fails

In reply to 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.

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +1 -1
index dc41682fd8d6..cfafbb6c42f7 100644
@@ -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;
 }
 
Signature · 1 line
2.34.1
#4 lore raw

Re: [PATCH 03/19] staging: r8188eu: release_firmware is not called if allocation fails

Hi Michael,

Quoted 18 lines · 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.

---
  drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +0 -0
index dc41682fd8d6..cfafbb6c42f7 100644
@@ -538,10 +538,10 @@ static int load_firmware(struct rt_firmware *pFirmware, struct device *device)
  	}

drivers/staging/r8188eu/hal/rtl8188e_hal_init.c static int load_firmware(struct rt_firmware *pFirmware, struct device *device) · line 547

Quoted 10 lines
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +1 -1
  	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

maintainer
#5 lore raw

Re: [PATCH 03/19] staging: r8188eu: release_firmware is not called if allocation fails

Quoted 35 lines · Pavel Skripkin

Hi Michael,

Quoted 17 lines · 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.

---
  drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +0 -0
index dc41682fd8d6..cfafbb6c42f7 100644

drivers/staging/r8188eu/hal/rtl8188e_hal_init.c static int load_firmware(struct rt_firmware *pFirmware, struct device *device) · line 545

Quoted 9 lines
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +1 -1
@@ -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.

Quoted 6 lines

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

#6 lore raw

Re: [PATCH 03/19] staging: r8188eu: release_firmware is not called if allocation fails

Hi Greg,

Quoted 10 lines · Greg KH
Quoted 2 lines

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

#7 lore raw

PATCH 4/19 staging: r8188eu: rename Exit label in load_firmware()

In reply to Michael Straube

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

Exit -> exit

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +5 -5
index cfafbb6c42f7..b4f29c48d58d 100644
@@ -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;
 }
Signature · 1 line
2.34.1
#8 lore raw

PATCH 5/19 staging: r8188eu: rename rtStatus in load_firmware()

In reply to Michael Straube

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

rtStatus -> ret

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +6 -6
index b4f29c48d58d..edb56a9ae283 100644
@@ -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)
Signature · 1 line
2.34.1
#9 lore raw

PATCH 6/19 staging: r8188eu: convert type of return variable in load_firmware()

In reply to 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.

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +1 -1
index edb56a9ae283..bd7f3dc5878b 100644
@@ -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);
Signature · 1 line
2.34.1
#10 lore raw

PATCH 7/19 staging: r8188eu: rename parameter pFirmware of load_firmware()

In reply to Michael Straube

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

pFirmware -> rtfw

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +7 -7
index bd7f3dc5878b..5c1da9dd179b 100644
@@ -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);
Signature · 1 line
2.34.1
#11 lore raw

PATCH 8/19 staging: r8188eu: rename fields of struct rt_firmware

In reply to Michael Straube

Rename fields of struct rt_firmware to avoid camel case.

szFwBuffer -> data
ulFwLength -> size

---
 .../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(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +11 -11
index 5c1da9dd179b..ee684b37ff91 100644
@@ -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;
drivers/staging/r8188eu/include/drv_types.h +2 -2
index 2dd5ebaaa921..388822dd325d 100644
@@ -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 {
drivers/staging/r8188eu/os_dep/os_intfs.c +2 -2
index b65e44f97826..08d719822062 100644
@@ -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;
Signature · 1 line
2.34.1
#12 lore raw

PATCH 9/19 staging: r8188eu: use kmemdup instead of kzalloc and memcpy

In reply to Michael Straube

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

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 7 +------
 drivers/staging/r8188eu/include/rtl8188e_hal.h  | 1 -
 2 files changed, 1 insertion(+), 7 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +1 -6
index ee684b37ff91..f7ae2fc0d2b9 100644
@@ -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);
 
drivers/staging/r8188eu/include/rtl8188e_hal.h +0 -1
index 3da04751f25d..051f3b9fe726 100644
@@ -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 */
Signature · 1 line
2.34.1
#13 lore raw

PATCH 10/19 staging: r8188eu: rename fw related functions to avoid camel case

In reply to 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

---
 .../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(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +17 -17
index f7ae2fc0d2b9..b1f2d349c33a 100644
@@ -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;
drivers/staging/r8188eu/hal/usb_halinit.c +1 -1
index 696beb29536f..3dc1c432e8cf 100644
@@ -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__);
drivers/staging/r8188eu/include/rtl8188e_hal.h +2 -2
index 051f3b9fe726..11d79606e120 100644
@@ -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);
 
Signature · 1 line
2.34.1
#14 lore raw

PATCH 11/19 staging: r8188eu: clean up rtw_reset_8051()

In reply to 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.

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +4 -5
index b1f2d349c33a..d219882fc4a2 100644
@@ -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)
Signature · 1 line
2.34.1
#15 lore raw

PATCH 12/19 staging: r8188eu: convert two functions from s32 to int

In reply to Michael Straube

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

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 6 +++---
 drivers/staging/r8188eu/include/rtl8188e_hal.h  | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +3 -3
index d219882fc4a2..f86b5cb2b6f9 100644
@@ -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);
drivers/staging/r8188eu/include/rtl8188e_hal.h +1 -1
index 11d79606e120..4b67e11024a1 100644
@@ -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);
Signature · 1 line
2.34.1
#16 lore raw

PATCH 13/19 staging: r8188eu: rename Exit label in rtl8188e_firmware_download()

In reply to Michael Straube

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

Exit -> exit

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +4 -4
index f86b5cb2b6f9..f158bbf44094 100644
@@ -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;
 }
 
Signature · 1 line
2.34.1
#17 lore raw

PATCH 14/19 staging: r8188eu: rename rtSatus in rtl8188e_firmware_download()

In reply to Michael Straube

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

rtStatus -> ret

---
 .../staging/r8188eu/hal/rtl8188e_hal_init.c    | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +9 -9
index f158bbf44094..1685386a7015 100644
@@ -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;
 }
 
 /*  */
Signature · 1 line
2.34.1
#18 lore raw

PATCH 15/19 staging: r8188eu: rename FWDL_ChkSum_rpt

In reply to Michael Straube

Rename FWDL_ChkSum_rpt to avoid camel case.

FWDL_ChkSum_rpt -> FWDL_CHKSUM_RPT

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 4 ++--
 drivers/staging/r8188eu/include/rtl8188e_spec.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +2 -2
index 1685386a7015..6c23966ec785 100644
@@ -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);
 
drivers/staging/r8188eu/include/rtl8188e_spec.h +1 -1
index 009222b4a95d..edae053e350e 100644
@@ -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)
Signature · 1 line
2.34.1
#19 lore raw

PATCH 16/19 staging: r8188eu: rename writeFW_retry

In reply to Michael Straube

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

writeFW_retry -> write_fw_retry

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +4 -4
index 6c23966ec785..15e8dc0b9a37 100644
@@ -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);
Signature · 1 line
2.34.1
#20 lore raw

PATCH 17/19 staging: r8188eu: rename pFwHdr in rtl8188e_firmware_download()

In reply to Michael Straube

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

pFwHdr -> fwhdr

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +6 -6
index 15e8dc0b9a37..c2112df0ac82 100644
@@ -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;
Signature · 1 line
2.34.1
#21 lore raw

PATCH 18/19 staging: r8188eu: rename pFirmwareBuf and FirmwareLen

In reply to Michael Straube

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

pFirmwareBuf -> fw_data
FirmwareLen -> fw_size

---
 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +7 -7
index c2112df0ac82..3c9ddbe16754 100644
@@ -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))
Signature · 1 line
2.34.1
#22 lore raw

PATCH 19/19 staging: r8188eu: move firmware loading code out of the hal layer

In reply to Michael Straube

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

---
 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
drivers/staging/r8188eu/Makefile +1 -0
index a7a486cc16dd..84627fc89ec9 100644
@@ -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 \
drivers/staging/r8188eu/core/rtw_fw.c new file +284 -0

284 lines not on this page · raw message

drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +1 -282

300 lines not on this page · raw message

drivers/staging/r8188eu/hal/usb_halinit.c +1 -1
index 3dc1c432e8cf..fc62019143ba 100644
@@ -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"
drivers/staging/r8188eu/include/rtl8188e_hal.h +0 -4
index 4b67e11024a1..c614faf188bb 100644
@@ -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 */
drivers/staging/r8188eu/include/rtw_fw.h new file +14 -0
new file mode 100644
index 000000000000..749157704251
@@ -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
Signature · 1 line
2.34.1