linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cxl/region: use str_enabled_disabled() instead of tenary operator
@ 2025-08-11 16:49 Nai-Chen Cheng
  2025-08-12  0:08 ` Alison Schofield
  2025-08-13  0:02 ` Dave Jiang
  0 siblings, 2 replies; 4+ messages in thread
From: Nai-Chen Cheng @ 2025-08-11 16:49 UTC (permalink / raw)
  To: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Alison Schofield,
	Vishal Verma, Ira Weiny, Dan Williams
  Cc: linux-cxl, linux-kernel, linux-kernel-mentees, Nai-Chen Cheng

Replace tenary operator with str_enabled_disabled() helper to enhance
code readability and consistency.

Signed-off-by: Nai-Chen Cheng <bleach1827@gmail.com>
---
 drivers/cxl/core/region.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index 71cc42d05248..83d58787b5af 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -10,6 +10,7 @@
 #include <linux/sort.h>
 #include <linux/idr.h>
 #include <linux/memory-tiers.h>
+#include <linux/string_choices.h>
 #include <cxlmem.h>
 #include <cxl.h>
 #include "core.h"
@@ -1468,9 +1469,7 @@ static int cxl_port_setup_targets(struct cxl_port *port,
 				dev_name(port->uport_dev), dev_name(&port->dev),
 				__func__, cxld->interleave_ways,
 				cxld->interleave_granularity,
-				(cxld->flags & CXL_DECODER_F_ENABLE) ?
-					"enabled" :
-					"disabled",
+				str_enabled_disabled(cxld->flags & CXL_DECODER_F_ENABLE),
 				cxld->hpa_range.start, cxld->hpa_range.end);
 			return -ENXIO;
 		}

---
base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
change-id: 20250812-cxl-region-string-choices-f5aa9832346e

Best regards,
-- 
Nai-Chen Cheng <bleach1827@gmail.com>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] cxl/region: use str_enabled_disabled() instead of tenary operator
  2025-08-11 16:49 [PATCH] cxl/region: use str_enabled_disabled() instead of tenary operator Nai-Chen Cheng
@ 2025-08-12  0:08 ` Alison Schofield
  2025-08-12  0:10   ` Alison Schofield
  2025-08-13  0:02 ` Dave Jiang
  1 sibling, 1 reply; 4+ messages in thread
From: Alison Schofield @ 2025-08-12  0:08 UTC (permalink / raw)
  To: Nai-Chen Cheng
  Cc: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Vishal Verma,
	Ira Weiny, Dan Williams, linux-cxl, linux-kernel,
	linux-kernel-mentees

On Tue, Aug 12, 2025 at 12:49:46AM +0800, Nai-Chen Cheng wrote:
> Replace tenary operator with str_enabled_disabled() helper to enhance
> code readability and consistency.
> 
> Signed-off-by: Nai-Chen Cheng <bleach1827@gmail.com>
> ---

Thanks for the patch!

DaveJ - Please fix-up the spelling when you apply s/tenary/ternary in
both commit message and log. With that, add:
Reviewed-by: Alison Schofield <alison.schofield@intel.com>

Nai-Chen Cheng - If you're able to pick up a related cleanup, I believe
drivers/cxl/core/hdm.c has a place where str_plural() could be used.

-- Alison


>  drivers/cxl/core/region.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 71cc42d05248..83d58787b5af 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -10,6 +10,7 @@
>  #include <linux/sort.h>
>  #include <linux/idr.h>
>  #include <linux/memory-tiers.h>
> +#include <linux/string_choices.h>
>  #include <cxlmem.h>
>  #include <cxl.h>
>  #include "core.h"
> @@ -1468,9 +1469,7 @@ static int cxl_port_setup_targets(struct cxl_port *port,
>  				dev_name(port->uport_dev), dev_name(&port->dev),
>  				__func__, cxld->interleave_ways,
>  				cxld->interleave_granularity,
> -				(cxld->flags & CXL_DECODER_F_ENABLE) ?
> -					"enabled" :
> -					"disabled",
> +				str_enabled_disabled(cxld->flags & CXL_DECODER_F_ENABLE),
>  				cxld->hpa_range.start, cxld->hpa_range.end);
>  			return -ENXIO;
>  		}
> 
> ---
> base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
> change-id: 20250812-cxl-region-string-choices-f5aa9832346e
> 
> Best regards,
> -- 
> Nai-Chen Cheng <bleach1827@gmail.com>
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cxl/region: use str_enabled_disabled() instead of tenary operator
  2025-08-12  0:08 ` Alison Schofield
