cxl: Remove else after return
authorRobert Richter <rrichter@amd.com>
Fri, 9 May 2025 15:06:46 +0000 (17:06 +0200)
committerDave Jiang <dave.jiang@intel.com>
Fri, 9 May 2025 16:48:25 +0000 (09:48 -0700)
Remove unnecessary 'else' after return. Improves readability of code.
It is easier to place comments. Check and fix all occurrences under
drivers/cxl/.

Signed-off-by: Robert Richter <rrichter@amd.com>
Reviewed-by: Gregory Price <gourry@gourry.net>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Davidlohr Bueso <dave@stgolabs.net>
Reviewed-by: Alison Schofield <alison.schofield@intel.com>
Reviewed-by: "Fabio M. De Francesco" <fabio.m.de.francesco@linux.intel.com>
Tested-by: Gregory Price <gourry@gourry.net>
Acked-by: Dan Williams <dan.j.williams@intel.com>
Link: https://patch.msgid.link/20250509150700.2817697-2-rrichter@amd.com
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
drivers/cxl/core/cdat.c
drivers/cxl/core/memdev.c
drivers/cxl/core/pci.c
drivers/cxl/core/region.c

index edb4f41eeacc64fa359b4e1c46909f247383c101..0ccef2f2a26aa13cb205cb817faa335c8307389e 100644 (file)
@@ -28,7 +28,7 @@ static u32 cdat_normalize(u16 entry, u64 base, u8 type)
         */
        if (entry == 0xffff || !entry)
                return 0;
-       else if (base > (UINT_MAX / (entry)))
+       if (base > (UINT_MAX / (entry)))
                return 0;
 
        /*
index a16a5886d40a7fe0f47c361255d20eb62d8a4d11..ca9e38b222c8d5587f9fdd5e0573f3b0a5ea784f 100644 (file)
@@ -153,8 +153,8 @@ static ssize_t security_state_show(struct device *dev,
                return sysfs_emit(buf, "frozen\n");
        if (state & CXL_PMEM_SEC_STATE_LOCKED)
                return sysfs_emit(buf, "locked\n");
-       else
-               return sysfs_emit(buf, "unlocked\n");
+
+       return sysfs_emit(buf, "unlocked\n");
 }
 static struct device_attribute dev_attr_security_state =
        __ATTR(state, 0444, security_state_show, NULL);
index 3b80e9a76ba862c25d1387d168e2fb3d3cfb16c7..71bfa3bbe43658a42f04ceff0a097184a39f96b2 100644 (file)
@@ -415,7 +415,8 @@ int cxl_hdm_decode_init(struct cxl_dev_state *cxlds, struct cxl_hdm *cxlhdm,
         */
        if (global_ctrl & CXL_HDM_DECODER_ENABLE || (!hdm && info->mem_enabled))
                return devm_cxl_enable_mem(&port->dev, cxlds);
-       else if (!hdm)
+
+       if (!hdm)
                return -ENODEV;
 
        root = to_cxl_port(port->dev.parent);
index c3f4dc244df77bb7bd48d3828ceece0c7cb2e3f2..f67fbb3c9e226243ef3f0b68850ccfbe5ec1ba87 100644 (file)
@@ -231,11 +231,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_WARN(&cxlr->dev,
-                                "Failed to synchronize CPU cache state\n");
-                       return -ENXIO;
                }
+               dev_WARN(&cxlr->dev,
+                       "Failed to synchronize CPU cache state\n");
+               return -ENXIO;
        }
 
        cpu_cache_invalidate_memregion(IORES_DESC_CXL);
@@ -1940,7 +1939,9 @@ static int cxl_region_attach(struct cxl_region *cxlr,
        if (p->state > CXL_CONFIG_INTERLEAVE_ACTIVE) {
                dev_dbg(&cxlr->dev, "region already active\n");
                return -EBUSY;
-       } else if (p->state < CXL_CONFIG_INTERLEAVE_ACTIVE) {
+       }
+
+       if (p->state < CXL_CONFIG_INTERLEAVE_ACTIVE) {
                dev_dbg(&cxlr->dev, "interleave config missing\n");
                return -ENXIO;
        }