Skip to content

Commit ba1aabb

Browse files
aloktiwasmb49
authored andcommitted
platform/mellanox: mlxreg-lc: Fix logic error in power state check
BugLink: https://bugs.launchpad.net/bugs/2122072 [ Upstream commit 644bec18e705ca41d444053407419a21832fcb2f ] Fixes a logic issue in mlxreg_lc_completion_notify() where the intention was to check if MLXREG_LC_POWERED flag is not set before powering on the device. The original code used "state & ~MLXREG_LC_POWERED" to check for the absence of the POWERED bit. However this condition evaluates to true even when other bits are set, leading to potentially incorrect behavior. Corrected the logic to explicitly check for the absence of MLXREG_LC_POWERED using !(state & MLXREG_LC_POWERED). Fixes: 62f9529 ("platform/mellanox: mlxreg-lc: Add initial support for Nvidia line card devices") Suggested-by: Vadim Pasternak <[email protected]> Signed-off-by: Alok Tiwari <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Noah Wager <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent d26bfad commit ba1aabb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/platform/mellanox/mlxreg-lc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ static int mlxreg_lc_completion_notify(void *handle, struct i2c_adapter *parent,
688688
if (regval & mlxreg_lc->data->mask) {
689689
mlxreg_lc->state |= MLXREG_LC_SYNCED;
690690
mlxreg_lc_state_update_locked(mlxreg_lc, MLXREG_LC_SYNCED, 1);
691-
if (mlxreg_lc->state & ~MLXREG_LC_POWERED) {
691+
if (!(mlxreg_lc->state & MLXREG_LC_POWERED)) {
692692
err = mlxreg_lc_power_on_off(mlxreg_lc, 1);
693693
if (err)
694694
goto mlxreg_lc_regmap_power_on_off_fail;

0 commit comments

Comments
 (0)