summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2005-11-15 16:23:31 +0000
committerderaadt <deraadt@openbsd.org>2005-11-15 16:23:31 +0000
commit2d6ad09b2ac12a8ba8e83e2904229304c618d4a0 (patch)
tree3bbd2ed322aaae6fbcac1458ea7f418e34c4019d /sys
parentmove lm87 to dev/i2c; ok kettenis (diff)
downloadwireguard-openbsd-2d6ad09b2ac12a8ba8e83e2904229304c618d4a0.tar.xz
wireguard-openbsd-2d6ad09b2ac12a8ba8e83e2904229304c618d4a0.zip
instead of passing OF nodes down to the drivers, pass name/compat string
pointers. This lets their match() functions actually make real decisions. OF-capable machines will pass name/compat pointers, but other machines will not. grudging ok kettenis
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/macppc/dev/maci2c.c23
-rw-r--r--sys/arch/macppc/dev/maci2cvar.h10
-rw-r--r--sys/dev/i2c/i2c.c4
-rw-r--r--sys/dev/i2c/i2cvar.h4
-rw-r--r--sys/dev/i2c/lm75.c9
-rw-r--r--sys/dev/i2c/lm87.c30
6 files changed, 42 insertions, 38 deletions
diff --git a/sys/arch/macppc/dev/maci2c.c b/sys/arch/macppc/dev/maci2c.c
index caea3cf2ab9..5b99452f577 100644
--- a/sys/arch/macppc/dev/maci2c.c
+++ b/sys/arch/macppc/dev/maci2c.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: maci2c.c,v 1.1 2005/11/11 16:22:50 kettenis Exp $ */
+/* $OpenBSD: maci2c.c,v 1.2 2005/11/15 16:23:34 deraadt Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -47,7 +47,8 @@ void
maciic_attach(struct device *parent, struct device *self, void *aux)
{
struct maci2cbus_attach_args *iba = aux;
- struct maci2c_attach_args ia;
+ struct i2c_attach_args ia;
+ char name[32], compat[32];
u_int32_t reg;
int node;
@@ -58,7 +59,16 @@ maciic_attach(struct device *parent, struct device *self, void *aux)
continue;
ia.ia_tag = iba->iba_tag;
ia.ia_addr = (reg >> 1);
- ia.ia_node = node;
+ ia.ia_name = NULL;
+ ia.ia_compat = NULL;
+ memset(compat, 0, sizeof compat);
+ memset(name, 0, sizeof name);
+ if (OF_getprop(node, "name", &name,
+ sizeof name))
+ ia.ia_name = name;
+ if (OF_getprop(node, "compatible", &compat,
+ sizeof compat))
+ ia.ia_compat = compat;
config_found(self, &ia, maciic_print);
}
}
@@ -66,13 +76,10 @@ maciic_attach(struct device *parent, struct device *self, void *aux)
int
maciic_print(void *aux, const char *pnp)
{
- struct maci2c_attach_args *ia = aux;
- char name[32];
+ struct i2c_attach_args *ia = aux;
if (pnp != NULL) {
- OF_getprop(ia->ia_node, "name", name, sizeof name);
- name[sizeof(name) - 1] = 0;
- printf("%s at %s", name, pnp);
+ printf("%s at %s", ia->ia_name, pnp);
}
printf(" addr 0x%x", ia->ia_addr);
diff --git a/sys/arch/macppc/dev/maci2cvar.h b/sys/arch/macppc/dev/maci2cvar.h
index 066a6f0ed98..7dc43716b20 100644
--- a/sys/arch/macppc/dev/maci2cvar.h
+++ b/sys/arch/macppc/dev/maci2cvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: maci2cvar.h,v 1.1 2005/11/11 16:22:50 kettenis Exp $ */
+/* $OpenBSD: maci2cvar.h,v 1.2 2005/11/15 16:23:34 deraadt Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -22,11 +22,3 @@ struct maci2cbus_attach_args {
i2c_tag_t iba_tag;
int iba_node;
};
-
-struct maci2c_attach_args {
- struct i2c_attach_args ia_ia;
- int ia_node;
-};
-
-#define ia_tag ia_ia.ia_tag
-#define ia_addr ia_ia.ia_addr
diff --git a/sys/dev/i2c/i2c.c b/sys/dev/i2c/i2c.c
index 8cfd6c8cbba..76165044a74 100644
--- a/sys/dev/i2c/i2c.c
+++ b/sys/dev/i2c/i2c.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i2c.c,v 1.1 2004/05/23 17:33:43 grange Exp $ */
+/* $OpenBSD: i2c.c,v 1.2 2005/11/15 16:23:31 deraadt Exp $ */
/* $NetBSD: i2c.c,v 1.1 2003/09/30 00:35:31 thorpej Exp $ */
/*
@@ -98,6 +98,8 @@ iic_search(struct device *parent, void *arg, void *aux)
ia.ia_tag = sc->sc_tag;
ia.ia_addr = cf->cf_loc[IICCF_ADDR];
ia.ia_size = cf->cf_loc[IICCF_SIZE];
+ ia.ia_name = NULL;
+ ia.ia_compat = NULL;
if (cf->cf_attach->ca_match(parent, cf, &ia) > 0)
config_attach(parent, cf, &ia, iic_print);
diff --git a/sys/dev/i2c/i2cvar.h b/sys/dev/i2c/i2cvar.h
index 7065df99932..bbda44a6595 100644
--- a/sys/dev/i2c/i2cvar.h
+++ b/sys/dev/i2c/i2cvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: i2cvar.h,v 1.1 2004/05/23 17:33:43 grange Exp $ */
+/* $OpenBSD: i2cvar.h,v 1.2 2005/11/15 16:23:31 deraadt Exp $ */
/* $NetBSD: i2cvar.h,v 1.1 2003/09/30 00:35:31 thorpej Exp $ */
/*
@@ -101,6 +101,8 @@ struct i2c_attach_args {
i2c_tag_t ia_tag; /* our controller */
i2c_addr_t ia_addr; /* address of device */
int ia_size; /* size (for EEPROMs) */
+ char *ia_name;
+ char *ia_compat;
};
/*
diff --git a/sys/dev/i2c/lm75.c b/sys/dev/i2c/lm75.c
index 64b5959923c..e833ba12bed 100644
--- a/sys/dev/i2c/lm75.c
+++ b/sys/dev/i2c/lm75.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lm75.c,v 1.3 2005/11/13 00:19:17 deraadt Exp $ */
+/* $OpenBSD: lm75.c,v 1.4 2005/11/15 16:23:31 deraadt Exp $ */
/* $NetBSD: lm75.c,v 1.1 2003/09/30 00:35:31 thorpej Exp $ */
/*
* Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
@@ -95,6 +95,13 @@ lmtemp_match(struct device *parent, void *match, void *aux)
{
struct i2c_attach_args *ia = aux;
+ if (ia->ia_compat) {
+ if (strcmp(ia->ia_compat, "lm75") == 0 ||
+ strcmp(ia->ia_compat, "ds1775") == 0)
+ return (1);
+ return (0);
+ }
+
/* XXX: we allow wider mask for LM77 */
if ((ia->ia_addr & LM75_ADDRMASK) == LM75_ADDR)
return (1);
diff --git a/sys/dev/i2c/lm87.c b/sys/dev/i2c/lm87.c
index 30130ef1297..e67bca2b019 100644
--- a/sys/dev/i2c/lm87.c
+++ b/sys/dev/i2c/lm87.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lm87.c,v 1.1 2005/11/15 16:19:15 deraadt Exp $ */
+/* $OpenBSD: lm87.c,v 1.2 2005/11/15 16:23:31 deraadt Exp $ */
/*
* Copyright (c) 2005 Mark Kettenis
@@ -21,8 +21,7 @@
#include <sys/device.h>
#include <sys/sensors.h>
-#include <dev/ofw/openfirm.h>
-#include <arch/macppc/dev/maci2cvar.h>
+#include <dev/i2c/i2cvar.h>
/* LM87 registers */
#define LM87_2_5V 0x20
@@ -76,27 +75,22 @@ struct cfdriver lmenv_cd = {
int
lmenv_match(struct device *parent, void *match, void *aux)
{
- struct maci2c_attach_args *ia = aux;
- char compat[32], name[32];
+ struct i2c_attach_args *ia = aux;
- memset(compat, 0, sizeof compat);
- OF_getprop(ia->ia_node, "compatible", &compat, sizeof compat);
- if (strcmp(compat, "lm87cimt") == 0)
- return (1);
-
- memset(name, 0, sizeof name);
- OF_getprop(ia->ia_node, "name", &name, sizeof name);
- if (strcmp(name, "lm87") == 0)
- return (1);
-
- return (0);
+ if (ia->ia_name) {
+ if (strcmp(ia->ia_name, "lm87") == 0 ||
+ strcmp(ia->ia_name, "lm87cimt") == 0)
+ return (1);
+ return (0);
+ }
+ return (1); /* accept the address given */
}
void
lmenv_attach(struct device *parent, struct device *self, void *aux)
{
struct lmenv_softc *sc = (struct lmenv_softc *)self;
- struct maci2c_attach_args *ia = aux;
+ struct i2c_attach_args *ia = aux;
u_int8_t cmd, data;
int i;
@@ -173,7 +167,7 @@ lmenv_attach(struct device *parent, struct device *self, void *aux)
sizeof(sc->sc_sensor[LMENV_FAN2].desc));
if (sensor_task_register(sc, lmenv_refresh, 5)) {
- printf(": unable to register update task\n");
+ printf(", unable to register update task\n");
return;
}