Skip to content

Commit a58afda

Browse files
MingLi-4davejiang
authored andcommitted
cxl/memdev: cxl_memdev_ioctl() cleanup
In cxl_memdev_ioctl(), the down_read(&cxl_memdev_rwsem) and up_read(&cxl_memdev_rwsem) can be replaced by a guard(rwsem_read)(&cxl_memdev_rwsem), it helps to remove the open-coded up_read(&cxl_memdev_rwsem). Besides, the local var 'rc' can be also removed to make the code more cleaner. 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-4-ming.li@zohomail.com Signed-off-by: Dave Jiang <dave.jiang@intel.com>
1 parent 3ad4f59 commit a58afda

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

drivers/cxl/core/memdev.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -668,15 +668,13 @@ static long cxl_memdev_ioctl(struct file *file, unsigned int cmd,
668668
{
669669
struct cxl_memdev *cxlmd = file->private_data;
670670
struct cxl_dev_state *cxlds;
671-
int rc = -ENXIO;
672671

673-
down_read(&cxl_memdev_rwsem);
672+
guard(rwsem_read)(&cxl_memdev_rwsem);
674673
cxlds = cxlmd->cxlds;
675674
if (cxlds && cxlds->type == CXL_DEVTYPE_CLASSMEM)
676-
rc = __cxl_memdev_ioctl(cxlmd, cmd, arg);
677-
up_read(&cxl_memdev_rwsem);
675+
return __cxl_memdev_ioctl(cxlmd, cmd, arg);
678676

679-
return rc;
677+
return -ENXIO;
680678
}
681679

682680
static int cxl_memdev_open(struct inode *inode, struct file *file)

0 commit comments

Comments
 (0)