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

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