Skip to content

Commit deb631c

Browse files
andy-shevbrgl
authored andcommitted
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
1 parent 0ea0908 commit deb631c

1 file changed

Lines changed: 3 additions & 30 deletions

File tree

drivers/gpio/gpio-aggregator.c

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,34 +62,6 @@ static char *get_arg(char **args)
6262
return start;
6363
}
6464

65-
static bool isrange(const char *s)
66-
{
67-
size_t n;
68-
69-
if (IS_ERR_OR_NULL(s))
70-
return false;
71-
72-
while (1) {
73-
n = strspn(s, "0123456789");
74-
if (!n)
75-
return false;
76-
77-
s += n;
78-
79-
switch (*s++) {
80-
case '\0':
81-
return true;
82-
83-
case '-':
84-
case ',':
85-
break;
86-
87-
default:
88-
return false;
89-
}
90-
}
91-
}
92-
9365
static int aggr_add_gpio(struct gpio_aggregator *aggr, const char *key,
9466
int hwnum, unsigned int *n)
9567
{
@@ -112,10 +84,10 @@ static int aggr_add_gpio(struct gpio_aggregator *aggr, const char *key,
11284

11385
static int aggr_parse(struct gpio_aggregator *aggr)
11486
{
87+
char *name, *offsets, *p;
11588
char *args = aggr->args;
11689
unsigned long *bitmap;
11790
unsigned int i, n = 0;
118-
char *name, *offsets;
11991
int error = 0;
12092

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

133-
if (!isrange(offsets)) {
105+
p = get_options(offsets, 0, &error);
106+
if (error == 0 || *p) {
134107
/* Named GPIO line */
135108
error = aggr_add_gpio(aggr, name, U16_MAX, &n);
136109
if (error)

0 commit comments

Comments
 (0)