From nobody Mon Oct 14 22:17:39 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XSBS44lnZz5ZFYM; Mon, 14 Oct 2024 22:17:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XSBS41XFMz3xYW; Mon, 14 Oct 2024 22:17:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728944260; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QR01sU+PP6dnGQszIb6M+g76qWrZolDITLSo14dsuB0=; b=WNHVK0nyDDAtaUWbqEEFT6aKWPFB6z8VM4ZRvyrZ4Mt095ONZyLAVRfP3rzYMrJ03uO69W t5jT9AS1x4EvApe7eUP4TyuznUpkfPqJ2pKSMKvPLA6KZ4kP9Vgq09HMmZhPdXocvMsxUv PWorFa2gZ9bU9Z6TUkRoKNwyBUgzogYQifsd13M8aqCdhgE7e3s+bXxLToSDlXEFtTDDYt wp22/Mu2QVUi3C94hZyD3getZh4E3iTBvACQW4pSapKZYdrPL8nJh5DVhTCdTQkIYoaJ67 ylWAGTOoOzXnlkt8+34OIrBuRw2nc1DkPEMDPkc+H661bW9GQy8wqaAjXEoDDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728944260; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=QR01sU+PP6dnGQszIb6M+g76qWrZolDITLSo14dsuB0=; b=floxsA/ENGyG9FwMOAeqnsdDzgNdLpm78BH/9P3X3Xz/tHxfc7J/9IodSX6Usx5Z1SLzW2 xTBd3+IJkIGGWn3uf+znpiDzPQGfABuS+Bo3So5Ct5VdQyWJjTM/W/utTwmLyOEX+GLYtl h6YIAih6awQU4u1mnirxVKLXfj1imVTkdM5ZuyB/pcbN9ipib5oXURmSoTl6Bk5w2hPIh8 kgOjlUhp5xljDlfQVWyETHrR3qTW5Y3qDcFZ3LaAXElTzM+yYFqi1ZL89nuSD2qqkFdcGX TSs4/jJbdhoyC6DqXWS/Nxh0mNtJ0FTcrLXumBE9dZmH14ZXnuFTICp00geAnw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728944260; a=rsa-sha256; cv=none; b=SBzPF8tiTjLR95sn6WZhis5XLy9udFVnUmB7oloxjEI9Bi242jtDZBNfOCav0OZR9egWPR JveCdsEsuEZtNmu6OlIhFpG5JU9cCrFM/JGjn/2BOflP7iPKCgqhtaa3FulfOwXJ/yNOlS pUoNTMzIAAx1bhygV6TE7ewCNo+ELEjqQR1YjhfR3SYR4rJa06gNbemLe7aJ3hnGilC+s7 BFn1pkEwnrAqfYPGtu4ScVWyJMQrICf65/+ZttL1fTQdcV+T+answnbNFdhivWhz/ENBxm Ys7Ewi5sA5ZMDj/zBj7zJIZSU6+KYgTpAnFyz44dC10JV+rjRA3FLFWuEKH3Vw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XSBS36msLzvxL; Mon, 14 Oct 2024 22:17:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49EMHdPn075014; Mon, 14 Oct 2024 22:17:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49EMHd7g075011; Mon, 14 Oct 2024 22:17:39 GMT (envelope-from git) Date: Mon, 14 Oct 2024 22:17:39 GMT Message-Id: <202410142217.49EMHd7g075011@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: c87b3f0006be - main - uart: uart_getenv: check for NULL class last, not first List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c87b3f0006be9ac5813f1ff636f18c9b4a41b08e Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=c87b3f0006be9ac5813f1ff636f18c9b4a41b08e commit c87b3f0006be9ac5813f1ff636f18c9b4a41b08e Author: Warner Losh AuthorDate: 2024-10-14 21:58:10 +0000 Commit: Warner Losh 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