Skip to content

Commit 22630e2

Browse files
Edwin Peerdavem330
authored andcommitted
bnxt_en: fix error handling when flashing from file
After bnxt_hwrm_do_send_message() was updated to return standard error codes in a recent commit, a regression in bnxt_flash_package_from_file() was introduced. The return value does not properly reflect all possible firmware errors when calling firmware to flash the package. Fix it by consolidating all errors in one local variable rc instead of having 2 variables for different errors. Fixes: d4f1420 ("bnxt_en: Convert error code in firmware message response to standard code.") Signed-off-by: Edwin Peer <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a9b952d commit 22630e2

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2007,8 +2007,8 @@ int bnxt_flash_package_from_file(struct net_device *dev, const char *filename,
20072007
struct hwrm_nvm_install_update_output *resp = bp->hwrm_cmd_resp_addr;
20082008
struct hwrm_nvm_install_update_input install = {0};
20092009
const struct firmware *fw;
2010-
int rc, hwrm_err = 0;
20112010
u32 item_len;
2011+
int rc = 0;
20122012
u16 index;
20132013

20142014
bnxt_hwrm_fw_set_time(bp);
@@ -2052,15 +2052,14 @@ int bnxt_flash_package_from_file(struct net_device *dev, const char *filename,
20522052
memcpy(kmem, fw->data, fw->size);
20532053
modify.host_src_addr = cpu_to_le64(dma_handle);
20542054

2055-
hwrm_err = hwrm_send_message(bp, &modify,
2056-
sizeof(modify),
2057-
FLASH_PACKAGE_TIMEOUT);
2055+
rc = hwrm_send_message(bp, &modify, sizeof(modify),
2056+
FLASH_PACKAGE_TIMEOUT);
20582057
dma_free_coherent(&bp->pdev->dev, fw->size, kmem,
20592058
dma_handle);
20602059
}
20612060
}
20622061
release_firmware(fw);
2063-
if (rc || hwrm_err)
2062+
if (rc)
20642063
goto err_exit;
20652064

20662065
if ((install_type & 0xffff) == 0)
@@ -2069,20 +2068,19 @@ int bnxt_flash_package_from_file(struct net_device *dev, const char *filename,
20692068
install.install_type = cpu_to_le32(install_type);
20702069

20712070
mutex_lock(&bp->hwrm_cmd_lock);
2072-
hwrm_err = _hwrm_send_message(bp, &install, sizeof(install),
2073-
INSTALL_PACKAGE_TIMEOUT);
2074-
if (hwrm_err) {
2071+
rc = _hwrm_send_message(bp, &install, sizeof(install),
2072+
INSTALL_PACKAGE_TIMEOUT);
2073+
if (rc) {
20752074
u8 error_code = ((struct hwrm_err_output *)resp)->cmd_err;
20762075

20772076
if (resp->error_code && error_code ==
20782077
NVM_INSTALL_UPDATE_CMD_ERR_CODE_FRAG_ERR) {
20792078
install.flags |= cpu_to_le16(
20802079
NVM_INSTALL_UPDATE_REQ_FLAGS_ALLOWED_TO_DEFRAG);
2081-
hwrm_err = _hwrm_send_message(bp, &install,
2082-
sizeof(install),
2083-
INSTALL_PACKAGE_TIMEOUT);
2080+
rc = _hwrm_send_message(bp, &install, sizeof(install),
2081+
INSTALL_PACKAGE_TIMEOUT);
20842082
}
2085-
if (hwrm_err)
2083+
if (rc)
20862084
goto flash_pkg_exit;
20872085
}
20882086

@@ -2094,7 +2092,7 @@ int bnxt_flash_package_from_file(struct net_device *dev, const char *filename,
20942092
flash_pkg_exit:
20952093
mutex_unlock(&bp->hwrm_cmd_lock);
20962094
err_exit:
2097-
if (hwrm_err == -EACCES)
2095+
if (rc == -EACCES)
20982096
bnxt_print_admin_err(bp);
20992097
return rc;
21002098
}

0 commit comments

Comments
 (0)