| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: subr_autoconf.c,v 1.277.2.11 2021/04/04 19:12:27 thorpej Exp $ */ | | 1 | /* $NetBSD: subr_autoconf.c,v 1.277.2.12 2021/04/04 19:23:53 thorpej Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1996, 2000 Christopher G. Demetriou | | 4 | * Copyright (c) 1996, 2000 Christopher G. Demetriou |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
| @@ -67,27 +67,27 @@ | | | @@ -67,27 +67,27 @@ |
67 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 67 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
68 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 68 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
69 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 69 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
70 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 70 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
71 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 71 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
72 | * SUCH DAMAGE. | | 72 | * SUCH DAMAGE. |
73 | * | | 73 | * |
74 | * from: Header: subr_autoconf.c,v 1.12 93/02/01 19:31:48 torek Exp (LBL) | | 74 | * from: Header: subr_autoconf.c,v 1.12 93/02/01 19:31:48 torek Exp (LBL) |
75 | * | | 75 | * |
76 | * @(#)subr_autoconf.c 8.3 (Berkeley) 5/17/94 | | 76 | * @(#)subr_autoconf.c 8.3 (Berkeley) 5/17/94 |
77 | */ | | 77 | */ |
78 | | | 78 | |
79 | #include <sys/cdefs.h> | | 79 | #include <sys/cdefs.h> |
80 | __KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.277.2.11 2021/04/04 19:12:27 thorpej Exp $"); | | 80 | __KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.277.2.12 2021/04/04 19:23:53 thorpej Exp $"); |
81 | | | 81 | |
82 | #ifdef _KERNEL_OPT | | 82 | #ifdef _KERNEL_OPT |
83 | #include "opt_ddb.h" | | 83 | #include "opt_ddb.h" |
84 | #include "drvctl.h" | | 84 | #include "drvctl.h" |
85 | #endif | | 85 | #endif |
86 | | | 86 | |
87 | #include <sys/param.h> | | 87 | #include <sys/param.h> |
88 | #include <sys/device.h> | | 88 | #include <sys/device.h> |
89 | #include <sys/disklabel.h> | | 89 | #include <sys/disklabel.h> |
90 | #include <sys/conf.h> | | 90 | #include <sys/conf.h> |
91 | #include <sys/kauth.h> | | 91 | #include <sys/kauth.h> |
92 | #include <sys/kmem.h> | | 92 | #include <sys/kmem.h> |
93 | #include <sys/systm.h> | | 93 | #include <sys/systm.h> |
| @@ -994,42 +994,57 @@ config_cfdata_detach(cfdata_t cf) | | | @@ -994,42 +994,57 @@ config_cfdata_detach(cfdata_t cf) |
994 | if (ct->ct_cfdata == cf) { | | 994 | if (ct->ct_cfdata == cf) { |
995 | TAILQ_REMOVE(&allcftables, ct, ct_list); | | 995 | TAILQ_REMOVE(&allcftables, ct, ct_list); |
996 | kmem_free(ct, sizeof(*ct)); | | 996 | kmem_free(ct, sizeof(*ct)); |
997 | return 0; | | 997 | return 0; |
998 | } | | 998 | } |
999 | } | | 999 | } |
1000 | | | 1000 | |
1001 | /* not found -- shouldn't happen */ | | 1001 | /* not found -- shouldn't happen */ |
1002 | return EINVAL; | | 1002 | return EINVAL; |
1003 | } | | 1003 | } |
1004 | | | 1004 | |
1005 | /* | | 1005 | /* |
1006 | * Invoke the "match" routine for a cfdata entry on behalf of | | 1006 | * Invoke the "match" routine for a cfdata entry on behalf of |
1007 | * an external caller, usually a "submatch" routine. | | 1007 | * an external caller, usually a direct config "submatch" routine. |
1008 | */ | | 1008 | */ |
1009 | int | | 1009 | int |
1010 | config_match(device_t parent, cfdata_t cf, void *aux) | | 1010 | config_match(device_t parent, cfdata_t cf, void *aux) |
1011 | { | | 1011 | { |
1012 | struct cfattach *ca; | | 1012 | struct cfattach *ca; |
1013 | | | 1013 | |
1014 | ca = config_cfattach_lookup(cf->cf_name, cf->cf_atname); | | 1014 | ca = config_cfattach_lookup(cf->cf_name, cf->cf_atname); |
1015 | if (ca == NULL) { | | 1015 | if (ca == NULL) { |
1016 | /* No attachment for this entry, oh well. */ | | 1016 | /* No attachment for this entry, oh well. */ |
1017 | return 0; | | 1017 | return 0; |
1018 | } | | 1018 | } |
1019 | | | 1019 | |
1020 | return (*ca->ca_match)(parent, cf, aux); | | 1020 | return (*ca->ca_match)(parent, cf, aux); |
1021 | } | | 1021 | } |
1022 | | | 1022 | |
| | | 1023 | /* |
| | | 1024 | * Invoke the "probe" routine for a cfdata entry on behalf of |
| | | 1025 | * an external caller, usually an indirect config "search" routine. |
| | | 1026 | */ |
| | | 1027 | int |
| | | 1028 | config_probe(device_t parent, cfdata_t cf, void *aux) |
| | | 1029 | { |
| | | 1030 | /* |
| | | 1031 | * This is currently a synonym for config_match(), but this |
| | | 1032 | * is an implementation detail; "match" and "probe" routines |
| | | 1033 | * have different behaviors. |
| | | 1034 | */ |
| | | 1035 | return config_match(parent, cf, aux); |
| | | 1036 | } |
| | | 1037 | |
1023 | static void | | 1038 | static void |
1024 | config_get_cfargs(cfarg_t tag, | | 1039 | config_get_cfargs(cfarg_t tag, |
1025 | cfsubmatch_t *fnp, /* output */ | | 1040 | cfsubmatch_t *fnp, /* output */ |
1026 | const char **ifattrp, /* output */ | | 1041 | const char **ifattrp, /* output */ |
1027 | const int **locsp, /* output */ | | 1042 | const int **locsp, /* output */ |
1028 | devhandle_t *handlep, /* output */ | | 1043 | devhandle_t *handlep, /* output */ |
1029 | va_list ap) | | 1044 | va_list ap) |
1030 | { | | 1045 | { |
1031 | cfsubmatch_t fn = NULL; | | 1046 | cfsubmatch_t fn = NULL; |
1032 | const char *ifattr = NULL; | | 1047 | const char *ifattr = NULL; |
1033 | const int *locs = NULL; | | 1048 | const int *locs = NULL; |
1034 | devhandle_t handle; | | 1049 | devhandle_t handle; |
1035 | | | 1050 | |