Tue Jan 26 14:55:34 2021 UTC ()
Replace 2 uses of of_match_compatible().


(thorpej)
diff -r1.35 -r1.36 src/sys/dev/fdt/fdtbus.c

cvs diff -r1.35 -r1.36 src/sys/dev/fdt/fdtbus.c (expand / switch to unified diff)

--- src/sys/dev/fdt/fdtbus.c 2020/09/20 11:25:36 1.35
+++ src/sys/dev/fdt/fdtbus.c 2021/01/26 14:55:34 1.36
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: fdtbus.c,v 1.35 2020/09/20 11:25:36 jmcneill Exp $ */ 1/* $NetBSD: fdtbus.c,v 1.36 2021/01/26 14:55:34 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> 4 * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
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.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.35 2020/09/20 11:25:36 jmcneill Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.36 2021/01/26 14:55:34 thorpej Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/systm.h> 33#include <sys/systm.h>
34#include <sys/device.h> 34#include <sys/device.h>
35#include <sys/kmem.h> 35#include <sys/kmem.h>
36#include <sys/cpu.h> 36#include <sys/cpu.h>
37 37
38#include <sys/bus.h> 38#include <sys/bus.h>
39 39
40#include <dev/ofw/openfirm.h> 40#include <dev/ofw/openfirm.h>
41 41
42#include <dev/fdt/fdtvar.h> 42#include <dev/fdt/fdtvar.h>
43 43
@@ -77,41 +77,43 @@ struct fdt_softc { @@ -77,41 +77,43 @@ struct fdt_softc {
77static int fdt_match(device_t, cfdata_t, void *); 77static int fdt_match(device_t, cfdata_t, void *);
78static void fdt_attach(device_t, device_t, void *); 78static void fdt_attach(device_t, device_t, void *);
79static int fdt_rescan(device_t, const char *, const int *); 79static int fdt_rescan(device_t, const char *, const int *);
80static void fdt_childdet(device_t, device_t); 80static void fdt_childdet(device_t, device_t);
81 81
82static int fdt_scan_submatch(device_t, cfdata_t, const int *, void *); 82static int fdt_scan_submatch(device_t, cfdata_t, const int *, void *);
83static void fdt_scan_best(struct fdt_softc *, struct fdt_node *); 83static void fdt_scan_best(struct fdt_softc *, struct fdt_node *);
84static void fdt_scan(struct fdt_softc *, int); 84static void fdt_scan(struct fdt_softc *, int);
85static void fdt_add_node(struct fdt_node *); 85static void fdt_add_node(struct fdt_node *);
86static u_int fdt_get_order(int); 86static u_int fdt_get_order(int);
87static void fdt_pre_attach(struct fdt_node *); 87static void fdt_pre_attach(struct fdt_node *);
88static void fdt_post_attach(struct fdt_node *); 88static void fdt_post_attach(struct fdt_node *);
89 89
90static const char * const fdtbus_compatible[] = 90static const struct device_compatible_entry compat_data[] = {
91 { "simple-bus", NULL }; 91 { .compat = "simple-bus" },
 92 { }
 93};
92 94
93CFATTACH_DECL2_NEW(simplebus, sizeof(struct fdt_softc), 95CFATTACH_DECL2_NEW(simplebus, sizeof(struct fdt_softc),
94 fdt_match, fdt_attach, NULL, NULL, fdt_rescan, fdt_childdet); 96 fdt_match, fdt_attach, NULL, NULL, fdt_rescan, fdt_childdet);
95 97
96static int 98static int
97fdt_match(device_t parent, cfdata_t cf, void *aux) 99fdt_match(device_t parent, cfdata_t cf, void *aux)
98{ 100{
99 const struct fdt_attach_args *faa = aux; 101 const struct fdt_attach_args *faa = aux;
100 const int phandle = faa->faa_phandle; 102 const int phandle = faa->faa_phandle;
101 int match; 103 int match;
102 104
103 /* Check compatible string */ 105 /* Check compatible string */
104 match = of_match_compatible(phandle, fdtbus_compatible); 106 match = of_match_compat_data(phandle, compat_data);
105 if (match) 107 if (match)
106 return match; 108 return match;
107 109
108 /* Some nodes have no compatible string */ 110 /* Some nodes have no compatible string */
109 if (!of_hasprop(phandle, "compatible")) { 111 if (!of_hasprop(phandle, "compatible")) {
110 if (OF_finddevice("/clocks") == phandle) 112 if (OF_finddevice("/clocks") == phandle)
111 return 1; 113 return 1;
112 if (OF_finddevice("/chosen") == phandle) 114 if (OF_finddevice("/chosen") == phandle)
113 return 1; 115 return 1;
114 } 116 }
115 117
116 /* Always match the root node */ 118 /* Always match the root node */
117 return OF_finddevice("/") == phandle; 119 return OF_finddevice("/") == phandle;
@@ -464,27 +466,27 @@ fdt_remove_byhandle(int phandle) @@ -464,27 +466,27 @@ fdt_remove_byhandle(int phandle)
464 if (node->n_phandle == phandle) { 466 if (node->n_phandle == phandle) {
465 TAILQ_REMOVE(&fdt_nodes, node, n_nodes); 467 TAILQ_REMOVE(&fdt_nodes, node, n_nodes);
466 return; 468 return;
467 } 469 }
468 } 470 }
469} 471}
470 472
471void 473void
472fdt_remove_bycompat(const char *compatible[]) 474fdt_remove_bycompat(const char *compatible[])
473{ 475{
474 struct fdt_node *node, *next; 476 struct fdt_node *node, *next;
475 477
476 TAILQ_FOREACH_SAFE(node, &fdt_nodes, n_nodes, next) { 478 TAILQ_FOREACH_SAFE(node, &fdt_nodes, n_nodes, next) {
477 if (of_match_compatible(node->n_phandle, compatible)) { 479 if (of_compatible(node->n_phandle, compatible)) {
478 TAILQ_REMOVE(&fdt_nodes, node, n_nodes); 480 TAILQ_REMOVE(&fdt_nodes, node, n_nodes);
479 } 481 }
480 } 482 }
481} 483}
482 484
483int 485int
484fdt_find_with_property(const char *prop, int *pindex) 486fdt_find_with_property(const char *prop, int *pindex)
485{ 487{
486 struct fdt_node *node; 488 struct fdt_node *node;
487 int index = 0; 489 int index = 0;
488 490
489 TAILQ_FOREACH(node, &fdt_nodes, n_nodes) { 491 TAILQ_FOREACH(node, &fdt_nodes, n_nodes) {
490 if (index++ < *pindex) 492 if (index++ < *pindex)