Commit deb631c4 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Bartosz Golaszewski
Browse files

gpio: aggregator: Replace isrange() by using get_options()



We already have a nice helper called get_options() which can be used
to validate the input format. Replace isrange() by using it.

Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarBartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
parent 0ea09083
Loading
Loading
Loading
Loading
+3 −30
Original line number Diff line number Diff line
@@ -62,34 +62,6 @@ static char *get_arg(char **args)
	return start;
}

static bool isrange(const char *s)
{
	size_t n;

	if (IS_ERR_OR_NULL(s))
		return false;

	while (1) {
		n = strspn(s, "0123456789");
		if (!n)
			return false;

		s += n;

		switch (*s++) {
		case '\0':
			return true;

		case '-':
		case ',':
			break;

		default:
			return false;
		}
	}
}

static int aggr_add_gpio(struct gpio_aggregator *aggr, const char *key,
			 int hwnum, unsigned int *n)
{
@@ -112,10 +84,10 @@ static int aggr_add_gpio(struct gpio_aggregator *aggr, const char *key,

static int aggr_parse(struct gpio_aggregator *aggr)
{
	char *name, *offsets, *p;
	char *args = aggr->args;
	unsigned long *bitmap;
	unsigned int i, n = 0;
	char *name, *offsets;
	int error = 0;

	bitmap = bitmap_alloc(ARCH_NR_GPIOS, GFP_KERNEL);
@@ -130,7 +102,8 @@ static int aggr_parse(struct gpio_aggregator *aggr)
			goto free_bitmap;
		}

		if (!isrange(offsets)) {
		p = get_options(offsets, 0, &error);
		if (error == 0 || *p) {
			/* Named GPIO line */
			error = aggr_add_gpio(aggr, name, U16_MAX, &n);
			if (error)