Module Name: src Committed By: thorpej Date: Sun Apr 4 19:12:28 UTC 2021
Modified Files: src/sys/kern [thorpej-cfargs]: subr_autoconf.c src/sys/sys [thorpej-cfargs]: device.h Log Message: Add a CFARG_SEARCH tag, which specifies an indirect config search function (which has the same signature as a direct config submatch function). This is a synonym for CFARG_SUBMATCH internally, but this is an implementation detail; the two things should be distinct to callers, because submatch and search functions have different behaviors. Only one SEARCH or SUBMATCH argument is allowed. Also, change config_get_cfargs() to panic if an unknown tag is passed (we don't know what kind of argument to consume after an unknown tag, so this is fatal). To generate a diff of this commit: cvs rdiff -u -r1.277.2.10 -r1.277.2.11 src/sys/kern/subr_autoconf.c cvs rdiff -u -r1.167.2.7 -r1.167.2.8 src/sys/sys/device.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/subr_autoconf.c diff -u src/sys/kern/subr_autoconf.c:1.277.2.10 src/sys/kern/subr_autoconf.c:1.277.2.11 --- src/sys/kern/subr_autoconf.c:1.277.2.10 Sat Apr 3 16:09:44 2021 +++ src/sys/kern/subr_autoconf.c Sun Apr 4 19:12:27 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_autoconf.c,v 1.277.2.10 2021/04/03 16:09:44 thorpej Exp $ */ +/* $NetBSD: subr_autoconf.c,v 1.277.2.11 2021/04/04 19:12:27 thorpej Exp $ */ /* * Copyright (c) 1996, 2000 Christopher G. Demetriou @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.277.2.10 2021/04/03 16:09:44 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.277.2.11 2021/04/04 19:12:27 thorpej Exp $"); #ifdef _KERNEL_OPT #include "opt_ddb.h" @@ -1037,7 +1037,18 @@ config_get_cfargs(cfarg_t tag, while (tag != CFARG_EOL) { switch (tag) { + /* + * CFARG_SUBMATCH and CFARG_SEARCH are synonyms, but this + * is merely an implementation detail. They are distinct + * from the caller's point of view. + */ case CFARG_SUBMATCH: + case CFARG_SEARCH: + /* Only allow one function to be specified. */ + if (fn != NULL) { + panic("%s: caller specified both " + "SUBMATCH and SEARCH", __func__); + } fn = va_arg(ap, cfsubmatch_t); break; @@ -1054,16 +1065,12 @@ config_get_cfargs(cfarg_t tag, break; default: - /* XXX panic? */ - /* XXX dump stack backtrace? */ - aprint_error("%s: unknown cfarg tag: %d\n", + panic("%s: unknown cfarg tag: %d\n", __func__, tag); - goto out; } tag = va_arg(ap, cfarg_t); } - out: if (fnp != NULL) *fnp = fn; if (ifattrp != NULL) Index: src/sys/sys/device.h diff -u src/sys/sys/device.h:1.167.2.7 src/sys/sys/device.h:1.167.2.8 --- src/sys/sys/device.h:1.167.2.7 Sat Apr 3 16:09:44 2021 +++ src/sys/sys/device.h Sun Apr 4 19:12:28 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: device.h,v 1.167.2.7 2021/04/03 16:09:44 thorpej Exp $ */ +/* $NetBSD: device.h,v 1.167.2.8 2021/04/04 19:12:28 thorpej Exp $ */ /* * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -529,10 +529,11 @@ struct pdevinit { * config_found(). */ typedef enum { - CFARG_SUBMATCH = 0, /* submatch function */ - CFARG_IATTR = 1, /* interface attribute */ - CFARG_LOCATORS = 2, /* locators array */ - CFARG_DEVHANDLE = 3, /* devhandle_t (by value) */ + CFARG_SUBMATCH = 0, /* submatch function (direct config) */ + CFARG_SEARCH = 1, /* search function (indirect config) */ + CFARG_IATTR = 2, /* interface attribute */ + CFARG_LOCATORS = 3, /* locators array */ + CFARG_DEVHANDLE = 4, /* devhandle_t (by value) */ CFARG_EOL = 0xffffffff } cfarg_t;