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
This commit is contained in:
parent
8818758a6e
commit
d1949353e5
@ -172,7 +172,7 @@ uart_parse_tag(const char **p)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
*p += 2;
|
*p += 2;
|
||||||
if ((*p)[0] != ':')
|
if ((*p)[0] != ':' && (*p)[0] != '=')
|
||||||
return (-1);
|
return (-1);
|
||||||
(*p)++;
|
(*p)++;
|
||||||
return (tag);
|
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);
|
di->bas.rclk = uart_parse_long(&spec);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
freeenv(cp);
|
goto inval;
|
||||||
return (EINVAL);
|
|
||||||
}
|
}
|
||||||
if (*spec == '\0')
|
if (*spec == '\0')
|
||||||
break;
|
break;
|
||||||
if (*spec != ',') {
|
if (*spec != ',')
|
||||||
freeenv(cp);
|
goto inval;
|
||||||
return (EINVAL);
|
|
||||||
}
|
|
||||||
spec++;
|
spec++;
|
||||||
}
|
}
|
||||||
freeenv(cp);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we still have an invalid address, the specification must be
|
* If we still have an invalid address, the specification must be
|
||||||
* missing an I/O port or memory address. We don't like that.
|
* missing an I/O port or memory address. We don't like that.
|
||||||
*/
|
*/
|
||||||
if (addr == ~0U)
|
if (addr == ~0U)
|
||||||
return (EINVAL);
|
goto inval;
|
||||||
|
freeenv(cp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Accept only the well-known baudrates. Any invalid baudrate
|
* 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,
|
error = bus_space_map(di->bas.bst, addr, uart_getrange(class), 0,
|
||||||
&di->bas.bsh);
|
&di->bas.bsh);
|
||||||
return (error);
|
return (error);
|
||||||
|
inval:
|
||||||
|
printf("warning: bad uart specification: %s\n", cp);
|
||||||
|
freeenv(cp);
|
||||||
|
return (EINVAL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user