Skip to content

Commit 3ad4f59

Browse files
MingLi-4davejiang
authored andcommitted
cxl/core: cxl_mem_sanitize() cleanup
In cxl_mem_sanitize(), the down_read() and up_read() for cxl_region_rwsem can be simply replaced by a guard(rwsem_read), and the local variable 'rc' can be removed. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Reviewed-by: Alison Schofield <alison.schofield@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Acked-by: Davidlohr Bueso <dave@stgolabs.net> Signed-off-by: Li Ming <ming.li@zohomail.com> Link: https://patch.msgid.link/20250221012453.126366-3-ming.li@zohomail.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent eeba747 commit 3ad4f59

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

drivers/cxl/core/mbox.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,23 +1222,19 @@ int cxl_mem_sanitize(struct cxl_memdev *cxlmd, u16 cmd)
12221222
{
12231223
struct cxl_memdev_state *mds = to_cxl_memdev_state(cxlmd->cxlds);
12241224
struct cxl_port *endpoint;
1225-
int rc;
12261225

12271226
/* synchronize with cxl_mem_probe() and decoder write operations */
12281227
guard(device)(&cxlmd->dev);
12291228
endpoint = cxlmd->endpoint;
1230-
down_read(&cxl_region_rwsem);
1229+
guard(rwsem_read)(&cxl_region_rwsem);
12311230
/*
12321231
* Require an endpoint to be safe otherwise the driver can not
12331232
* be sure that the device is unmapped.
12341233
*/
12351234
if (endpoint && cxl_num_decoders_committed(endpoint) == 0)
1236-
rc = __cxl_mem_sanitize(mds, cmd);
1237-
else
1238-
rc = -EBUSY;
1239-
up_read(&cxl_region_rwsem);
1235+
return __cxl_mem_sanitize(mds, cmd);
12401236

1241-
return rc;
1237+
return -EBUSY;
12421238
}
12431239

12441240
static int add_dpa_res(struct device *dev, struct resource *parent,

0 commit comments

Comments
 (0)