Skip to content

Commit e7ece05

Browse files
Xinming HuKalle Valo
authored andcommitted
mwifiex: pcie: compatible with wifi-only image while extract wifi-part fw
Sometimes, we might using wifi-only firmware with a combo firmware name, in this case, do not need to filter bluetooth part from header. Signed-off-by: Xinming Hu <[email protected]> Signed-off-by: Cathy Luo <[email protected]> Reviewed-by: Brian Norris <[email protected]> Signed-off-by: Kalle Valo <[email protected]>
1 parent e37f648 commit e7ece05

File tree

1 file changed

+19
-7
lines changed
  • drivers/net/wireless/marvell/mwifiex

1 file changed

+19
-7
lines changed

drivers/net/wireless/marvell/mwifiex/pcie.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1985,15 +1985,16 @@ static int mwifiex_pcie_event_complete(struct mwifiex_adapter *adapter,
19851985
* (3) wifi image.
19861986
*
19871987
* This function bypass the header and bluetooth part, return
1988-
* the offset of tail wifi-only part.
1988+
* the offset of tail wifi-only part. If the image is already wifi-only,
1989+
* that is start with CMD1, return 0.
19891990
*/
19901991

19911992
static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
19921993
const void *firmware, u32 firmware_len) {
19931994
const struct mwifiex_fw_data *fwdata;
19941995
u32 offset = 0, data_len, dnld_cmd;
19951996
int ret = 0;
1996-
bool cmd7_before = false;
1997+
bool cmd7_before = false, first_cmd = false;
19971998

19981999
while (1) {
19992000
/* Check for integer and buffer overflow */
@@ -2014,20 +2015,29 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
20142015

20152016
switch (dnld_cmd) {
20162017
case MWIFIEX_FW_DNLD_CMD_1:
2017-
if (!cmd7_before) {
2018-
mwifiex_dbg(adapter, ERROR,
2019-
"no cmd7 before cmd1!\n");
2018+
if (offset + data_len < data_len) {
2019+
mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
20202020
ret = -1;
20212021
goto done;
20222022
}
2023-
if (offset + data_len < data_len) {
2024-
mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
2023+
2024+
/* Image start with cmd1, already wifi-only firmware */
2025+
if (!first_cmd) {
2026+
mwifiex_dbg(adapter, MSG,
2027+
"input wifi-only firmware\n");
2028+
return 0;
2029+
}
2030+
2031+
if (!cmd7_before) {
2032+
mwifiex_dbg(adapter, ERROR,
2033+
"no cmd7 before cmd1!\n");
20252034
ret = -1;
20262035
goto done;
20272036
}
20282037
offset += data_len;
20292038
break;
20302039
case MWIFIEX_FW_DNLD_CMD_5:
2040+
first_cmd = true;
20312041
/* Check for integer overflow */
20322042
if (offset + data_len < data_len) {
20332043
mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
@@ -2037,6 +2047,7 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
20372047
offset += data_len;
20382048
break;
20392049
case MWIFIEX_FW_DNLD_CMD_6:
2050+
first_cmd = true;
20402051
/* Check for integer overflow */
20412052
if (offset + data_len < data_len) {
20422053
mwifiex_dbg(adapter, ERROR, "bad FW parse\n");
@@ -2053,6 +2064,7 @@ static int mwifiex_extract_wifi_fw(struct mwifiex_adapter *adapter,
20532064
}
20542065
goto done;
20552066
case MWIFIEX_FW_DNLD_CMD_7:
2067+
first_cmd = true;
20562068
cmd7_before = true;
20572069
break;
20582070
default:

0 commit comments

Comments
 (0)