Blame SOURCES/0111-cxl-memdev-Cleanup-memdev-filter.patch

2eb93d
From 6cab8e0186e73af75f0a15ce87c4db20ef0089df Mon Sep 17 00:00:00 2001
2eb93d
From: Dan Williams <dan.j.williams@intel.com>
2eb93d
Date: Sun, 23 Jan 2022 16:54:01 -0800
2eb93d
Subject: [PATCH 111/217] cxl/memdev: Cleanup memdev filter
2eb93d
2eb93d
util_cxl_memdev_filter() already handles the difference between 'mem%d',
2eb93d
'%d', and 'all' for the identifier format. Drop the duplicate / incomplete
2eb93d
format checking.
2eb93d
2eb93d
If the checking for bad formats was dropped too then this command could
2eb93d
support "0,1,2" syntax in addition to "0 1 2" like 'cxl list'. However, it is
2eb93d
not clear that's worthwhile since 'list' is ok to be imprecise, but memdev
2eb93d
commands need to be stricter.
2eb93d
2eb93d
Link: https://lore.kernel.org/r/164298564100.3021641.9410483964085163708.stgit@dwillia2-desk3.amr.corp.intel.com
2eb93d
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2eb93d
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
2eb93d
---
2eb93d
 cxl/memdev.c | 18 +++++++-----------
2eb93d
 1 file changed, 7 insertions(+), 11 deletions(-)
2eb93d
2eb93d
diff --git a/cxl/memdev.c b/cxl/memdev.c
2eb93d
index 327c260..4cca8b8 100644
2eb93d
--- a/cxl/memdev.c
2eb93d
+++ b/cxl/memdev.c
2eb93d
@@ -191,16 +191,16 @@ static int memdev_action(int argc, const char **argv, struct cxl_ctx *ctx,
2eb93d
 		usage_with_options(u, options);
2eb93d
 	for (i = 0; i < argc; i++) {
2eb93d
 		if (strcmp(argv[i], "all") == 0) {
2eb93d
-			argv[0] = "all";
2eb93d
 			argc = 1;
2eb93d
 			break;
2eb93d
 		}
2eb93d
+		if (sscanf(argv[i], "mem%lu", &id) == 1)
2eb93d
+			continue;
2eb93d
+		if (sscanf(argv[i], "%lu", &id) == 1)
2eb93d
+			continue;
2eb93d
 
2eb93d
-		if (sscanf(argv[i], "mem%lu", &id) != 1) {
2eb93d
-			log_err(&ml, "'%s' is not a valid memdev name\n",
2eb93d
-				argv[i]);
2eb93d
-			err++;
2eb93d
-		}
2eb93d
+		log_err(&ml, "'%s' is not a valid memdev name\n", argv[i]);
2eb93d
+		err++;
2eb93d
 	}
2eb93d
 
2eb93d
 	if (err == argc) {
2eb93d
@@ -243,11 +243,7 @@ static int memdev_action(int argc, const char **argv, struct cxl_ctx *ctx,
2eb93d
 	count = 0;
2eb93d
 
2eb93d
 	for (i = 0; i < argc; i++) {
2eb93d
-		if (sscanf(argv[i], "mem%lu", &id) != 1
2eb93d
-				&& strcmp(argv[i], "all") != 0)
2eb93d
-			continue;
2eb93d
-
2eb93d
-		cxl_memdev_foreach (ctx, memdev) {
2eb93d
+		cxl_memdev_foreach(ctx, memdev) {
2eb93d
 			if (!util_cxl_memdev_filter(memdev, argv[i], NULL))
2eb93d
 				continue;
2eb93d
 
2eb93d
-- 
2eb93d
2.27.0
2eb93d