Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/mellanox: mlxreg-lc: Fix logic error in power state check

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: 62f9529b8d5c ("platform/mellanox: mlxreg-lc: Add initial support for Nvidia line card devices")
Suggested-by: Vadim Pasternak <vadimp@nvidia.com>
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Link: https://lore.kernel.org/r/20250630105812.601014-1-alok.a.tiwari@oracle.com
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>

authored by

Alok Tiwari and committed by
Ilpo Järvinen
644bec18 af14ed3f

+1 -1
+1 -1
drivers/platform/mellanox/mlxreg-lc.c
··· 688 688 if (regval & mlxreg_lc->data->mask) { 689 689 mlxreg_lc->state |= MLXREG_LC_SYNCED; 690 690 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)) { 692 692 err = mlxreg_lc_power_on_off(mlxreg_lc, 1); 693 693 if (err) 694 694 goto mlxreg_lc_regmap_power_on_off_fail;