Module Name: src Committed By: thorpej Date: Tue Jan 19 14:39:20 UTC 2021
Modified Files: src/sys/dev/ofisa: atppc_ofisa.c com_ofisa.c ess_ofisa.c if_cs_ofisa.c joy_ofisa.c lpt_ofisa.c ofisa.c sb_ofisa.c wdc_ofisa.c Log Message: of_compatible() is a hokey API (returning -1 for no match) and nothing here relies on its reverse-index return value semantics, so just use of_match_compat_data() instead. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ofisa/atppc_ofisa.c cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ofisa/com_ofisa.c \ src/sys/dev/ofisa/joy_ofisa.c cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ofisa/ess_ofisa.c cvs rdiff -u -r1.27 -r1.28 src/sys/dev/ofisa/if_cs_ofisa.c cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ofisa/lpt_ofisa.c cvs rdiff -u -r1.26 -r1.27 src/sys/dev/ofisa/ofisa.c cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ofisa/sb_ofisa.c cvs rdiff -u -r1.36 -r1.37 src/sys/dev/ofisa/wdc_ofisa.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/ofisa/atppc_ofisa.c diff -u src/sys/dev/ofisa/atppc_ofisa.c:1.10 src/sys/dev/ofisa/atppc_ofisa.c:1.11 --- src/sys/dev/ofisa/atppc_ofisa.c:1.10 Mon Apr 28 20:23:54 2008 +++ src/sys/dev/ofisa/atppc_ofisa.c Tue Jan 19 14:39:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: atppc_ofisa.c,v 1.10 2008/04/28 20:23:54 martin Exp $ */ +/* $NetBSD: atppc_ofisa.c,v 1.11 2021/01/19 14:39:20 thorpej Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: atppc_ofisa.c,v 1.10 2008/04/28 20:23:54 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: atppc_ofisa.c,v 1.11 2021/01/19 14:39:20 thorpej Exp $"); #include "opt_atppc.h" @@ -73,6 +73,12 @@ static int atppc_ofisa_dma_malloc(device bus_size_t); static void atppc_ofisa_dma_free(device_t, void **, bus_addr_t *, bus_size_t); + +static const struct device_compatible_entry compat_data[] = { + { .compat = "pnpPNP,401" }, + { 0 } +}; + /* * atppc_ofisa_match: autoconf(9) match routine */ @@ -80,11 +86,9 @@ static int atppc_ofisa_match(device_t parent, cfdata_t match, void *aux) { struct ofisa_attach_args *aa = aux; - static const char *const compatible_strings[] = { "pnpPNP,401", NULL }; - int rv = 0; + int rv; - if (of_compatible(aa->oba.oba_phandle, compatible_strings) != -1) - rv = 5; + rv = of_match_compat_data(aa->oba.oba_phandle, compat_data) ? 5 : 0; #ifdef _LPT_OFISA_MD_MATCH if (!rv) rv = lpt_ofisa_md_match(parent, match, aux); Index: src/sys/dev/ofisa/com_ofisa.c diff -u src/sys/dev/ofisa/com_ofisa.c:1.16 src/sys/dev/ofisa/com_ofisa.c:1.17 --- src/sys/dev/ofisa/com_ofisa.c:1.16 Sat Dec 8 17:46:14 2018 +++ src/sys/dev/ofisa/com_ofisa.c Tue Jan 19 14:39:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: com_ofisa.c,v 1.16 2018/12/08 17:46:14 thorpej Exp $ */ +/* $NetBSD: com_ofisa.c,v 1.17 2021/01/19 14:39:20 thorpej Exp $ */ /* * Copyright 1997, 1998 @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: com_ofisa.c,v 1.16 2018/12/08 17:46:14 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: com_ofisa.c,v 1.17 2021/01/19 14:39:20 thorpej Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -68,15 +68,18 @@ void com_ofisa_attach(device_t, device_t CFATTACH_DECL_NEW(com_ofisa, sizeof(struct com_ofisa_softc), com_ofisa_probe, com_ofisa_attach, NULL, NULL); +static const struct device_compatible_entry compat_data[] = { + { .compat = "pnpPNP,501" }, + { 0 } +}; + int com_ofisa_probe(device_t parent, cfdata_t cf, void *aux) { struct ofisa_attach_args *aa = aux; - static const char *const compatible_strings[] = { "pnpPNP,501", NULL }; - int rv = 0; + int rv; - if (of_compatible(aa->oba.oba_phandle, compatible_strings) != -1) - rv = 5; + rv = of_match_compat_data(aa->oba.oba_phandle, compat_data) ? 5 : 0; #ifdef _COM_OFISA_MD_MATCH if (!rv) rv = com_ofisa_md_match(parent, cf, aux); Index: src/sys/dev/ofisa/joy_ofisa.c diff -u src/sys/dev/ofisa/joy_ofisa.c:1.16 src/sys/dev/ofisa/joy_ofisa.c:1.17 --- src/sys/dev/ofisa/joy_ofisa.c:1.16 Fri Dec 9 17:18:35 2016 +++ src/sys/dev/ofisa/joy_ofisa.c Tue Jan 19 14:39:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: joy_ofisa.c,v 1.16 2016/12/09 17:18:35 christos Exp $ */ +/* $NetBSD: joy_ofisa.c,v 1.17 2021/01/19 14:39:20 thorpej Exp $ */ /*- * Copyright (c) 1996, 1998, 2008 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: joy_ofisa.c,v 1.16 2016/12/09 17:18:35 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: joy_ofisa.c,v 1.17 2021/01/19 14:39:20 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -58,19 +58,17 @@ static void joy_ofisa_attach(device_t, d CFATTACH_DECL_NEW(joy_ofisa, sizeof(struct joy_ofisa_softc), joy_ofisa_match, joy_ofisa_attach, NULL, NULL); +static const struct device_compatible_entry compat_data[] = { + { .compat = "pnpPNP,b02f" }, /* generic joystick */ + { 0 } +}; + static int joy_ofisa_match(device_t parent, cfdata_t match, void *aux) { struct ofisa_attach_args *aa = aux; - static const char *const compatible_strings[] = { - "pnpPNP,b02f", /* generic joystick */ - NULL, - }; - int rv = 0; - - if (of_compatible(aa->oba.oba_phandle, compatible_strings) != -1) - rv = 1; - return rv; + + return of_match_compat_data(aa->oba.oba_phandle, compat_data); } static void Index: src/sys/dev/ofisa/ess_ofisa.c diff -u src/sys/dev/ofisa/ess_ofisa.c:1.28 src/sys/dev/ofisa/ess_ofisa.c:1.29 --- src/sys/dev/ofisa/ess_ofisa.c:1.28 Wed May 8 13:40:18 2019 +++ src/sys/dev/ofisa/ess_ofisa.c Tue Jan 19 14:39:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ess_ofisa.c,v 1.28 2019/05/08 13:40:18 isaki Exp $ */ +/* $NetBSD: ess_ofisa.c,v 1.29 2021/01/19 14:39:20 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ess_ofisa.c,v 1.28 2019/05/08 13:40:18 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ess_ofisa.c,v 1.29 2021/01/19 14:39:20 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -56,24 +56,20 @@ void ess_ofisa_attach(device_t, device_t CFATTACH_DECL_NEW(ess_ofisa, sizeof(struct ess_softc), ess_ofisa_match, ess_ofisa_attach, NULL, NULL); +static const struct device_compatible_entry compat_data[] = { + { .compat = "ESST,es1887-codec" }, /* ESS 1887 */ + { .compat = "ESST,es1888-codec" }, /* ESS 1888 */ + { .compat = "ESST,es888-codec" }, /* ESS 888 */ + { 0 } +}; + int ess_ofisa_match(device_t parent, cfdata_t cf, void *aux) { struct ofisa_attach_args *aa = aux; - static const char *const compatible_strings[] = { - "ESST,es1887-codec", /* ESS 1887 */ - "ESST,es1888-codec", /* ESS 1888 */ - "ESST,es888-codec", /* ESS 888 */ - NULL, - }; - int rv = 0; - - /* XXX table */ - if (of_compatible(aa->oba.oba_phandle, compatible_strings) != -1) { - rv = 10; - } - return (rv); + /* beat generic SB */ + return of_match_compat_data(aa->oba.oba_phandle, compat_data) ? 10 : 0; } void Index: src/sys/dev/ofisa/if_cs_ofisa.c diff -u src/sys/dev/ofisa/if_cs_ofisa.c:1.27 src/sys/dev/ofisa/if_cs_ofisa.c:1.28 --- src/sys/dev/ofisa/if_cs_ofisa.c:1.27 Fri Dec 9 17:18:35 2016 +++ src/sys/dev/ofisa/if_cs_ofisa.c Tue Jan 19 14:39:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_cs_ofisa.c,v 1.27 2016/12/09 17:18:35 christos Exp $ */ +/* $NetBSD: if_cs_ofisa.c,v 1.28 2021/01/19 14:39:20 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_cs_ofisa.c,v 1.27 2016/12/09 17:18:35 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_cs_ofisa.c,v 1.28 2021/01/19 14:39:20 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -66,20 +66,20 @@ static void cs_ofisa_attach(device_t, de CFATTACH_DECL_NEW(cs_ofisa, sizeof(struct cs_softc_isa), cs_ofisa_match, cs_ofisa_attach, NULL, NULL); +static const struct device_compatible_entry compat_data[] = { + { .compat = "CRUS,CS8900" }, + /* XXX CS8920, CS8920M? */ + /* XXX PNP names? */ + { 0 } +}; + int cs_ofisa_match(device_t parent, cfdata_t cf, void *aux) { struct ofisa_attach_args *aa = aux; - static const char *const compatible_strings[] = { - "CRUS,CS8900", - /* XXX CS8920, CS8920M? */ - /* XXX PNP names? */ - NULL, - }; - int rv = 0; + int rv; - if (of_compatible(aa->oba.oba_phandle, compatible_strings) != -1) - rv = 5; + rv = of_match_compat_data(aa->oba.oba_phandle, compat_data) ? 5 : 0; #ifdef _CS_OFISA_MD_MATCH if (rv == 0) rv = cs_ofisa_md_match(parent, cf, aux); Index: src/sys/dev/ofisa/lpt_ofisa.c diff -u src/sys/dev/ofisa/lpt_ofisa.c:1.15 src/sys/dev/ofisa/lpt_ofisa.c:1.16 --- src/sys/dev/ofisa/lpt_ofisa.c:1.15 Sat Oct 27 17:18:27 2012 +++ src/sys/dev/ofisa/lpt_ofisa.c Tue Jan 19 14:39:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lpt_ofisa.c,v 1.15 2012/10/27 17:18:27 chs Exp $ */ +/* $NetBSD: lpt_ofisa.c,v 1.16 2021/01/19 14:39:20 thorpej Exp $ */ /* * Copyright 1997, 1998 @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lpt_ofisa.c,v 1.15 2012/10/27 17:18:27 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lpt_ofisa.c,v 1.16 2021/01/19 14:39:20 thorpej Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -68,15 +68,18 @@ void lpt_ofisa_attach(device_t, device_t CFATTACH_DECL_NEW(lpt_ofisa, sizeof(struct lpt_ofisa_softc), lpt_ofisa_probe, lpt_ofisa_attach, NULL, NULL); +static const struct device_compatible_entry compat_data[] = { + { .compat = "pnpPNP,401" }, + { 0 } +}; + int lpt_ofisa_probe(device_t parent, cfdata_t cf, void *aux) { struct ofisa_attach_args *aa = aux; - static const char *const compatible_strings[] = { "pnpPNP,401", NULL }; - int rv = 0; + int rv; - if (of_compatible(aa->oba.oba_phandle, compatible_strings) != -1) - rv = 5; + rv = of_match_compat_data(aa->oba.oba_phandle, compat_data) ? 5 : 0; #ifdef _LPT_OFISA_MD_MATCH if (!rv) rv = lpt_ofisa_md_match(parent, cf, aux); Index: src/sys/dev/ofisa/ofisa.c diff -u src/sys/dev/ofisa/ofisa.c:1.26 src/sys/dev/ofisa/ofisa.c:1.27 --- src/sys/dev/ofisa/ofisa.c:1.26 Mon Sep 3 16:29:32 2018 +++ src/sys/dev/ofisa/ofisa.c Tue Jan 19 14:39:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ofisa.c,v 1.26 2018/09/03 16:29:32 riastradh Exp $ */ +/* $NetBSD: ofisa.c,v 1.27 2021/01/19 14:39:20 thorpej Exp $ */ /* * Copyright 1997, 1998 @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ofisa.c,v 1.26 2018/09/03 16:29:32 riastradh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofisa.c,v 1.27 2021/01/19 14:39:20 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -75,16 +75,18 @@ ofisaprint(void *aux, const char *pnp) return UNCONF; } +static const struct device_compatible_entry compat_data[] = { + { .compat = "pnpPNP,a00" }, + { 0 } +}; + int ofisamatch(device_t parent, cfdata_t cf, void *aux) { struct ofbus_attach_args *oba = aux; - static const char *const compatible_strings[] = { "pnpPNP,a00", NULL }; - int rv = 0; - - if (of_compatible(oba->oba_phandle, compatible_strings) != -1) - rv = 5; + int rv; + rv = of_match_compat_data(oba->oba_phandle, compat_data) ? 5 : 0; #ifdef _OFISA_MD_MATCH if (!rv) rv = ofisa_md_match(parent, cf, aux); Index: src/sys/dev/ofisa/sb_ofisa.c diff -u src/sys/dev/ofisa/sb_ofisa.c:1.19 src/sys/dev/ofisa/sb_ofisa.c:1.20 --- src/sys/dev/ofisa/sb_ofisa.c:1.19 Wed May 8 13:40:18 2019 +++ src/sys/dev/ofisa/sb_ofisa.c Tue Jan 19 14:39:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: sb_ofisa.c,v 1.19 2019/05/08 13:40:18 isaki Exp $ */ +/* $NetBSD: sb_ofisa.c,v 1.20 2021/01/19 14:39:20 thorpej Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sb_ofisa.c,v 1.19 2019/05/08 13:40:18 isaki Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sb_ofisa.c,v 1.20 2021/01/19 14:39:20 thorpej Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -58,28 +58,24 @@ void sb_ofisa_attach(device_t, device_t, CFATTACH_DECL_NEW(sb_ofisa, sizeof(struct sbdsp_softc), sb_ofisa_match, sb_ofisa_attach, NULL, NULL); +static const struct device_compatible_entry compat_data[] = { + { .compat = "pnpPNP,b000" }, /* generic SB 1.5 */ + { .compat = "pnpPNP,b001" }, /* generic SB 2.0 */ + { .compat = "pnpPNP,b002" }, /* generic SB Pro */ + { .compat = "pnpPNP,b003" }, /* generic SB 16 */ + { 0 } +}; + int sb_ofisa_match(device_t parent, cfdata_t cf, void *aux) { struct ofisa_attach_args *aa = aux; - static const char *const compatible_strings[] = { - "pnpPNP,b000", /* generic SB 1.5 */ - "pnpPNP,b001", /* generic SB 2.0 */ - "pnpPNP,b002", /* generic SB Pro */ - "pnpPNP,b003", /* generic SB 16 */ - NULL, - }; - int rv = 0; - - if (of_compatible(aa->oba.oba_phandle, compatible_strings) != -1) { - /* - * Use a low match priority so that a more specific driver - * can match, e.g. a native ESS driver. - */ - rv = 1; - } - return (rv); + /* + * Use a low match priority so that a more specific driver + * can match, e.g. a native ESS driver. + */ + return of_match_compat_data(aa->oba.oba_phandle, compat_data) ? 1 : 0; } void Index: src/sys/dev/ofisa/wdc_ofisa.c diff -u src/sys/dev/ofisa/wdc_ofisa.c:1.36 src/sys/dev/ofisa/wdc_ofisa.c:1.37 --- src/sys/dev/ofisa/wdc_ofisa.c:1.36 Fri Oct 20 07:06:07 2017 +++ src/sys/dev/ofisa/wdc_ofisa.c Tue Jan 19 14:39:20 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: wdc_ofisa.c,v 1.36 2017/10/20 07:06:07 jdolecek Exp $ */ +/* $NetBSD: wdc_ofisa.c,v 1.37 2021/01/19 14:39:20 thorpej Exp $ */ /* * Copyright 1997, 1998 @@ -38,7 +38,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: wdc_ofisa.c,v 1.36 2017/10/20 07:06:07 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdc_ofisa.c,v 1.37 2021/01/19 14:39:20 thorpej Exp $"); #include <sys/param.h> #include <sys/device.h> @@ -71,15 +71,18 @@ static void wdc_ofisa_attach(device_t, d CFATTACH_DECL_NEW(wdc_ofisa, sizeof(struct wdc_ofisa_softc), wdc_ofisa_probe, wdc_ofisa_attach, NULL, NULL); +static const struct device_compatible_entry compat_data[] = { + { .compat = "pnpPNP,600" }, + { 0 } +}; + static int wdc_ofisa_probe(device_t parent, cfdata_t cf, void *aux) { struct ofisa_attach_args *aa = aux; - static const char *const compatible_strings[] = { "pnpPNP,600", NULL }; - int rv = 0; + int rv; - if (of_compatible(aa->oba.oba_phandle, compatible_strings) != -1) - rv = 5; + rv = of_match_compat_data(aa->oba.oba_phandle, compat_data) ? 5 : 0; #ifdef _WDC_OFISA_MD_MATCH if (!rv) rv = wdc_ofisa_md_match(parent, cf, aux);