Blame SOURCES/0093-cxl-list-Support-comma-separated-lists.patch

26ccd9
From a36b8b815d2e8bfd8438b44d4775bdf3ffc3a6d8 Mon Sep 17 00:00:00 2001
26ccd9
From: Dan Williams <dan.j.williams@intel.com>
26ccd9
Date: Sun, 23 Jan 2022 16:52:26 -0800
26ccd9
Subject: [PATCH 093/217] cxl/list: Support comma separated lists
26ccd9
26ccd9
In addition to supporting a syntax like:
26ccd9
26ccd9
   cxl list -m "0 1 2"
26ccd9
26ccd9
...support:
26ccd9
26ccd9
   cxl list -m 0,1,2
26ccd9
26ccd9
Link: https://lore.kernel.org/r/164298554612.3021641.3315920699556984273.stgit@dwillia2-desk3.amr.corp.intel.com
26ccd9
Reported-by: Vishal Verma <vishal.l.verma@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/filter.c | 13 +++++++++++--
26ccd9
 1 file changed, 11 insertions(+), 2 deletions(-)
26ccd9
26ccd9
diff --git a/cxl/filter.c b/cxl/filter.c
26ccd9
index efafaf5..405b653 100644
26ccd9
--- a/cxl/filter.c
26ccd9
+++ b/cxl/filter.c
26ccd9
@@ -6,6 +6,15 @@
26ccd9
 #include <cxl/libcxl.h>
26ccd9
 #include "filter.h"
26ccd9
 
26ccd9
+static const char *which_sep(const char *filter)
26ccd9
+{
26ccd9
+	if (strchr(filter, ' '))
26ccd9
+		return " ";
26ccd9
+	if (strchr(filter, ','))
26ccd9
+		return ",";
26ccd9
+	return " ";
26ccd9
+}
26ccd9
+
26ccd9
 struct cxl_memdev *util_cxl_memdev_filter(struct cxl_memdev *memdev,
26ccd9
 					  const char *__ident)
26ccd9
 {
26ccd9
@@ -20,8 +29,8 @@ struct cxl_memdev *util_cxl_memdev_filter(struct cxl_memdev *memdev,
26ccd9
 	if (!ident)
26ccd9
 		return NULL;
26ccd9
 
26ccd9
-	for (name = strtok_r(ident, " ", &save); name;
26ccd9
-	     name = strtok_r(NULL, " ", &save)) {
26ccd9
+	for (name = strtok_r(ident, which_sep(__ident), &save); name;
26ccd9
+	     name = strtok_r(NULL, which_sep(__ident), &save)) {
26ccd9
 		if (strcmp(name, "all") == 0)
26ccd9
 			break;
26ccd9
 
26ccd9
-- 
26ccd9
2.27.0
26ccd9