Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/fdt Use device_compatible_entry / of_search_com...



details:   https://anonhg.NetBSD.org/src/rev/a2eb65377308
branches:  trunk
changeset: 958772:a2eb65377308
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Jan 19 00:40:17 2021 +0000

description:
Use device_compatible_entry / of_search_compatible() for the GICv3
quirk table.

diffstat:

 sys/arch/arm/fdt/gicv3_fdt.c |  47 ++++++++++++++++++++++---------------------
 1 files changed, 24 insertions(+), 23 deletions(-)

diffs (102 lines):

diff -r 3004b29b17de -r a2eb65377308 sys/arch/arm/fdt/gicv3_fdt.c
--- a/sys/arch/arm/fdt/gicv3_fdt.c      Tue Jan 19 00:38:52 2021 +0000
+++ b/sys/arch/arm/fdt/gicv3_fdt.c      Tue Jan 19 00:40:17 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_fdt.c,v 1.11 2021/01/15 00:38:22 jmcneill Exp $ */
+/* $NetBSD: gicv3_fdt.c,v 1.12 2021/01/19 00:40:17 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015-2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
 #define        _INTR_PRIVATE
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.11 2021/01/15 00:38:22 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_fdt.c,v 1.12 2021/01/19 00:40:17 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -107,29 +107,26 @@
        struct gicv3_fdt_irq    *sc_irq[GICV3_MAXIRQ];
 };
 
-struct gicv3_fdt_quirk {
-       const char              *compat;
-       u_int                   quirks;
-};
-
-static const struct gicv3_fdt_quirk gicv3_fdt_quirks[] = {
-       { "rockchip,rk3399",    GICV3_QUIRK_RK3399 },
+static const struct device_compatible_entry gicv3_fdt_quirks[] = {
+       { .compat = "rockchip,rk3399",          .value = GICV3_QUIRK_RK3399 },
+       { 0 }
 };
 
 CFATTACH_DECL_NEW(gicv3_fdt, sizeof(struct gicv3_fdt_softc),
        gicv3_fdt_match, gicv3_fdt_attach, NULL, NULL);
 
+static const struct device_compatible_entry compat_data[] = {
+       { .compat = "arm,gic-v3" },
+       { 0 }
+};
+
 static int
 gicv3_fdt_match(device_t parent, cfdata_t cf, void *aux)
 {
-       const char * const compatible[] = {
-               "arm,gic-v3",
-               NULL
-       };
        struct fdt_attach_args * const faa = aux;
        const int phandle = faa->faa_phandle;
 
-       return of_match_compatible(phandle, compatible);
+       return of_match_compat_data(phandle, compat_data);
 }
 
 static void
@@ -138,7 +135,7 @@
        struct gicv3_fdt_softc * const sc = device_private(self);
        struct fdt_attach_args * const faa = aux;
        const int phandle = faa->faa_phandle;
-       int error, n;
+       int error;
 
        error = fdtbus_register_interrupt_controller(self, phandle,
            &gicv3_fdt_funcs);
@@ -164,11 +161,10 @@
        aprint_debug_dev(self, "%d redistributors\n", sc->sc_gic.sc_bsh_r_count);
 
        /* Apply quirks */
-       for (n = 0; n < __arraycount(gicv3_fdt_quirks); n++) {
-               const char *compat[] = { gicv3_fdt_quirks[n].compat, NULL };
-               if (of_match_compatible(OF_finddevice("/"), compat)) {
-                       sc->sc_gic.sc_quirks |= gicv3_fdt_quirks[n].quirks;
-               }
+       const struct device_compatible_entry *dce =
+           of_search_compatible(OF_finddevice("/"), gicv3_fdt_quirks);
+       if (dce != NULL) {
+               sc->sc_gic.sc_quirks |= dce->value;
        }
 
        error = gicv3_init(&sc->sc_gic);
@@ -183,11 +179,16 @@
                gicv3_fdt_attach_mbi(sc);
        } else {
                /* Interrupt Translation Services */
-               for (int child = OF_child(phandle); child; child = OF_peer(child)) {
+               static const struct device_compatible_entry its_compat[] = {
+                       { .compat = "arm,gic-v3-its" },
+                       { 0 }
+               };
+
+               for (int child = OF_child(phandle); child;
+                    child = OF_peer(child)) {
                        if (!fdtbus_status_okay(child))
                                continue;
-                       const char * const its_compat[] = { "arm,gic-v3-its", NULL };
-                       if (of_match_compatible(child, its_compat))
+                       if (of_match_compat_data(child, its_compat))
                                gicv3_fdt_attach_its(sc, faa->faa_bst, child);
                }
        }



Home | Main Index | Thread Index | Old Index