From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Alok Tiwari <alok.a.tiwari@oracle.com>
Cc: hansg@kernel.org, vadimp@nvidia.com,
platform-driver-x86@vger.kernel.org, darren.kenny@oracle.com,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] platform/mellanox: Fix logic error in power state check in mlxreg-lc
Date: Mon, 30 Jun 2025 13:01:54 +0300 (EEST) [thread overview]
Message-ID: <8e86e409-0a19-ec74-f126-2e5315e3dc0a@linux.intel.com> (raw)
In-Reply-To: <20250630095001.598061-1-alok.a.tiwari@oracle.com>
On Mon, 30 Jun 2025, 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.
>
> Corrected the logic to explicitly check for the absence of
> MLXREG_LC_POWERED using !(state & MLXREG_LC_POWERED).
>
> Suggested-by: Vadim Pasternak <vadimp@nvidia.com>
> Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
Makes sense but please add Fixes tag and resubmit as v2.
> ---
> 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;
>
--
i.
next prev parent reply other threads:[~2025-06-30 10:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-30 9:49 [PATCH] platform/mellanox: Fix logic error in power state check in mlxreg-lc Alok Tiwari
2025-06-30 10:01 ` Ilpo Järvinen [this message]
2025-06-30 10:03 ` Ilpo Järvinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8e86e409-0a19-ec74-f126-2e5315e3dc0a@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=alok.a.tiwari@oracle.com \
--cc=darren.kenny@oracle.com \
--cc=hansg@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=vadimp@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox