Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/ofw There is not much point in of_compatible() retur...



details:   https://anonhg.NetBSD.org/src/rev/8f092aec1081
branches:  trunk
changeset: 980184:8f092aec1081
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Jan 26 14:49:41 2021 +0000

description:
There is not much point in of_compatible() returning -1 for "no match"
and >= 0 for "match".  Just make it return 0 for "no match" and >0 for
"match" so it can be treated like a boolean expression.

As such of_match_compatible() (a wrapper around of_compatible()) is now
obsolete, and will be removed once all call sites are converted to an
appropriate replacement.

diffstat:

 sys/arch/macppc/dev/awacs.c           |  16 +++++-------
 sys/arch/macppc/dev/mediabay.c        |   6 ++--
 sys/arch/macppc/dev/obio.c            |   6 ++--
 sys/arch/macppc/dev/pmu.c             |   8 +++---
 sys/arch/macppc/dev/wdc_obio.c        |   6 ++--
 sys/arch/macppc/macppc/interrupts.c   |   6 ++--
 sys/arch/macppc/macppc/machdep.c      |  14 +++++-----
 sys/arch/macppc/macppc/pic_heathrow.c |   6 ++--
 sys/arch/macppc/macppc/pic_u3_ht.c    |   8 +++---
 sys/arch/macppc/pci/pci_machdep.c     |   6 ++--
 sys/dev/ofw/ofw_subr.c                |  45 ++++++++++------------------------
 11 files changed, 54 insertions(+), 73 deletions(-)

diffs (truncated from 447 to 300 lines):

diff -r 20c3202a3cdc -r 8f092aec1081 sys/arch/macppc/dev/awacs.c
--- a/sys/arch/macppc/dev/awacs.c       Tue Jan 26 14:09:11 2021 +0000
+++ b/sys/arch/macppc/dev/awacs.c       Tue Jan 26 14:49:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: awacs.c,v 1.48 2019/06/08 08:02:37 isaki Exp $ */
+/*     $NetBSD: awacs.c,v 1.49 2021/01/26 14:49:41 thorpej Exp $       */
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: awacs.c,v 1.48 2019/06/08 08:02:37 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: awacs.c,v 1.49 2021/01/26 14:49:41 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/audioio.h>
@@ -373,7 +373,7 @@
        cv_init(&sc->sc_event, "awacs_wait");
 
        /* check if the chip is a screamer */
-       sc->sc_screamer = (of_compatible(ca->ca_node, screamer) != -1);
+       sc->sc_screamer = of_compatible(ca->ca_node, screamer);
        if (!sc->sc_screamer) {
                /* look for 'sound' child node */
                int sound_node;
@@ -381,8 +381,7 @@
                sound_node = OF_child(ca->ca_node);
                while ((sound_node != 0) && (!sc->sc_screamer)) {
 
-                       sc->sc_screamer = 
-                           (of_compatible(sound_node, screamer) != -1);
+                       sc->sc_screamer = of_compatible(sound_node, screamer);
                        sound_node = OF_peer(sound_node);
                }
        }
@@ -426,7 +425,7 @@
         */
        perch = OF_finddevice("/perch");
        root_node = OF_finddevice("/");
