LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH v2] rdmacg: Convert to use match_string() helper
@ 2018-05-04 14:42 Andy Shevchenko
2018-05-07 16:27 ` Tejun Heo
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2018-05-04 14:42 UTC (permalink / raw)
To: linux-kernel, Parav Pandit, Tejun Heo; +Cc: Andy Shevchenko
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>
---
- fix compile error
kernel/cgroup/rdma.c | 35 ++++++++++++++++-------------------
1 file 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);
static int parse_resource(char *c, int *intval)
{
substring_t argstr;
- const char **table = &rdmacg_resource_names[0];
char *name, *value = c;
size_t len;
- int ret, i = 0;
+ int ret, i;
name = strsep(&value, "=");
if (!name || !value)
return -EINVAL;
- len = strlen(value);
+ i = match_string(rdmacg_resource_names, RDMACG_RESOURCE_MAX, name);
+ if (i < 0)
+ return i;
- for (i = 0; i < RDMACG_RESOURCE_MAX; i++) {
- if (strcmp(table[i], name))
- continue;
+ len = strlen(value);
- argstr.from = value;
- argstr.to = value + len;
+ argstr.from = value;
+ argstr.to = value + len;
- ret = match_int(&argstr, intval);
- if (ret >= 0) {
- if (*intval < 0)
- break;
- return i;
- }
- if (strncmp(value, RDMACG_MAX_STR, len) == 0) {
- *intval = S32_MAX;
- return i;
- }
- break;
+ ret = match_int(&argstr, intval);
+ if (ret >= 0) {
+ if (*intval < 0)
+ return -EINVAL;
+ return i;
+ }
+ if (strncmp(value, RDMACG_MAX_STR, len) == 0) {
+ *intval = S32_MAX;
+ return i;
}
return -EINVAL;
}
--
2.17.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] rdmacg: Convert to use match_string() helper
2018-05-04 14:42 [PATCH v2] rdmacg: Convert to use match_string() helper Andy Shevchenko
@ 2018-05-07 16:27 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2018-05-07 16:27 UTC (permalink / raw)
To: Andy Shevchenko; +Cc: linux-kernel, Parav Pandit
On Fri, May 04, 2018 at 05:42:16PM +0300, Andy Shevchenko wrote:
> 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>
Applied to cgroup/for-4.18.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-07 16:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-04 14:42 [PATCH v2] rdmacg: Convert to use match_string() helper Andy Shevchenko
2018-05-07 16:27 ` Tejun Heo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).