summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-11-12 10:47:07 +0000
committerpatrick <patrick@openbsd.org>2020-11-12 10:47:07 +0000
commit1ac62f4e146a95bf6fb5690037d3f5c73c30fae3 (patch)
tree96d956c2fba107b55f57953530c96a9066e9b69b
parentwitness: detect and report uninitialized (or zeroed) lock usage (diff)
downloadwireguard-openbsd-1ac62f4e146a95bf6fb5690037d3f5c73c30fae3.tar.xz
wireguard-openbsd-1ac62f4e146a95bf6fb5690037d3f5c73c30fae3.zip
FDT-based I2C drivers should not use OF_* API in the match code, since
on machines with ACPI ia->ia_cookie will be an ACPI node instead of an OF node. We'll still get into trouble with APCI devices that provide a string that matches, but we'll worry when that happens. ok kettenis@
-rw-r--r--sys/dev/fdt/bd718x7.c7
-rw-r--r--sys/dev/fdt/fanpwr.c9
-rw-r--r--sys/dev/fdt/rkpmic.c7
-rw-r--r--sys/dev/fdt/sypwr.c5
4 files changed, 12 insertions, 16 deletions
diff --git a/sys/dev/fdt/bd718x7.c b/sys/dev/fdt/bd718x7.c
index d3bf474613d..baec9f63ccc 100644
--- a/sys/dev/fdt/bd718x7.c
+++ b/sys/dev/fdt/bd718x7.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bd718x7.c,v 1.2 2020/03/27 12:23:52 patrick Exp $ */
+/* $OpenBSD: bd718x7.c,v 1.3 2020/11/12 10:47:07 patrick Exp $ */
/*
* Copyright (c) 2019 Patrick Wildt <patrick@blueri.se>
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
@@ -74,10 +74,9 @@ int
bdpmic_match(struct device *parent, void *match, void *aux)
{
struct i2c_attach_args *ia = aux;
- int node = *(int *)ia->ia_cookie;
- return (OF_is_compatible(node, "rohm,bd71837") ||
- OF_is_compatible(node, "rohm,bd71847"));
+ return (strcmp(ia->ia_name, "rohm,bd71837") == 0 ||
+ strcmp(ia->ia_name, "rohm,bd71847") == 0);
}
void
diff --git a/sys/dev/fdt/fanpwr.c b/sys/dev/fdt/fanpwr.c
index 22ef3058b65..483ae576823 100644
--- a/sys/dev/fdt/fanpwr.c
+++ b/sys/dev/fdt/fanpwr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fanpwr.c,v 1.3 2019/05/24 18:54:12 kettenis Exp $ */
+/* $OpenBSD: fanpwr.c,v 1.4 2020/11/12 10:47:07 patrick Exp $ */
/*
* Copyright (c) 2018 Mark Kettenis <kettenis@openbsd.org>
*
@@ -77,11 +77,10 @@ int
fanpwr_match(struct device *parent, void *match, void *aux)
{
struct i2c_attach_args *ia = aux;
- int node = *(int *)ia->ia_cookie;
- return (OF_is_compatible(node, "fcs,fan53555") ||
- OF_is_compatible(node, "silergy,syr827") ||
- OF_is_compatible(node, "silergy,syr828"));
+ return (strcmp(ia->ia_name, "fcs,fan53555") == 0 ||
+ strcmp(ia->ia_name, "silergy,syr827") == 0 ||
+ strcmp(ia->ia_name, "silergy,syr828") == 0);
}
void
diff --git a/sys/dev/fdt/rkpmic.c b/sys/dev/fdt/rkpmic.c
index 4ef4226bbcc..fd4c8ed3038 100644
--- a/sys/dev/fdt/rkpmic.c
+++ b/sys/dev/fdt/rkpmic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rkpmic.c,v 1.6 2018/07/31 10:09:25 kettenis Exp $ */
+/* $OpenBSD: rkpmic.c,v 1.7 2020/11/12 10:47:07 patrick Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
*
@@ -107,10 +107,9 @@ int
rkpmic_match(struct device *parent, void *match, void *aux)
{
struct i2c_attach_args *ia = aux;
- int node = *(int *)ia->ia_cookie;
- return (OF_is_compatible(node, "rockchip,rk805") ||
- OF_is_compatible(node, "rockchip,rk808"));
+ return (strcmp(ia->ia_name, "rockchip,rk805") == 0 ||
+ strcmp(ia->ia_name, "rockchip,rk808") == 0);
}
void
diff --git a/sys/dev/fdt/sypwr.c b/sys/dev/fdt/sypwr.c
index ae79509f297..be710a173b2 100644
--- a/sys/dev/fdt/sypwr.c
+++ b/sys/dev/fdt/sypwr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sypwr.c,v 1.3 2019/09/29 13:27:48 kettenis Exp $ */
+/* $OpenBSD: sypwr.c,v 1.4 2020/11/12 10:47:07 patrick Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
*
@@ -62,9 +62,8 @@ int
sypwr_match(struct device *parent, void *match, void *aux)
{
struct i2c_attach_args *ia = aux;
- int node = *(int *)ia->ia_cookie;
- return (OF_is_compatible(node, "silergy,sy8106a"));
+ return (strcmp(ia->ia_name, "silergy,sy8106a") == 0);
}
void