diff --git a/sys/dev/uart/uart.h b/sys/dev/uart/uart.h --- 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 @@ */ 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 --- a/sys/dev/uart/uart_dev_ns8250.c +++ b/sys/dev/uart/uart_dev_ns8250.c @@ -451,6 +451,7 @@ .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 --- a/sys/dev/uart/uart_dev_z8530.c +++ b/sys/dev/uart/uart_dev_z8530.c @@ -309,6 +309,7 @@ .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 --- 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 @@ 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;