serial: core: Use isdigit() in uart_parse_options()
PATCH 1/2 serial: core: Use isdigit() in uart_parse_options()
Use isdigit() to replace the open-coded implementation.
Signed-off-by Thorsten Blum <[email protected]>
--- drivers/tty/serial/serial_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/tty/serial/serial_core.c +2 -1
@@ -14,6 +14,7 @@#include <linux/sched/signal.h> #include <linux/init.h> #include <linux/console.h> +#include <linux/ctype.h> #include <linux/gpio/consumer.h> #include <linux/kernel.h> #include <linux/of.h>
@@ -2211,7 +2212,7 @@ uart_parse_options(const char *options, int *baud, int *parity,const char *s = options; *baud =simple_strtoul (s,NULL ,10 ); -while (*s >='0' && *s <='9' ) +while (isdigit (*s)) s++;if (*s) *parity = *s++;
PATCH 2/2 serial: earlycon: Use isdigit() in earlycon_init()
Use isdigit() and a while loop to simplify the backward scan.
Signed-off-by Thorsten Blum <[email protected]>
--- drivers/tty/serial/earlycon.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/tty/serial/earlycon.c +5 -5
@@ -11,6 +11,7 @@#define pr_fmt (fmt) KBUILD_MODNAME ": " fmt#include <linux/console.h> +#include <linux/ctype.h> #include <linux/kernel.h> #include <linux/init.h> #include <linux/io.h>
@@ -59,11 +60,10 @@ static void __init earlycon_init(struct earlycon_device *device,const char *s;size_t len; -/* scan backwards from end of string for first non-numeral */ -for (s = name +strlen (name); - s > name && s[-1 ] >='0' && s[-1 ] <='9' ; - s--) - ; +/* Scan backwards to split the trailing index from the console name. */ + s = name +strlen (name); +while (s > name &&isdigit (s[-1 ])) + s--;if (*s) earlycon->index =simple_strtoul (s,NULL ,10 ); len = s - name;
[email protected]
AI reviewRe: [PATCH 2/2] serial: earlycon: Use isdigit() in earlycon_init()
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 3 lines
Use
isdigit()and a while loop to simplify the backward scan.Signed-off-by Thorsten Blum <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 3 lines
Use
isdigit()to replace the open-coded implementation.Signed-off-by Thorsten Blum <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 3 lines · Thorsten Blum
Use
isdigit()to replace the open-coded implementation.Signed-off-by Thorsten Blum <[email protected]>
Reviewed-by John Ogness <[email protected]>