lib/cmdline: Export next_arg() for being used in modules
Subsystems (3)
PATCH 1/2 lib/cmdline: Export next_arg() for being used in modules
At least one module will benefit from using next_arg() helper. Let's export it for that module and others if they consider it helpful.
--- lib/cmdline.c | 1 + 1 file changed, 1 insertion(+)
lib/cmdline.c +1 -0
@@ -272,3 +272,4 @@ char *next_arg(char *args, char **param, char **val)/* Chew up trailing spaces. */ return skip_spaces (args); } +EXPORT_SYMBOL (next_arg);
Signature · 1 line
2.30.1
PATCH 2/2 gpio: aggregator: Replace custom get_arg() with a generic next_arg()
cmdline library provides next_arg() helper to traverse over parameters and their values given in command line. Replace custom approach in the driver by it.
--- drivers/gpio/gpio-aggregator.c | 39 +++++----------------------------- 1 file changed, 5 insertions(+), 34 deletions(-)
drivers/gpio/gpio-aggregator.c +5 -34
@@ -37,31 +37,6 @@ struct gpio_aggregator {static DEFINE_MUTEX (gpio_aggregator_lock);/* protects idr */ static DEFINE_IDR (gpio_aggregator_idr); -static char *get_arg (char **args) -{ -char *start, *end; - - start =skip_spaces (*args); -if (!*start) -return NULL ; - -if (*start =='"' ) { -/* Quoted arg */ - end =strchr (++start,'"' ); -if (!end) -return ERR_PTR (-EINVAL ); - }else { -/* Unquoted arg */ -for (end = start; *end && !isspace (*end); end++) ; - } - -if (*end) - *end++ ='\0' ; - - *args = end; -return start; -} -static int aggr_add_gpio (struct gpio_aggregator *aggr,const char *key,int hwnum,unsigned int *n) {
@@ -83,8 +58,8 @@ static int aggr_add_gpio(struct gpio_aggregator *aggr, const char *key,static int aggr_parse (struct gpio_aggregator *aggr) { +char *args =skip_spaces (aggr->args);char *name, *offsets, *p; -char *args = aggr->args;unsigned long *bitmap;unsigned int i, n =0 ;int error =0 ;
@@ -93,13 +68,9 @@ static int aggr_parse(struct gpio_aggregator *aggr)if (!bitmap)return -ENOMEM ; -for (name =get_arg (&args), offsets =get_arg (&args); name; - offsets =get_arg (&args)) { -if (IS_ERR (name)) { -pr_err ("Cannot get GPIO specifier: %pe\n" , name); - error =PTR_ERR (name); - goto free_bitmap; - } + args =next_arg (args, &name, &p); +while (*args) { + args =next_arg (args, &offsets, &p); p =get_options (offsets,0 , &error);if (error ==0 || *p) {
@@ -125,7 +96,7 @@ static int aggr_parse(struct gpio_aggregator *aggr) goto free_bitmap; } - name =get_arg (&args); + args =next_arg (args, &name, &p); }if (!n) {
Signature · 1 line
2.30.1
Re: [PATCH v1 2/2] gpio: aggregator: Replace custom get_arg() with a generic next_arg()
Quoted 5 lines · Andy Shevchenko
cmdline library provides
next_arg()helper to traverse over parameters and their values given in command line. Replace custom approach in the driver by it.Signed-off-by Andy Shevchenko <[email protected]>
Wow how nice!
Yours,
Linus Walleij
Re: [PATCH v1 2/2] gpio: aggregator: Replace custom get_arg() with a generic next_arg()
In reply to Andy ShevchenkoHi Andy,
Quoted 5 lines · Andy Shevchenko
cmdline library provides
next_arg()helper to traverse over parameters and their values given in command line. Replace custom approach in the driver by it.Signed-off-by Andy Shevchenko <[email protected]>
Thanks for your patch!
Quoted 6 lines
drivers/gpio/gpio-aggregator.c +0
-0@@ -93,13 +68,9 @@ static int aggr_parse(struct gpio_aggregator *aggr)if (!bitmap)return -ENOMEM ;
drivers/gpio/gpio-aggregator.c static int aggr_parse(struct gpio_aggregator *aggr) · line 73
Quoted 10 lines
drivers/gpio/gpio-aggregator.c +3
-7-for (name =get_arg (&args), offsets =get_arg (&args); name; - offsets =get_arg (&args)) { -if (IS_ERR (name)) { -pr_err ("Cannot get GPIO specifier: %pe\n" , name); - error =PTR_ERR (name); - goto free_bitmap; - } + args =next_arg (args, &name, &p); +while (*args) { + args =next_arg (args, &offsets, &p);
As name and offsets should not contain equal signs (can they?), I guess using next_arg() is fine.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH v1 2/2] gpio: aggregator: Replace custom get_arg() with a generic next_arg()
Quoted 18 lines · Geert Uytterhoeven
Hi Andy,
Quoted 5 lines · Andy Shevchenko
cmdline library provides
next_arg()helper to traverse over parameters and their values given in command line. Replace custom approach in the driver by it.Signed-off-by Andy Shevchenko <[email protected]>Thanks for your patch!
Quoted 6 lines
drivers/gpio/gpio-aggregator.c +0
-0@@ -93,13 +68,9 @@ static int aggr_parse(struct gpio_aggregator *aggr)if (!bitmap)return -ENOMEM ;
Quoted 13 lines
drivers/gpio/gpio-aggregator.c static int aggr_parse(struct gpio_aggregator *aggr) · line 73
Quoted 10 lines
drivers/gpio/gpio-aggregator.c +3
-7-for (name =get_arg (&args), offsets =get_arg (&args); name; - offsets =get_arg (&args)) { -if (IS_ERR (name)) { -pr_err ("Cannot get GPIO specifier: %pe\n" , name); - error =PTR_ERR (name); - goto free_bitmap; - } + args =next_arg (args, &name, &p); +while (*args) { + args =next_arg (args, &offsets, &p);As name and offsets should not contain equal signs (can they?), I guess using
next_arg()is fine.
Even though we can use double quotes (AFAICU the next_arg() code).
Quoted 1 line
Reviewed-by Geert Uytterhoeven <[email protected]>
Thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 5 lines · Andy Shevchenko
At least one module will benefit from using
next_arg()helper. Let's export it for that module and others if they consider it helpful.Signed-off-by Andy Shevchenko <[email protected]>
Yours,
Linus Walleij
Quoted 5 lines · Andy Shevchenko
At least one module will benefit from using
next_arg()helper. Let's export it for that module and others if they consider it helpful.Signed-off-by Andy Shevchenko <[email protected]>
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Quoted 9 lines · Geert Uytterhoeven
Quoted 5 lines · Andy Shevchenko
At least one module will benefit from using
next_arg()helper. Let's export it for that module and others if they consider it helpful.Signed-off-by Andy Shevchenko <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>
Thanks Geert and Linus!
Bart, do you want me to add it to my usual PR or you want to take it yourself (I have no dependencies in my tree on this anyway)?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 12 lines · Andy Shevchenko
Quoted 9 lines · Geert Uytterhoeven
Quoted 5 lines · Andy Shevchenko
At least one module will benefit from using
next_arg()helper. Let's export it for that module and others if they consider it helpful.Signed-off-by Andy Shevchenko <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>
Quoted 10 lines
Thanks Geert and Linus!
Bart, do you want me to add it to my usual PR or you want to take it yourself (I have no dependencies in my tree on this anyway)?
--
With Best Regards,
Andy Shevchenko
Please send it with your PR.
Bart
Quoted 11 lines · Bartosz Golaszewski
Quoted 9 lines · Andy Shevchenko
Quoted 8 lines · Geert Uytterhoeven
Quoted 5 lines · Andy Shevchenko
At least one module will benefit from using
next_arg()helper. Let's export it for that module and others if they consider it helpful.Signed-off-by Andy Shevchenko <[email protected]>
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
Reviewed-by Geert Uytterhoeven <[email protected]>Thanks Geert and Linus!
Bart, do you want me to add it to my usual PR or you want to take it yourself (I have no dependencies in my tree on this anyway)?
Please send it with your PR.
Will do, thanks!
Signature · 2 lines
With Best Regards, Andy Shevchenko