Skip to content

Commit

Permalink
platform/mellanox: mlxreg-lc: Make error handling flow consistent
Browse files Browse the repository at this point in the history
Use 'goto' statement in error flow of mlxreg_lc_event_handler() at all
places for consistency.

This follow-up patch implementing comments from
https://www.spinics.net/lists/platform-driver-x86/msg34587.html

Signed-off-by: Vadim Pasternak <vadimp@nvidia.com>
Link: https://lore.kernel.org/r/20220904141113.49048-1-vadimp@nvidia.com
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
  • Loading branch information
Vadim Pasternak authored and Hans de Goede committed Sep 9, 2022
1 parent c5b94f5 commit 072aba5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions drivers/platform/mellanox/mlxreg-lc.c
Original file line number Diff line number Diff line change
Expand Up @@ -564,10 +564,8 @@ static int mlxreg_lc_event_handler(void *handle, enum mlxreg_hotplug_kind kind,
mlxreg_lc->data->slot, mlxreg_lc->state, kind, action);

mutex_lock(&mlxreg_lc->lock);
if (!(mlxreg_lc->state & MLXREG_LC_INITIALIZED)) {
mutex_unlock(&mlxreg_lc->lock);
return 0;
}
if (!(mlxreg_lc->state & MLXREG_LC_INITIALIZED))
goto mlxreg_lc_non_initialzed_exit;

switch (kind) {
case MLXREG_HOTPLUG_LC_SYNCED:
Expand All @@ -594,8 +592,8 @@ static int mlxreg_lc_event_handler(void *handle, enum mlxreg_hotplug_kind kind,
/* In case line card is configured - enable it. */
if (mlxreg_lc->state & MLXREG_LC_CONFIGURED)
err = mlxreg_lc_enable_disable(mlxreg_lc, 1);
mutex_unlock(&mlxreg_lc->lock);
return err;

goto mlxreg_lc_enable_disable_exit;
}
err = mlxreg_lc_create_static_devices(mlxreg_lc, mlxreg_lc->main_devs,
mlxreg_lc->main_devs_num);
Expand Down Expand Up @@ -627,8 +625,10 @@ static int mlxreg_lc_event_handler(void *handle, enum mlxreg_hotplug_kind kind,
break;
}

mlxreg_lc_enable_disable_exit:
mlxreg_lc_power_on_off_fail:
mlxreg_lc_create_static_devices_fail:
mlxreg_lc_non_initialzed_exit:
mutex_unlock(&mlxreg_lc->lock);

return err;
Expand Down

0 comments on commit 072aba5

Please sign in to comment.