aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2022-01-23 16:54:01 -0800
committerVishal Verma <vishal.l.verma@intel.com>2022-01-26 14:37:53 -0700
commit6cab8e0186e73af75f0a15ce87c4db20ef0089df (patch)
tree2617288fa9b3f6249dcc3985ca15c72476624324
parent5e1c1ab5bf6b6257552ad9fa242483ec1c1de006 (diff)
cxl/memdev: Cleanup memdev filter
util_cxl_memdev_filter() already handles the difference between 'mem%d', '%d', and 'all' for the identifier format. Drop the duplicate / incomplete format checking. If the checking for bad formats was dropped too then this command could support "0,1,2" syntax in addition to "0 1 2" like 'cxl list'. However, it is not clear that's worthwhile since 'list' is ok to be imprecise, but memdev commands need to be stricter. Link: https://lore.kernel.org/r/164298564100.3021641.9410483964085163708.stgit@dwillia2-desk3.amr.corp.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/memdev.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/cxl/memdev.c b/cxl/memdev.c
index 327c2608..4cca8b8c 100644
--- a/cxl/memdev.c
+++ b/cxl/memdev.c
@@ -191,16 +191,16 @@ static int memdev_action(int argc, const char **argv, struct cxl_ctx *ctx,
usage_with_options(u, options);
for (i = 0; i < argc; i++) {
if (strcmp(argv[i], "all") == 0) {
- argv[0] = "all";
argc = 1;
break;
}
+ if (sscanf(argv[i], "mem%lu", &id) == 1)
+ continue;
+ if (sscanf(argv[i], "%lu", &id) == 1)
+ continue;
- if (sscanf(argv[i], "mem%lu", &id) != 1) {
- log_err(&ml, "'%s' is not a valid memdev name\n",
- argv[i]);
- err++;
- }
+ log_err(&ml, "'%s' is not a valid memdev name\n", argv[i]);
+ err++;
}
if (err == argc) {
@@ -243,11 +243,7 @@ static int memdev_action(int argc, const char **argv, struct cxl_ctx *ctx,
count = 0;
for (i = 0; i < argc; i++) {
- if (sscanf(argv[i], "mem%lu", &id) != 1
- && strcmp(argv[i], "all") != 0)
- continue;
-
- cxl_memdev_foreach (ctx, memdev) {
+ cxl_memdev_foreach(ctx, memdev) {
if (!util_cxl_memdev_filter(memdev, argv[i], NULL))
continue;