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>
This commit is contained in:
parent
c43c5ea75f
commit
cc659e76f3
|
@ -362,35 +362,32 @@ EXPORT_SYMBOL(rdmacg_unregister_device);
|
||||||
static int parse_resource(char *c, int *intval)
|
static int parse_resource(char *c, int *intval)
|
||||||
{
|
{
|
||||||
substring_t argstr;
|
substring_t argstr;
|
||||||
const char **table = &rdmacg_resource_names[0];
|
|
||||||
char *name, *value = c;
|
char *name, *value = c;
|
||||||
size_t len;
|
size_t len;
|
||||||
int ret, i = 0;
|
int ret, i;
|
||||||
|
|
||||||
name = strsep(&value, "=");
|
name = strsep(&value, "=");
|
||||||
if (!name || !value)
|
if (!name || !value)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
i = match_string(rdmacg_resource_names, RDMACG_RESOURCE_MAX, name);
|
||||||
|
if (i < 0)
|
||||||
|
return i;
|
||||||
|
|
||||||
len = strlen(value);
|
len = strlen(value);
|
||||||
|
|
||||||
for (i = 0; i < RDMACG_RESOURCE_MAX; i++) {
|
argstr.from = value;
|
||||||
if (strcmp(table[i], name))
|
argstr.to = value + len;
|
||||||
continue;
|
|
||||||
|
|
||||||
argstr.from = value;
|
ret = match_int(&argstr, intval);
|
||||||
argstr.to = value + len;
|
if (ret >= 0) {
|
||||||
|
if (*intval < 0)
|
||||||
ret = match_int(&argstr, intval);
|
return -EINVAL;
|
||||||
if (ret >= 0) {
|
return i;
|
||||||
if (*intval < 0)
|
}
|
||||||
break;
|
if (strncmp(value, RDMACG_MAX_STR, len) == 0) {
|
||||||
return i;
|
*intval = S32_MAX;
|
||||||
}
|
return i;
|
||||||
if (strncmp(value, RDMACG_MAX_STR, len) == 0) {
|
|
||||||
*intval = S32_MAX;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue