Skip to content

Commit

Permalink
uart: uart_getenv: check for NULL class last, not first
Browse files Browse the repository at this point in the history
This allows one to specify dt:XXXX when the default class isn't compiled
into the kernel. It's not an error to not have a class until we're done
parsing the spec, so defer checking until then.

Sponsored by:		Netflix
Reviewed by:		adrian, andrew, markj
Differential Revision:	https://reviews.freebsd.org/D47078
  • Loading branch information
bsdimp committed Oct 14, 2024
1 parent 8190dfb commit c87b3f0
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions sys/dev/uart/uart_subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,6 @@ uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class)
bus_addr_t addr = ~0U;
int error;

/*
* All uart_class references are weak. Make sure the default
* device class has been compiled-in.
*/
if (class == NULL)
return (ENXIO);

/*
* Check the environment variables "hw.uart.console" and
* "hw.uart.dbgport". These variables, when present, specify
Expand Down Expand Up @@ -300,6 +293,13 @@ uart_getenv(int devtype, struct uart_devinfo *di, struct uart_class *class)
goto inval;
freeenv(cp);

/*
* The default uart_class reference is weak. Make sure the default
* device class has been compiled-in or we've set one with dt=.
*/
if (class == NULL)
return (ENXIO);

/*
* Accept only the well-known baudrates. Any invalid baudrate
* is silently replaced with a 0-valued baudrate. The 0 baudrate
Expand Down

0 comments on commit c87b3f0

Please sign in to comment.