Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc659e76 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Tejun Heo
Browse files

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent c43c5ea7
Loading
Loading
Loading
Loading
+16 −19
Original line number Original line Diff line number Diff line
@@ -362,20 +362,19 @@ 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;


	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++) {
	len = strlen(value);
		if (strcmp(table[i], name))
			continue;


	argstr.from = value;
	argstr.from = value;
	argstr.to = value + len;
	argstr.to = value + len;
@@ -383,15 +382,13 @@ static int parse_resource(char *c, int *intval)
	ret = match_int(&argstr, intval);
	ret = match_int(&argstr, intval);
	if (ret >= 0) {
	if (ret >= 0) {
		if (*intval < 0)
		if (*intval < 0)
				break;
			return -EINVAL;
		return i;
		return i;
	}
	}
	if (strncmp(value, RDMACG_MAX_STR, len) == 0) {
	if (strncmp(value, RDMACG_MAX_STR, len) == 0) {
		*intval = S32_MAX;
		*intval = S32_MAX;
		return i;
		return i;
	}
	}
		break;
	}
	return -EINVAL;
	return -EINVAL;
}
}