diff mbox series

[v7,2/2] cxl/region: Remove else after return statement

Message ID 20230726073421.2452-3-raghuhack78@gmail.com
State Accepted
Commit 11dcd3b6a3aac1cace09f35407a47a311fdb0259
Headers show
Series Fixing check patch styling issues | expand

Commit Message

Raghu Halharvi July 26, 2023, 7:34 a.m. UTC
Issue found with checkpatch

The else section here is redundant after return statement, removing it.
Sanity and correctness is not affected due to this fix.

Signed-off-by: Raghu Halharvi <raghuhack78@gmail.com>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
---
 drivers/cxl/core/region.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Alison Schofield July 30, 2023, 2:18 a.m. UTC | #1
On Wed, Jul 26, 2023 at 07:34:21AM +0000, Raghu Halharvi wrote:
> Issue found with checkpatch
> 
> The else section here is redundant after return statement, removing it.
> Sanity and correctness is not affected due to this fix.
> 
> Signed-off-by: Raghu Halharvi <raghuhack78@gmail.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
> Reviewed-by: Ira Weiny <ira.weiny@intel.com>

Reviewed-by: Alison Schofield <alison.schofield@intel.com>



> ---
>  drivers/cxl/core/region.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> index e115ba382e04..bfd3b13dd2c1 100644
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
> @@ -133,11 +133,11 @@ 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.39.2
>
Joe Perches July 30, 2023, 8:09 p.m. UTC | #2
On Sat, 2023-07-29 at 19:18 -0700, Alison Schofield wrote:
> On Wed, Jul 26, 2023 at 07:34:21AM +0000, Raghu Halharvi wrote:
> > Issue found with checkpatch
> > 
> > The else section here is redundant after return statement, removing it.
> > Sanity and correctness is not affected due to this fix.
> > 
> > Signed-off-by: Raghu Halharvi <raghuhack78@gmail.com>
> > Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> > Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
> > Reviewed-by: Ira Weiny <ira.weiny@intel.com>
> 
> Reviewed-by: Alison Schofield <alison.schofield@intel.com>
> 
> 
> 
> > ---
> >  drivers/cxl/core/region.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> > index e115ba382e04..bfd3b13dd2c1 100644
> > --- a/drivers/cxl/core/region.c
> > +++ b/drivers/cxl/core/region.c
> > @@ -133,11 +133,11 @@ 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.39.2
> > 

My preference would be for this function to be something like:
---
static int cxl_region_invalidate_memregion(struct cxl_region *cxlr)
{
	if (cpu_cache_has_invalidate_memregion()) {
		cpu_cache_invalidate_memregion(IORES_DESC_CXL);
		return 0;
	}

	if (IS_ENABLED(CONFIG_CXL_REGION_INVALIDATION_TEST)) {
		dev_warn_once(&cxlr->dev,
			      "Bypassing cpu_cache_invalidate_memregion() for testing!\n");
		return 0;
	}

	dev_err(&cxlr->dev, "Failed to synchronize CPU cache state\n");
	return -ENXIO;
}
diff mbox series

Patch

diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
index e115ba382e04..bfd3b13dd2c1 100644
--- a/drivers/cxl/core/region.c
+++ b/drivers/cxl/core/region.c
@@ -133,11 +133,11 @@  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);