From nobody Tue Feb 13 11:51:50 2024 X-Original-To: dev-commits-src-all@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 4TZ06Z5Tj1z5B70p; Tue, 13 Feb 2024 11:51:50 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TZ06Z21lcz44hX; Tue, 13 Feb 2024 11:51:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707825110; 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=XdrCrUWD5GIZZL+clp/mRPm32l2OwpXDcrbzMtTd/8c=; b=dQTHrvIotW6bG6+xZIHSVitfsfbl2PBuRCoebAkxB+AsvF17QILvVrCdZTg16gBgc108C0 z0nPaubBrEHACNGCb8g73BJYKniF+xCxaQMVnEUb/8UztaznJpr5Je4gUAlXZnBcYWub5b njkYfI8ruBPrmuWsIH3fONWNAfJ99a4ba7eiCAngav5IMuEgYhqiY5b8I6hCFT3t81hcC8 ZCP5uJXcGJ7u+vK4AUs+U+LQouSMBGqVVpZikPBJr47uCqKN4zf66UGPJyVuHFkyOIohJy G0rDX32nNsCEkZ1YepamLHxEGF/ffnIYVvio7RyN94/4QX625g4KPDA460av+Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707825110; a=rsa-sha256; cv=none; b=OG2Cnb9slplMseVQmTkA6Vk533EtDDGGlqvpoQ4OAB0xj3KX+Tq62EMEOcN6vSd0GiAFBK StiOcU7230YkKrL1QlqAGlZ1IGGFB8P1kNJa736ArgJ7bLtVv7DRaM9KbccxVRA2VQXd1z 5g6Lq1StRdMJz54QFl71ApsowoD2MSCQz33JqERvXzSzDfpQBzpsbfjS76fFM7zKDd55LJ vz9MT3oPdnhUDP5Rxvl5jF+re2APnrTQKCu/mJaiTuFy/3z+Wx+0XZCuE51ddSd723D4Xk /zyKUjb+DAN7mU+qxEJFzdWLTJeNPC2bRgn8ndaHri/qIOowmmb4wDbMNooOxA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707825110; 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=XdrCrUWD5GIZZL+clp/mRPm32l2OwpXDcrbzMtTd/8c=; b=j7B/byT8XBTaWuiVo6IOWuPNMIHyPEZA6VuMgkNF0wz5zNT16tKD80ETlOK+NVfCFlqVJp itl4JwWtRDJvizNoG8I1Oo4hdaubfo4+BjhOmJ6ehRjUQYeKRqQT8k53OW966LT3aK/nrm miR9gmQyB2A6bUpd8IIbxYM8rN1IBuiQw1m0iMfH8wBhRfkQtAFk8ZYMc4rkK8w6TVYrWb OYhtzgt304Fn5bW5qYqppFYql0lHh+BkIOFbQ+ComF6vmDxA1QAWVwKZEUghvv8vPp60Xi 5LKFr7wjM+iGNmfgCI1x24GroJXbGUKYBKeEv1R/VS37eM0Ic/lLINuhLiHcsA== 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 4TZ06Z14hpzDbL; Tue, 13 Feb 2024 11:51:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41DBpoOM045867; Tue, 13 Feb 2024 11:51:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41DBpoao045864; Tue, 13 Feb 2024 11:51:50 GMT (envelope-from git) Date: Tue, 13 Feb 2024 11:51:50 GMT Message-Id: <202402131151.41DBpoao045864@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 949670f8f466 - main - dev/uart: Use a linker set to find uart classes List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: andrew X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 949670f8f46656a30ffbd22c9ae2cc645bda8533 Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=949670f8f46656a30ffbd22c9ae2cc645bda8533 commit 949670f8f46656a30ffbd22c9ae2cc645bda8533 Author: Andrew Turner AuthorDate: 2024-01-08 15:02:29 +0000 Commit: Andrew Turner CommitDate: 2024-02-13 11:48:52 +0000 dev/uart: Use a linker set to find uart classes When the uart is configured via the environment we need to find the uart class with a specified name. Currently to do this with an incomplete list of uarts. As we may not have included all uarts in the kernel each class is defined as weak. Switch to a linker set so the list is always up to date based on what is included in the kernel, and the class can be static. Reviewed by: imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D43361 --- sys/dev/uart/uart.h | 4 ++++ sys/dev/uart/uart_dev_ns8250.c | 1 + sys/dev/uart/uart_dev_z8530.c | 1 + sys/dev/uart/uart_subr.c | 12 +++--------- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/dev/uart/uart.h b/sys/dev/uart/uart.h index 5eae06ceba6f..987152283c81 100644 --- a/sys/dev/uart/uart.h +++ b/sys/dev/uart/uart.h @@ -29,6 +29,8 @@ #ifndef _DEV_UART_H_ #define _DEV_UART_H_ +#include + /* * Bus access structure. This structure holds the minimum information needed * to access the UART. The rclk field, although not important to actually @@ -99,6 +101,8 @@ uart_setreg(struct uart_bas *bas, int reg, int value) */ struct uart_class; +SET_DECLARE(uart_class_set, struct uart_class); + extern struct uart_class uart_ns8250_class __attribute__((weak)); extern struct uart_class uart_quicc_class __attribute__((weak)); extern struct uart_class uart_z8530_class __attribute__((weak)); diff --git a/sys/dev/uart/uart_dev_ns8250.c b/sys/dev/uart/uart_dev_ns8250.c index 090909fdf8d2..f660639862ff 100644 --- a/sys/dev/uart/uart_dev_ns8250.c +++ b/sys/dev/uart/uart_dev_ns8250.c @@ -451,6 +451,7 @@ struct uart_class uart_ns8250_class = { .uc_rclk = DEFAULT_RCLK, .uc_rshift = 0 }; +DATA_SET(uart_class_set, uart_ns8250_class); /* * XXX -- refactor out ACPI and FDT ifdefs diff --git a/sys/dev/uart/uart_dev_z8530.c b/sys/dev/uart/uart_dev_z8530.c index 8e1adac0aec2..107fcb1eb4ba 100644 --- a/sys/dev/uart/uart_dev_z8530.c +++ b/sys/dev/uart/uart_dev_z8530.c @@ -309,6 +309,7 @@ struct uart_class uart_z8530_class = { .uc_rclk = DEFAULT_RCLK, .uc_rshift = 0 }; +DATA_SET(uart_class_set, uart_z8530_class); #define SIGCHG(c, i, s, d) \ if (c) { \ diff --git a/sys/dev/uart/uart_subr.c b/sys/dev/uart/uart_subr.c index d10084cfa6d8..e7570e173358 100644 --- a/sys/dev/uart/uart_subr.c +++ b/sys/dev/uart/uart_subr.c @@ -48,11 +48,6 @@ #define UART_TAG_XO 9 #define UART_TAG_BD 10 -static struct uart_class *uart_classes[] = { - &uart_ns8250_class, - &uart_z8530_class, -}; - static bus_addr_t uart_parse_addr(const char **p) { @@ -62,13 +57,12 @@ uart_parse_addr(const char **p) static struct uart_class * uart_parse_class(struct uart_class *class, const char **p) { - struct uart_class *uc; + struct uart_class **puc, *uc; const char *nm; size_t len; - u_int i; - for (i = 0; i < nitems(uart_classes); i++) { - uc = uart_classes[i]; + SET_FOREACH(puc, uart_class_set) { + uc = *puc; nm = uart_getname(uc); if (nm == NULL || *nm == '\0') continue;