Commit 5042e8b9 authored by Saeed Mahameed's avatar Saeed Mahameed Committed by David S. Miller

net/mlxfw: Use MLXFW_ERR_MSG macro for error reporting

Instead of always calling both mlxfw_err and NL_SET_ERR_MSG_MOD with the
same message, use the dedicated macro instead.
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6a3f707c
...@@ -95,7 +95,7 @@ static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle, ...@@ -95,7 +95,7 @@ static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
err = mlxfw_dev->ops->fsm_query_state(mlxfw_dev, fwhandle, err = mlxfw_dev->ops->fsm_query_state(mlxfw_dev, fwhandle,
&curr_fsm_state, &fsm_state_err); &curr_fsm_state, &fsm_state_err);
if (err) { if (err) {
NL_SET_ERR_MSG_MOD(extack, "FSM state query failed"); MLXFW_ERR_MSG(mlxfw_dev, extack, "FSM state query failed", err);
return err; return err;
} }
...@@ -104,8 +104,8 @@ static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle, ...@@ -104,8 +104,8 @@ static int mlxfw_fsm_state_wait(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
if (curr_fsm_state != fsm_state) { if (curr_fsm_state != fsm_state) {
if (--times == 0) { if (--times == 0) {
mlxfw_err(mlxfw_dev, "Timeout reached on FSM state change\n"); MLXFW_ERR_MSG(mlxfw_dev, extack,
NL_SET_ERR_MSG_MOD(extack, "Timeout reached on FSM state change"); "Timeout reached on FSM state change", -ETIMEDOUT);
return -ETIMEDOUT; return -ETIMEDOUT;
} }
msleep(MLXFW_FSM_STATE_WAIT_CYCLE_MS); msleep(MLXFW_FSM_STATE_WAIT_CYCLE_MS);
...@@ -146,15 +146,14 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev, ...@@ -146,15 +146,14 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
&comp_max_size, &comp_align_bits, &comp_max_size, &comp_align_bits,
&comp_max_write_size); &comp_max_write_size);
if (err) { if (err) {
NL_SET_ERR_MSG_MOD(extack, "FSM component query failed"); MLXFW_ERR_MSG(mlxfw_dev, extack, "FSM component query failed", err);
return err; return err;
} }
comp_max_size = min_t(u32, comp_max_size, MLXFW_FSM_MAX_COMPONENT_SIZE); comp_max_size = min_t(u32, comp_max_size, MLXFW_FSM_MAX_COMPONENT_SIZE);
if (comp->data_size > comp_max_size) { if (comp->data_size > comp_max_size) {
mlxfw_err(mlxfw_dev, "Component %d is of size %d which is bigger than limit %d\n", MLXFW_ERR_MSG(mlxfw_dev, extack,
comp->index, comp->data_size, comp_max_size); "Component size is bigger than limit", -EINVAL);
NL_SET_ERR_MSG_MOD(extack, "Component is bigger than limit");
return -EINVAL; return -EINVAL;
} }
...@@ -167,7 +166,8 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev, ...@@ -167,7 +166,8 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
comp->index, comp->index,
comp->data_size); comp->data_size);
if (err) { if (err) {
NL_SET_ERR_MSG_MOD(extack, "FSM component update failed"); MLXFW_ERR_MSG(mlxfw_dev, extack,
"FSM component update failed", err);
return err; return err;
} }
...@@ -189,7 +189,8 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev, ...@@ -189,7 +189,8 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
block_ptr, block_size, block_ptr, block_size,
offset); offset);
if (err) { if (err) {
NL_SET_ERR_MSG_MOD(extack, "Component download failed"); MLXFW_ERR_MSG(mlxfw_dev, extack,
"Component download failed", err);
goto err_out; goto err_out;
} }
mlxfw_status_notify(mlxfw_dev, "Downloading component", mlxfw_status_notify(mlxfw_dev, "Downloading component",
...@@ -202,7 +203,8 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev, ...@@ -202,7 +203,8 @@ static int mlxfw_flash_component(struct mlxfw_dev *mlxfw_dev,
err = mlxfw_dev->ops->fsm_component_verify(mlxfw_dev, fwhandle, err = mlxfw_dev->ops->fsm_component_verify(mlxfw_dev, fwhandle,
comp->index); comp->index);
if (err) { if (err) {
NL_SET_ERR_MSG_MOD(extack, "FSM component verify failed"); MLXFW_ERR_MSG(mlxfw_dev, extack,
"FSM component verify failed", err);
goto err_out; goto err_out;
} }
...@@ -229,8 +231,8 @@ static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle, ...@@ -229,8 +231,8 @@ static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
mlxfw_dev->psid_size, mlxfw_dev->psid_size,
&component_count); &component_count);
if (err) { if (err) {
mlxfw_err(mlxfw_dev, "Could not find device PSID in MFA2 file\n"); MLXFW_ERR_MSG(mlxfw_dev, extack,
NL_SET_ERR_MSG_MOD(extack, "Could not find device PSID in MFA2 file"); "Could not find device PSID in MFA2 file", err);
return err; return err;
} }
...@@ -241,7 +243,8 @@ static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle, ...@@ -241,7 +243,8 @@ static int mlxfw_flash_components(struct mlxfw_dev *mlxfw_dev, u32 fwhandle,
mlxfw_dev->psid_size, i); mlxfw_dev->psid_size, i);
if (IS_ERR(comp)) { if (IS_ERR(comp)) {
err = PTR_ERR(comp); err = PTR_ERR(comp);
NL_SET_ERR_MSG_MOD(extack, "Failed to get MFA2 component"); MLXFW_ERR_MSG(mlxfw_dev, extack,
"Failed to get MFA2 component", err);
return err; return err;
} }
...@@ -264,16 +267,16 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev, ...@@ -264,16 +267,16 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
int err; int err;
if (!mlxfw_mfa2_check(firmware)) { if (!mlxfw_mfa2_check(firmware)) {
mlxfw_err(mlxfw_dev, "Firmware file is not MFA2\n"); MLXFW_ERR_MSG(mlxfw_dev, extack,
NL_SET_ERR_MSG_MOD(extack, "Firmware file is not MFA2"); "Firmware file is not MFA2", -EINVAL);
return -EINVAL; return -EINVAL;
} }
mfa2_file = mlxfw_mfa2_file_init(firmware); mfa2_file = mlxfw_mfa2_file_init(firmware);
if (IS_ERR(mfa2_file)) { if (IS_ERR(mfa2_file)) {
err = PTR_ERR(mfa2_file); err = PTR_ERR(mfa2_file);
NL_SET_ERR_MSG_MOD(extack, MLXFW_ERR_MSG(mlxfw_dev, extack,
"Failed to initialize MFA2 firmware file"); "Failed to initialize MFA2 firmware file", err);
return err; return err;
} }
...@@ -283,8 +286,8 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev, ...@@ -283,8 +286,8 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
NULL, 0, 0); NULL, 0, 0);
err = mlxfw_dev->ops->fsm_lock(mlxfw_dev, &fwhandle); err = mlxfw_dev->ops->fsm_lock(mlxfw_dev, &fwhandle);
if (err) { if (err) {
mlxfw_err(mlxfw_dev, "Could not lock the firmware FSM\n"); MLXFW_ERR_MSG(mlxfw_dev, extack,
NL_SET_ERR_MSG_MOD(extack, "Could not lock the firmware FSM"); "Could not lock the firmware FSM", err);
goto err_fsm_lock; goto err_fsm_lock;
} }
...@@ -301,8 +304,8 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev, ...@@ -301,8 +304,8 @@ int mlxfw_firmware_flash(struct mlxfw_dev *mlxfw_dev,
mlxfw_status_notify(mlxfw_dev, "Activating image", NULL, 0, 0); mlxfw_status_notify(mlxfw_dev, "Activating image", NULL, 0, 0);
err = mlxfw_dev->ops->fsm_activate(mlxfw_dev, fwhandle); err = mlxfw_dev->ops->fsm_activate(mlxfw_dev, fwhandle);
if (err) { if (err) {
mlxfw_err(mlxfw_dev, "Could not activate the downloaded image\n"); MLXFW_ERR_MSG(mlxfw_dev, extack,
NL_SET_ERR_MSG_MOD(extack, "Could not activate the downloaded image"); "Could not activate the downloaded image", err);
goto err_fsm_activate; goto err_fsm_activate;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment