diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2018-05-04 10:42:16 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2018-05-07 12:27:26 -0400 |
commit | cc659e76f375ab158fb682c1e39b2a22bf9f7657 (patch) | |
tree | 421a281bb718cd1026f3b267dc98247d4684709f /kernel/cgroup | |
parent | c43c5ea75fd53cae3c8b63e1a27efc4cff6508d3 (diff) |
rdmacg: Convert to use match_string() helper
The new helper returns index of the matching string in an array.
We are going to use it here.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/cgroup')
-rw-r--r-- | kernel/cgroup/rdma.c | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/kernel/cgroup/rdma.c b/kernel/cgroup/rdma.c index defad3c5e7dc..d3bbb757ee49 100644 --- a/kernel/cgroup/rdma.c +++ b/kernel/cgroup/rdma.c | |||
@@ -362,35 +362,32 @@ EXPORT_SYMBOL(rdmacg_unregister_device); | |||
362 | static int parse_resource(char *c, int *intval) | 362 | static int parse_resource(char *c, int *intval) |
363 | { | 363 | { |
364 | substring_t argstr; | 364 | substring_t argstr; |
365 | const char **table = &rdmacg_resource_names[0]; | ||
366 | char *name, *value = c; | 365 | char *name, *value = c; |
367 | size_t len; | 366 | size_t len; |
368 | int ret, i = 0; | 367 | int ret, i; |
369 | 368 | ||
370 | name = strsep(&value, "="); | 369 | name = strsep(&value, "="); |
371 | if (!name || !value) | 370 | if (!name || !value) |
372 | return -EINVAL; | 371 | return -EINVAL; |
373 | 372 | ||
374 | len = strlen(value); | 373 | i = match_string(rdmacg_resource_names, RDMACG_RESOURCE_MAX, name); |
374 | if (i < 0) | ||
375 | return i; | ||
375 | 376 | ||
376 | for (i = 0; i < RDMACG_RESOURCE_MAX; i++) { | 377 | len = strlen(value); |
377 | if (strcmp(table[i], name)) | ||
378 | continue; | ||
379 | 378 | ||
380 | argstr.from = value; | 379 | argstr.from = value; |
381 | argstr.to = value + len; | 380 | argstr.to = value + len; |
382 | 381 | ||
383 | ret = match_int(&argstr, intval); | 382 | ret = match_int(&argstr, intval); |
384 | if (ret >= 0) { | 383 | if (ret >= 0) { |
385 | if (*intval < 0) | 384 | if (*intval < 0) |
386 | break; | 385 | return -EINVAL; |
387 | return i; | 386 | return i; |
388 | } | 387 | } |
389 | if (strncmp(value, RDMACG_MAX_STR, len) == 0) { | 388 | if (strncmp(value, RDMACG_MAX_STR, len) == 0) { |
390 | *intval = S32_MAX; | 389 | *intval = S32_MAX; |
391 | return i; | 390 | return i; |
392 | } | ||
393 | break; | ||
394 | } | 391 | } |
395 | return -EINVAL; | 392 | return -EINVAL; |
396 | } | 393 | } |