git: d1949353e5f5 - main - uart: Improve console specification parsing
Warner Losh
imp at FreeBSD.org
Fri Jan 15 00:47:30 UTC 2021
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=d1949353e5f57678f227b0b283cb63f367174e96
commit d1949353e5f57678f227b0b283cb63f367174e96
Author: Warner Losh <imp at FreeBSD.org>
AuthorDate: 2021-01-14 20:43:15 +0000
Commit: Warner Losh <imp at FreeBSD.org>
CommitDate: 2021-01-15 00:47:04 +0000
uart: Improve console specification parsing
Print warning when we can't parse a console specification (this may
not appear on the console, but will appear in dmesg).
Also, accept key:value and key=value. There's no reason not to
and it makes this more forgiving of mistakes.
Reviewed by: rpokala@
Differential Revision: https://reviews.freebsd.org/D28168
---
sys/dev/uart/uart_subr.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/sys/dev/uart/uart_subr.c b/sys/dev/uart/uart_subr.c
index 96d7735ea0ed..e6dec58d7705 100644
--- a/sys/dev/uart/uart_subr.c
+++ b/sys/dev/uart/uart_subr.c
@@ -172,7 +172,7 @@ uart_parse_tag(const char **p)
out:
*p += 2;
- if ((*p)[0] != ':')
+ if ((*p)[0] != ':' && (*p)[0] != '=')
return (-1);
(*p)++;
return (tag);
@@ -283,25 +283,22 @@ uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class)
di->bas.rclk = uart_parse_long(&spec);
break;
default:
- freeenv(cp);
- return (EINVAL);
+ goto inval;
}
if (*spec == '\0')
break;
- if (*spec != ',') {
- freeenv(cp);
- return (EINVAL);
- }
+ if (*spec != ',')
+ goto inval;
spec++;
}
- freeenv(cp);
/*
* If we still have an invalid address, the specification must be
* missing an I/O port or memory address. We don't like that.
*/
if (addr == ~0U)
- return (EINVAL);
+ goto inval;
+ freeenv(cp);
/*
* Accept only the well-known baudrates. Any invalid baudrate
@@ -327,4 +324,8 @@ uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class)
error = bus_space_map(di->bas.bst, addr, uart_getrange(class), 0,
&di->bas.bsh);
return (error);
+inval:
+ printf("warning: bad uart specification: %s\n", cp);
+ freeenv(cp);
+ return (EINVAL);
}
More information about the dev-commits-src-main
mailing list