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