-       if (of_compatible(root_node, detect_reversed) != -1) {
+       if (of_compatible(root_node, detect_reversed)) {
 
                /* 0x02 is for the microphone jack, high active */
                /*
@@ -435,8 +434,7 @@
                 */
                sc->sc_headphones_mask = 0x8;
                sc->sc_headphones_in = 0x0;
-       } else if ((perch != -1) ||
-           (of_compatible(root_node, use_gpio4) != -1)) {
+       } else if ((perch != -1) || of_compatible(root_node, use_gpio4)) {
                /*
                 * this is for the beige G3's 'personality card' which uses
                 * yet another wiring of the headphone detect GPIOs
@@ -450,7 +448,7 @@
                sc->sc_headphones_in = 0x8;
        }
 
-       if (of_compatible(root_node, no_parallel_output) != -1)
+       if (of_compatible(root_node, no_parallel_output))
                sc->sc_need_parallel_output = 0;
        else {
                sc->sc_need_parallel_output = 1;
diff -r 20c3202a3cdc -r 8f092aec1081 sys/arch/macppc/dev/mediabay.c
--- a/sys/arch/macppc/dev/mediabay.c    Tue Jan 26 14:09:11 2021 +0000
+++ b/sys/arch/macppc/dev/mediabay.c    Tue Jan 26 14:49:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mediabay.c,v 1.22 2011/07/26 08:36:02 macallan Exp $   */
+/*     $NetBSD: mediabay.c,v 1.23 2021/01/26 14:49:41 thorpej Exp $    */
 
 /*-
  * Copyright (C) 1999 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mediabay.c,v 1.22 2011/07/26 08:36:02 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mediabay.c,v 1.23 2021/01/26 14:49:41 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -132,7 +132,7 @@
        irq = ca->ca_intr[0];
        itype = IST_EDGE;
 
-       if (of_compatible(ca->ca_node, mediabay_keylargo) != -1) {
+       if (of_compatible(ca->ca_node, mediabay_keylargo)) {
                sc->sc_type = MB_CONTROLLER_KEYLARGO;
                sc->sc_fcr = sc->sc_addr + 2;
        } else {
diff -r 20c3202a3cdc -r 8f092aec1081 sys/arch/macppc/dev/obio.c
--- a/sys/arch/macppc/dev/obio.c        Tue Jan 26 14:09:11 2021 +0000
+++ b/sys/arch/macppc/dev/obio.c        Tue Jan 26 14:49:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: obio.c,v 1.47 2020/10/25 16:39:00 nia Exp $    */
+/*     $NetBSD: obio.c,v 1.48 2021/01/26 14:49:41 thorpej Exp $        */
 
 /*-
  * Copyright (C) 1998  Internet Research Institute, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.47 2020/10/25 16:39:00 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: obio.c,v 1.48 2021/01/26 14:49:41 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -368,7 +368,7 @@
        char name[32];
        int child, use_dfs, cpunode, hiclock;
 
-       if (of_compatible(sc->sc_node, keylargo) == -1)
+       if (! of_compatible(sc->sc_node, keylargo))
                return;
 
        if (OF_getprop(node, "reg", reg, sizeof(reg)) < 4)
diff -r 20c3202a3cdc -r 8f092aec1081 sys/arch/macppc/dev/pmu.c
--- a/sys/arch/macppc/dev/pmu.c Tue Jan 26 14:09:11 2021 +0000
+++ b/sys/arch/macppc/dev/pmu.c Tue Jan 26 14:49:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmu.c,v 1.34 2020/07/14 08:58:03 martin Exp $ */
+/*     $NetBSD: pmu.c,v 1.35 2021/01/26 14:49:41 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2006 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.34 2020/07/14 08:58:03 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmu.c,v 1.35 2021/01/26 14:49:41 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -428,10 +428,10 @@
        }
 
        /* attach batteries */
-       if (of_compatible(root_node, has_legacy_battery) != -1) {
+       if (of_compatible(root_node, has_legacy_battery)) {
 
                pmu_attach_legacy_battery(sc);
-       } else if (of_compatible(root_node, has_two_smart_batteries) != -1) {
+       } else if (of_compatible(root_node, has_two_smart_batteries)) {
 
                pmu_attach_smart_battery(sc, 0);
                pmu_attach_smart_battery(sc, 1);
diff -r 20c3202a3cdc -r 8f092aec1081 sys/arch/macppc/dev/wdc_obio.c
--- a/sys/arch/macppc/dev/wdc_obio.c    Tue Jan 26 14:09:11 2021 +0000
+++ b/sys/arch/macppc/dev/wdc_obio.c    Tue Jan 26 14:49:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wdc_obio.c,v 1.61 2017/10/20 07:06:07 jdolecek Exp $   */
+/*     $NetBSD: wdc_obio.c,v 1.62 2021/01/26 14:49:41 thorpej Exp $    */
 
 /*-
  * Copyright (c) 1998, 2003 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.61 2017/10/20 07:06:07 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wdc_obio.c,v 1.62 2021/01/26 14:49:41 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -107,7 +107,7 @@
            strcmp(ca->ca_name, "ide") == 0)
                return 1;
 
-       if (of_compatible(ca->ca_node, ata_names) >= 0)
+       if (of_compatible(ca->ca_node, ata_names))
                return 1;
 
        return 0;
diff -r 20c3202a3cdc -r 8f092aec1081 sys/arch/macppc/macppc/interrupts.c
--- a/sys/arch/macppc/macppc/interrupts.c       Tue Jan 26 14:09:11 2021 +0000
+++ b/sys/arch/macppc/macppc/interrupts.c       Tue Jan 26 14:49:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: interrupts.c,v 1.7 2018/05/11 22:48:38 macallan Exp $ */
+/*     $NetBSD: interrupts.c,v 1.8 2021/01/26 14:49:41 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: interrupts.c,v 1.7 2018/05/11 22:48:38 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: interrupts.c,v 1.8 2021/01/26 14:49:41 thorpej Exp $");
 
 #include "opt_multiprocessor.h"
 
@@ -81,7 +81,7 @@
        aprint_debug("macio: %08x\n", macio);
 
        pic = OF_child(macio);
-       while ((pic != 0) && (of_compatible(pic, compat) == -1))
+       while ((pic != 0) && !of_compatible(pic, compat))
                pic = OF_peer(pic);
 
        aprint_debug("pic: %08x\n", pic);
diff -r 20c3202a3cdc -r 8f092aec1081 sys/arch/macppc/macppc/machdep.c
--- a/sys/arch/macppc/macppc/machdep.c  Tue Jan 26 14:09:11 2021 +0000
+++ b/sys/arch/macppc/macppc/machdep.c  Tue Jan 26 14:49:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.171 2020/07/14 08:55:07 martin Exp $     */
+/*     $NetBSD: machdep.c,v 1.172 2021/01/26 14:49:41 thorpej Exp $    */
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.171 2020/07/14 08:55:07 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.172 2021/01/26 14:49:41 thorpej Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_ddb.h"
@@ -411,27 +411,27 @@
 
        node = OF_finddevice("/");
 
-       if (of_compatible(node, bl_rev_models) != -1) {
+       if (of_compatible(node, bl_rev_models)) {
                prop_dictionary_set_bool(dict, "backlight_level_reverted", 1);
        }
-       if (of_compatible(node, clamshell) != -1) {
+       if (of_compatible(node, clamshell)) {
                prop_data_t edid;
 
                edid = prop_data_create_nocopy(edid_clamshell, sizeof(edid_clamshell));
                prop_dictionary_set(dict, "EDID", edid);
                prop_object_release(edid);
        }
-       if (of_compatible(node, pismo) != -1) {
+       if (of_compatible(node, pismo)) {
                prop_data_t edid;
 
                edid = prop_data_create_nocopy(edid_pismo, sizeof(edid_pismo));
                prop_dictionary_set(dict, "EDID", edid);
                prop_object_release(edid);
        }
-       if (of_compatible(node, mini1) != -1) {
+       if (of_compatible(node, mini1)) {
                prop_dictionary_set_bool(dict, "dvi-internal", 1);
        }
-       if (of_compatible(node, mini2) != -1) {
+       if (of_compatible(node, mini2)) {
                prop_dictionary_set_bool(dict, "dvi-external", 1);
        }
 }
diff -r 20c3202a3cdc -r 8f092aec1081 sys/arch/macppc/macppc/pic_heathrow.c
--- a/sys/arch/macppc/macppc/pic_heathrow.c     Tue Jan 26 14:09:11 2021 +0000
+++ b/sys/arch/macppc/macppc/pic_heathrow.c     Tue Jan 26 14:49:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pic_heathrow.c,v 1.11 2017/06/16 18:48:22 macallan Exp $ */
+/*     $NetBSD: pic_heathrow.c,v 1.12 2021/01/26 14:49:41 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic_heathrow.c,v 1.11 2017/06/16 18:48:22 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_heathrow.c,v 1.12 2021/01/26 14:49:41 thorpej Exp $");
 
 #include "opt_interrupt.h"
 
@@ -88,7 +88,7 @@
        if (heathrow == -1)
                return FALSE;
 
-       if (of_compatible(heathrow, compat) == -1)
+       if (! of_compatible(heathrow, compat))
                return FALSE;
 
        if (OF_getprop(heathrow, "assigned-addresses", reg, sizeof(reg)) != 20) 
diff -r 20c3202a3cdc -r 8f092aec1081 sys/arch/macppc/macppc/pic_u3_ht.c
--- a/sys/arch/macppc/macppc/pic_u3_ht.c        Tue Jan 26 14:09:11 2021 +0000
+++ b/sys/arch/macppc/macppc/pic_u3_ht.c        Tue Jan 26 14:49:41 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pic_u3_ht.c,v 1.9 2020/07/15 09:58:34 rin Exp $        */
+/*     $NetBSD: pic_u3_ht.c,v 1.10 2021/01/26 14:49:41 thorpej Exp $   */
 /*-
  * Copyright (c) 2013 Phileas Fogg
  * All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.9 2020/07/15 09:58:34 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_u3_ht.c,v 1.10 2021/01/26 14:49:41 thorpej Exp $");
 
 #include "opt_openpic.h"
 #include "opt_interrupt.h"



Home | Main Index | Thread Index | Old Index