* [PATCH] cxl: remove assignment from if condition in cxl_mem_get_poison
@ 2025-08-13 11:55 darshanrathod475
2025-08-13 12:52 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: darshanrathod475 @ 2025-08-13 11:55 UTC (permalink / raw)
To: dave, jonathan.cameron, dave.jiang, alison.schofield,
vishal.l.verma, ira.weiny, dan.j.williams
Cc: shiju.jose, ming.li, peterz, linux-cxl, linux-kernel,
Darshan Rathod
From: Darshan Rathod <darshanrathod475@gmail.com>
Refactor cxl_mem_get_poison() to assign the return value of
ACQUIRE_ERR() before the conditional check, instead of performing the
assignment inside the if condition. This resolves a checkpatch.pl
warning ("do not use assignment in if condition") and improves
readability.
Signed-off-by: Darshan Rathod <darshanrathod475@gmail.com>
---
drivers/cxl/core/mbox.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
index fa6dd0c94656..9c5066631896 100644
--- a/drivers/cxl/core/mbox.c
+++ b/drivers/cxl/core/mbox.c
@@ -1426,7 +1426,9 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
int rc;
ACQUIRE(mutex_intr, lock)(&mds->poison.mutex);
- if ((rc = ACQUIRE_ERR(mutex_intr, &lock)))
+
+ rc = ACQUIRE_ERR(mutex_intr, &lock);
+ if (rc)
return rc;
po = mds->poison.list_out;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] cxl: remove assignment from if condition in cxl_mem_get_poison
2025-08-13 11:55 [PATCH] cxl: remove assignment from if condition in cxl_mem_get_poison darshanrathod475
@ 2025-08-13 12:52 ` Jonathan Cameron
2025-08-13 13:07 ` Darshan Rathod
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2025-08-13 12:52 UTC (permalink / raw)
To: darshanrathod475
Cc: dave, dave.jiang, alison.schofield, vishal.l.verma, ira.weiny,
dan.j.williams, shiju.jose, ming.li, peterz, linux-cxl,
linux-kernel
On Wed, 13 Aug 2025 17:25:54 +0530
darshanrathod475@gmail.com wrote:
> From: Darshan Rathod <darshanrathod475@gmail.com>
>
> Refactor cxl_mem_get_poison() to assign the return value of
> ACQUIRE_ERR() before the conditional check, instead of performing the
> assignment inside the if condition. This resolves a checkpatch.pl
> warning ("do not use assignment in if condition") and improves
> readability.
>
> Signed-off-by: Darshan Rathod <darshanrathod475@gmail.com>
See:
https://lore.kernel.org/all/20250813003821.2891532-1-alison.schofield@intel.com/
Which stops checkpatch complaining about this.
Let's see where that discussion ends up before considering 'fixing' this.
Jonathan
> ---
> drivers/cxl/core/mbox.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> index fa6dd0c94656..9c5066631896 100644
> --- a/drivers/cxl/core/mbox.c
> +++ b/drivers/cxl/core/mbox.c
> @@ -1426,7 +1426,9 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
> int rc;
>
> ACQUIRE(mutex_intr, lock)(&mds->poison.mutex);
> - if ((rc = ACQUIRE_ERR(mutex_intr, &lock)))
> +
> + rc = ACQUIRE_ERR(mutex_intr, &lock);
> + if (rc)
> return rc;
>
> po = mds->poison.list_out;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] cxl: remove assignment from if condition in cxl_mem_get_poison
2025-08-13 12:52 ` Jonathan Cameron
@ 2025-08-13 13:07 ` Darshan Rathod
0 siblings, 0 replies; 3+ messages in thread
From: Darshan Rathod @ 2025-08-13 13:07 UTC (permalink / raw)
To: Jonathan Cameron
Cc: dave, dave.jiang, alison.schofield, vishal.l.verma, ira.weiny,
dan.j.williams, shiju.jose, ming.li, peterz, linux-cxl,
linux-kernel
Hi Jonathan,
Thanks for pointing that out.
I’ll hold off on this change and wait for the outcome of Alison’s
patch discussion before proceeding further.
Regards,
Darshan
On Wed, Aug 13, 2025 at 6:22 PM Jonathan Cameron
<Jonathan.Cameron@huawei.com> wrote:
>
> On Wed, 13 Aug 2025 17:25:54 +0530
> darshanrathod475@gmail.com wrote:
>
> > From: Darshan Rathod <darshanrathod475@gmail.com>
> >
> > Refactor cxl_mem_get_poison() to assign the return value of
> > ACQUIRE_ERR() before the conditional check, instead of performing the
> > assignment inside the if condition. This resolves a checkpatch.pl
> > warning ("do not use assignment in if condition") and improves
> > readability.
> >
> > Signed-off-by: Darshan Rathod <darshanrathod475@gmail.com>
> See:
> https://lore.kernel.org/all/20250813003821.2891532-1-alison.schofield@intel.com/
>
> Which stops checkpatch complaining about this.
> Let's see where that discussion ends up before considering 'fixing' this.
>
> Jonathan
>
> > ---
> > drivers/cxl/core/mbox.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/cxl/core/mbox.c b/drivers/cxl/core/mbox.c
> > index fa6dd0c94656..9c5066631896 100644
> > --- a/drivers/cxl/core/mbox.c
> > +++ b/drivers/cxl/core/mbox.c
> > @@ -1426,7 +1426,9 @@ int cxl_mem_get_poison(struct cxl_memdev *cxlmd, u64 offset, u64 len,
> > int rc;
> >
> > ACQUIRE(mutex_intr, lock)(&mds->poison.mutex);
> > - if ((rc = ACQUIRE_ERR(mutex_intr, &lock)))
> > +
> > + rc = ACQUIRE_ERR(mutex_intr, &lock);
> > + if (rc)
> > return rc;
> >
> > po = mds->poison.list_out;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-13 13:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13 11:55 [PATCH] cxl: remove assignment from if condition in cxl_mem_get_poison darshanrathod475
2025-08-13 12:52 ` Jonathan Cameron
2025-08-13 13:07 ` Darshan Rathod
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).