* [PATCH v2] platform/mellanox: mlxreg-lc: Fix logic error in power state check
@ 2025-06-30 10:58 Alok Tiwari
2025-06-30 11:07 ` Ilpo Järvinen
0 siblings, 1 reply; 2+ messages in thread
From: Alok Tiwari @ 2025-06-30 10:58 UTC (permalink / raw)
To: hansg, ilpo.jarvinen, vadimp, platform-driver-x86
Cc: alok.a.tiwari, darren.kenny, linux-kernel
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>
---
drivers/platform/mellanox/mlxreg-lc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/platform/mellanox/mlxreg-lc.c b/drivers/platform/mellanox/mlxreg-lc.c
index aee395bb48ae4..8681ceb7144ba 100644
--- a/drivers/platform/mellanox/mlxreg-lc.c
+++ b/drivers/platform/mellanox/mlxreg-lc.c
@@ -688,7 +688,7 @@ static int mlxreg_lc_completion_notify(void *handle, struct i2c_adapter *parent,
if (regval & mlxreg_lc->data->mask) {
mlxreg_lc->state |= MLXREG_LC_SYNCED;
mlxreg_lc_state_update_locked(mlxreg_lc, MLXREG_LC_SYNCED, 1);
- if (mlxreg_lc->state & ~MLXREG_LC_POWERED) {
+ if (!(mlxreg_lc->state & MLXREG_LC_POWERED)) {
err = mlxreg_lc_power_on_off(mlxreg_lc, 1);
if (err)
goto mlxreg_lc_regmap_power_on_off_fail;
--
2.46.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] platform/mellanox: mlxreg-lc: Fix logic error in power state check
2025-06-30 10:58 [PATCH v2] platform/mellanox: mlxreg-lc: Fix logic error in power state check Alok Tiwari
@ 2025-06-30 11:07 ` Ilpo Järvinen
0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2025-06-30 11:07 UTC (permalink / raw)
To: hansg, vadimp, platform-driver-x86, Alok Tiwari
Cc: darren.kenny, linux-kernel
On Mon, 30 Jun 2025 03:58:08 -0700, Alok Tiwari wrote:
> 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.
>
> [...]
Thank you for your contribution, it has been applied to my local
review-ilpo-fixes branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my
local branch there, which might take a while.
The list of commits applied:
[1/1] platform/mellanox: mlxreg-lc: Fix logic error in power state check
commit: 644bec18e705ca41d444053407419a21832fcb2f
--
i.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-30 11:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-30 10:58 [PATCH v2] platform/mellanox: mlxreg-lc: Fix logic error in power state check Alok Tiwari
2025-06-30 11:07 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®