aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2022-01-23 16:52:26 -0800
committerVishal Verma <vishal.l.verma@intel.com>2022-01-26 14:37:53 -0700
commita36b8b815d2e8bfd8438b44d4775bdf3ffc3a6d8 (patch)
tree9a2a1317e7ecf80f13e65fc25d537e319299c56a
parent0ce0152d8e29f85325a3a59f94051228540abf6a (diff)
cxl/list: Support comma separated lists
In addition to supporting a syntax like: cxl list -m "0 1 2" ...support: cxl list -m 0,1,2 Link: https://lore.kernel.org/r/164298554612.3021641.3315920699556984273.stgit@dwillia2-desk3.amr.corp.intel.com Reported-by: Vishal Verma <vishal.l.verma@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
-rw-r--r--cxl/filter.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/cxl/filter.c b/cxl/filter.c
index efafaf5a..405b653d 100644
--- a/cxl/filter.c
+++ b/cxl/filter.c
@@ -6,6 +6,15 @@
#include <cxl/libcxl.h>
#include "filter.h"
+static const char *which_sep(const char *filter)
+{
+ if (strchr(filter, ' '))
+ return " ";
+ if (strchr(filter, ','))
+ return ",";
+ return " ";
+}
+
struct cxl_memdev *util_cxl_memdev_filter(struct cxl_memdev *memdev,
const char *__ident)
{
@@ -20,8 +29,8 @@ struct cxl_memdev *util_cxl_memdev_filter(struct cxl_memdev *memdev,
if (!ident)
return NULL;
- for (name = strtok_r(ident, " ", &save); name;
- name = strtok_r(NULL, " ", &save)) {
+ for (name = strtok_r(ident, which_sep(__ident), &save); name;
+ name = strtok_r(NULL, which_sep(__ident), &save)) {
if (strcmp(name, "all") == 0)
break;