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