All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 2/7] cxl/region: Fix a checkpatch warning
       [not found] <CGME20230922113233epcas2p2cd57df10dde36b0da3b2fc5a916132e8@epcas2p2.samsung.com>
@ 2023-09-22 11:35 ` Jeongtae Park
  2023-09-25 10:07   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Jeongtae Park @ 2023-09-22 11:35 UTC (permalink / raw)
  To: Dan Williams, Alison Schofield, Vishal Verma, Ben Widawsky,
	Jonathan Cameron, Dave Jiang, Davidlohr Bueso, Fan Ni, linux-cxl
  Cc: linux-kernel, Greg Kroah-Hartman, Kyungsan Kim, Wonjae Lee,
	Hojin Nam, Junhyeok Im, Jehoon Park, Jeongtae Park,
	Jeongtae Park

WARNING: else is not generally useful after a break or return

Signed-off-by: Jeongtae Park <jtp.park@samsung.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
---
 drivers/cxl/core/region.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index e115ba382e04..1fc9d01c1ac0 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -133,11 +133,10 @@ static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)
 				&cxlr->dev,
 				"Bypassing cpu_cache_invalidate_memregion() for testing!\n");
 			return 0;
-		} else {
-			dev_err(&cxlr->dev,
-				"Failed to synchronize CPU cache state\n");
-			return -ENXIO;
 		}
+
+		dev_err(&cxlr->dev, "Failed to synchronize CPU cache state\n");
+		return -ENXIO;
 	}
 
 	cpu_cache_invalidate_memregion(IORES_DESC_CXL);
-- 
2.34.1


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

* Re: [PATCH v2 2/7] cxl/region: Fix a checkpatch warning
  2023-09-22 11:35 ` [PATCH v2 2/7] cxl/region: Fix a checkpatch warning Jeongtae Park
@ 2023-09-25 10:07   ` Jonathan Cameron
  2023-10-05  8:08     ` Jeongtae Park
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2023-09-25 10:07 UTC (permalink / raw)
  To: Jeongtae Park
  Cc: Dan Williams, Alison Schofield, Vishal Verma, Ben Widawsky,
	Dave Jiang, Davidlohr Bueso, Fan Ni, linux-cxl, linux-kernel,
	Greg Kroah-Hartman, Kyungsan Kim, Wonjae Lee, Hojin Nam,
	Junhyeok Im, Jehoon Park, Jeongtae Park

On Fri, 22 Sep 2023 20:35:20 +0900
Jeongtae Park <jtp.park@samsung.com> wrote:

> WARNING: else is not generally useful after a break or return
> 
> Signed-off-by: Jeongtae Park <jtp.park@samsung.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>

This one is a little ugly. I'd prefer to see the error
condition remain out of line (vs the warning one)

		if (!IS_ENABLED(CONFIG_CXL_REGION_INVALIDATION_TEST)) {
			dev_err(&cxlr->dev,
				"Failed ...");
			return -ENOXIO
		}

		dev_warn_once(...

		return 0;

Or keep the else.

Not that important though as code is small enough that less
than ideal in / out of line doesn't matter that much to readability.

Jonathan


> ---
>  drivers/cxl/core/region.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index e115ba382e04..1fc9d01c1ac0 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -133,11 +133,10 @@ static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)
>  				&cxlr->dev,
>  				"Bypassing cpu_cache_invalidate_memregion() for testing!\n");
>  			return 0;
> -		} else {
> -			dev_err(&cxlr->dev,
> -				"Failed to synchronize CPU cache state\n");
> -			return -ENXIO;
>  		}
> +
> +		dev_err(&cxlr->dev, "Failed to synchronize CPU cache state\n");
> +		return -ENXIO;
>  	}
>  
>  	cpu_cache_invalidate_memregion(IORES_DESC_CXL);


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

* Re: [PATCH v2 2/7] cxl/region: Fix a checkpatch warning
  2023-09-25 10:07   ` Jonathan Cameron
@ 2023-10-05  8:08     ` Jeongtae Park
  0 siblings, 0 replies; 3+ messages in thread
From: Jeongtae Park @ 2023-10-05  8:08 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Dan Williams, Alison Schofield, Vishal Verma, Ben Widawsky,
	Dave Jiang, Davidlohr Bueso, Fan Ni, linux-cxl, linux-kernel,
	Greg Kroah-Hartman, Kyungsan Kim, Wonjae Lee, Hojin Nam,
	Junhyeok Im, Jehoon Park, Jeongtae Park

[-- Attachment #1: Type: text/plain, Size: 2374 bytes --]

On Mon, Sep 25, 2023 at 11:07:45AM +0100, Jonathan Cameron wrote:
> On Fri, 22 Sep 2023 20:35:20 +0900
> Jeongtae Park <jtp.park@samsung.com> wrote:
> 
> > WARNING: else is not generally useful after a break or return
> > 
> > Signed-off-by: Jeongtae Park <jtp.park@samsung.com>
> > Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> 
> This one is a little ugly. I'd prefer to see the error
> condition remain out of line (vs the warning one)
> 
> 		if (!IS_ENABLED(CONFIG_CXL_REGION_INVALIDATION_TEST)) {
> 			dev_err(&cxlr->dev,
> 				"Failed ...");
> 			return -ENOXIO
> 		}
> 
> 		dev_warn_once(...
> 
> 		return 0;
> 
> Or keep the else.

I think I changed it too mechanically ignoring the meanings.
Your comment made me think about it a bit more. If we don't
really need the error message to be printed every calling,
how about remove it and modify the condition statements like
below. It would make more efficient or small codes
when 'CONFIG_CXL_REGION_INVALIDATION_TEST' is not set.

static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)
{
        if (IS_ENABLED(CONFIG_CXL_REGION_INVALIDATION_TEST)
                        && cpu_cache_has_invalidate_memregion()) {
                dev_warn_once(&cxlr->dev,
                        "Bypassing cpu_cache_invalidate_memregion() for testing!\n");
                return 0;
        }

        return cpu_cache_invalidate_memregion(IORES_DESC_CXL);
}

> 
> Not that important though as code is small enough that less
> than ideal in / out of line doesn't matter that much to readability.
> 
> Jonathan
> 
> 
> > ---
> >  drivers/cxl/core/region.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> > index e115ba382e04..1fc9d01c1ac0 100644
> > --- a/drivers/cxl/core/region.c
> > +++ b/drivers/cxl/core/region.c
> > @@ -133,11 +133,10 @@ static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)
> >  				&cxlr->dev,
> >  				"Bypassing cpu_cache_invalidate_memregion() for testing!\n");
> >  			return 0;
> > -		} else {
> > -			dev_err(&cxlr->dev,
> > -				"Failed to synchronize CPU cache state\n");
> > -			return -ENXIO;
> >  		}
> > +
> > +		dev_err(&cxlr->dev, "Failed to synchronize CPU cache state\n");
> > +		return -ENXIO;
> >  	}
> >  
> >  	cpu_cache_invalidate_memregion(IORES_DESC_CXL);
> 

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



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

end of thread, other threads:[~2023-10-05 14:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20230922113233epcas2p2cd57df10dde36b0da3b2fc5a916132e8@epcas2p2.samsung.com>
2023-09-22 11:35 ` [PATCH v2 2/7] cxl/region: Fix a checkpatch warning Jeongtae Park
2023-09-25 10:07   ` Jonathan Cameron
2023-10-05  8:08     ` Jeongtae Park

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.