The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=c87b3f0006be9ac5813f1ff636f18c9b4a41b08e

commit c87b3f0006be9ac5813f1ff636f18c9b4a41b08e
Author:     Warner Losh <i...@freebsd.org>
AuthorDate: 2024-10-14 21:58:10 +0000
Commit:     Warner Losh <i...@freebsd.org>
CommitDate: 2024-10-14 22:03:59 +0000

    uart: uart_getenv: check for NULL class last, not first
    
    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
---
 sys/dev/uart/uart_subr.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sys/dev/uart/uart_subr.c b/sys/dev/uart/uart_subr.c
index 070ae80d9aff..ca127b3a956e 100644
--- a/sys/dev/uart/uart_subr.c
+++ b/sys/dev/uart/uart_subr.c
@@ -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
@@ -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

Reply via email to