@ 2025-08-12  0:10   ` Alison Schofield
  0 siblings, 0 replies; 4+ messages in thread
From: Alison Schofield @ 2025-08-12  0:10 UTC (permalink / raw)
  To: Nai-Chen Cheng
  Cc: Davidlohr Bueso, Jonathan Cameron, Dave Jiang, Vishal Verma,
	Ira Weiny, Dan Williams, linux-cxl, linux-kernel,
	linux-kernel-mentees

On Mon, Aug 11, 2025 at 05:08:13PM -0700, Alison Schofield wrote:
> On Tue, Aug 12, 2025 at 12:49:46AM +0800, Nai-Chen Cheng wrote:
> > Replace tenary operator with str_enabled_disabled() helper to enhance
> > code readability and consistency.
> > 
> > Signed-off-by: Nai-Chen Cheng <bleach1827@gmail.com>
> > ---
> 
> Thanks for the patch!
> 
> DaveJ - Please fix-up the spelling when you apply s/tenary/ternary in
> both commit message and log. With that, add:
> Reviewed-by: Alison Schofield <alison.schofield@intel.com>
> 
> Nai-Chen Cheng - If you're able to pick up a related cleanup, I believe
> drivers/cxl/core/hdm.c has a place where str_plural() could be used.
Oops...I guess I should read these in FIFO order. I see str_plural()
already on the list :)

> 
> -- Alison
> 
> 
> >  drivers/cxl/core/region.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> > index 71cc42d05248..83d58787b5af 100644
> > --- a/drivers/cxl/core/region.c
> > +++ b/drivers/cxl/core/region.c
> > @@ -10,6 +10,7 @@
> >  #include <linux/sort.h>
> >  #include <linux/idr.h>
> >  #include <linux/memory-tiers.h>
> > +#include <linux/string_choices.h>
> >  #include <cxlmem.h>
> >  #include <cxl.h>
> >  #include "core.h"
> > @@ -1468,9 +1469,7 @@ static int cxl_port_setup_targets(struct cxl_port *port,
> >  				dev_name(port->uport_dev), dev_name(&port->dev),
> >  				__func__, cxld->interleave_ways,
> >  				cxld->interleave_granularity,
> > -				(cxld->flags & CXL_DECODER_F_ENABLE) ?
> > -					"enabled" :
> > -					"disabled",
> > +				str_enabled_disabled(cxld->flags & CXL_DECODER_F_ENABLE),
> >  				cxld->hpa_range.start, cxld->hpa_range.end);
> >  			return -ENXIO;
> >  		}
> > 
> > ---
> > base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
> > change-id: 20250812-cxl-region-string-choices-f5aa9832346e
> > 
> > Best regards,
> > -- 
> > Nai-Chen Cheng <bleach1827@gmail.com>
> > 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] cxl/region: use str_enabled_disabled() instead of tenary operator
  2025-08-11 16:49 [PATCH] cxl/region: use str_enabled_disabled() instead of tenary operator Nai-Chen Cheng
  2025-08-12  0:08 ` Alison Schofield
@ 2025-08-13  0:02 ` Dave Jiang
  1 sibling, 0 replies; 4+ messages in thread
From: Dave Jiang @ 2025-08-13  0:02 UTC (permalink / raw)
  To: Nai-Chen Cheng, Davidlohr Bueso, Jonathan Cameron,
	Alison Schofield, Vishal Verma, Ira Weiny, Dan Williams
  Cc: linux-cxl, linux-kernel, linux-kernel-mentees



On 8/11/25 9:49 AM, Nai-Chen Cheng wrote:
> Replace tenary operator with str_enabled_disabled() helper to enhance
> code readability and consistency.
> 
> Signed-off-by: Nai-Chen Cheng <bleach1827@gmail.com>

Applied to cxl/next. Spelling mistakes noted by Alison fixed.
733c4e9bcec9

> ---
>  drivers/cxl/core/region.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index 71cc42d05248..83d58787b5af 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -10,6 +10,7 @@
>  #include <linux/sort.h>
>  #include <linux/idr.h>
>  #include <linux/memory-tiers.h>
> +#include <linux/string_choices.h>
>  #include <cxlmem.h>
>  #include <cxl.h>
>  #include "core.h"
> @@ -1468,9 +1469,7 @@ static int cxl_port_setup_targets(struct cxl_port *port,
>  				dev_name(port->uport_dev), dev_name(&port->dev),
>  				__func__, cxld->interleave_ways,
>  				cxld->interleave_granularity,
> -				(cxld->flags & CXL_DECODER_F_ENABLE) ?
> -					"enabled" :
> -					"disabled",
> +				str_enabled_disabled(cxld->flags & CXL_DECODER_F_ENABLE),
>  				cxld->hpa_range.start, cxld->hpa_range.end);
>  			return -ENXIO;
>  		}
> 
> ---
> base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
> change-id: 20250812-cxl-region-string-choices-f5aa9832346e
> 
> Best regards,


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-08-13  0:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-11 16:49 [PATCH] cxl/region: use str_enabled_disabled() instead of tenary operator Nai-Chen Cheng
2025-08-12  0:08 ` Alison Schofield
2025-08-12  0:10   ` Alison Schofield
2025-08-13  0:02 ` Dave Jiang

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).