summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/ic/nslm7x.c7
-rw-r--r--sys/dev/isa/it.c7
-rw-r--r--sys/dev/isa/nsclpcsio_isa.c8
-rw-r--r--sys/dev/pci/viaenv.c7
-rw-r--r--sys/sys/sensors.h12
5 files changed, 19 insertions, 22 deletions
diff --git a/sys/dev/ic/nslm7x.c b/sys/dev/ic/nslm7x.c
index 0aafacd79ba..fdceb302b34 100644
--- a/sys/dev/ic/nslm7x.c
+++ b/sys/dev/ic/nslm7x.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nslm7x.c,v 1.3 2003/08/05 13:42:36 couderc Exp $ */
+/* $OpenBSD: nslm7x.c,v 1.4 2004/01/12 14:10:53 grange Exp $ */
/* $NetBSD: nslm7x.c,v 1.17 2002/11/15 14:55:41 ad Exp $ */
/*-
@@ -151,8 +151,6 @@ void
lm_attach(struct lm_softc *lmsc)
{
u_int i;
- extern int nsensors;
- extern struct sensors_head sensors;
/* Install default bank selection routine, if none given. */
if (lmsc->lm_banksel == NULL)
@@ -169,8 +167,7 @@ lm_attach(struct lm_softc *lmsc)
for (i = 0; i < lmsc->numsensors; ++i) {
strlcpy(lmsc->sensors[i].device, lmsc->sc_dev.dv_xname,
sizeof(lmsc->sensors[i].device));
- lmsc->sensors[i].num = nsensors++;
- SLIST_INSERT_HEAD(&sensors, &lmsc->sensors[i], list);
+ SENSOR_ADD(&lmsc->sensors[i]);
}
/* Refresh sensors data every 1.5 seconds */
diff --git a/sys/dev/isa/it.c b/sys/dev/isa/it.c
index 2997649bfcd..21093327eac 100644
--- a/sys/dev/isa/it.c
+++ b/sys/dev/isa/it.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: it.c,v 1.4 2003/11/05 20:57:10 grange Exp $ */
+/* $OpenBSD: it.c,v 1.5 2004/01/12 14:10:53 grange Exp $ */
/*
* Copyright (c) 2003 Julien Bordet <zejames@greyhats.org>
@@ -122,8 +122,6 @@ it_attach(struct device *parent, struct device *self, void *aux)
struct isa_attach_args *ia = aux;
int i;
u_int8_t cr;
- extern int nsensors;
- extern struct sensors_head sensors;
iobase = ia->ipa_io[0].base;
iot = sc->it_iot = ia->ia_iot;
@@ -161,8 +159,7 @@ it_attach(struct device *parent, struct device *self, void *aux)
for (i = 0; i < sc->numsensors; ++i) {
strlcpy(sc->sensors[i].device, sc->sc_dev.dv_xname,
sizeof(sc->sensors[i].device));
- sc->sensors[i].num = nsensors++;
- SLIST_INSERT_HEAD(&sensors, &sc->sensors[i], list);
+ SENSOR_ADD(&sc->sensors[i]);
}
timeout_set(&it_timeout, it_refresh, sc);
diff --git a/sys/dev/isa/nsclpcsio_isa.c b/sys/dev/isa/nsclpcsio_isa.c
index 710ce8b8a36..43cd6a54ba0 100644
--- a/sys/dev/isa/nsclpcsio_isa.c
+++ b/sys/dev/isa/nsclpcsio_isa.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nsclpcsio_isa.c,v 1.1 2004/01/05 17:27:29 markus Exp $ */
+/* $OpenBSD: nsclpcsio_isa.c,v 1.2 2004/01/12 14:10:53 grange Exp $ */
/* $NetBSD: nsclpcsio_isa.c,v 1.5 2002/10/22 16:18:26 drochner Exp $ */
/*
@@ -226,9 +226,6 @@ nsclpcsio_isa_attach(parent, self, aux)
int iobase;
int i;
- extern int nsensors;
- extern struct sensors_head sensors;
-
iobase = ia->ipa_io[0].base;
sc->sc_iot = iot = ia->ia_iot;
if (bus_space_map(ia->ia_iot, iobase, 2, 0, &sc->sc_ioh)) {
@@ -250,8 +247,7 @@ nsclpcsio_isa_attach(parent, self, aux)
continue;
strlcpy(sc->sensors[i].device, sc->sc_dev.dv_xname,
sizeof(sc->sensors[i].device));
- sc->sensors[i].num = nsensors++;
- SLIST_INSERT_HEAD(&sensors, &sc->sensors[i], list);
+ SENSOR_ADD(&sc->sensors[i]);
}
if (sc->sc_tms || sc->sc_vlm) {
timeout_set(&nsclpcsio_timeout, nsclpcsio_refresh, sc);
diff --git a/sys/dev/pci/viaenv.c b/sys/dev/pci/viaenv.c
index 76498c84256..301673057a4 100644
--- a/sys/dev/pci/viaenv.c
+++ b/sys/dev/pci/viaenv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: viaenv.c,v 1.2 2003/10/16 18:38:40 grange Exp $ */
+/* $OpenBSD: viaenv.c,v 1.3 2004/01/12 14:10:53 grange Exp $ */
/* $NetBSD: viaenv.c,v 1.9 2002/10/02 16:51:59 thorpej Exp $ */
/*
@@ -246,8 +246,6 @@ viaenv_attach(struct device * parent, struct device * self, void *aux)
struct pci_attach_args *pa = aux;
pcireg_t iobase, control;
int i;
- extern int nsensors;
- extern struct sensors_head sensors;
iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, 0x70);
control = pci_conf_read(pa->pa_pc, pa->pa_tag, 0x74);
@@ -266,8 +264,7 @@ viaenv_attach(struct device * parent, struct device * self, void *aux)
for (i = 0; i < VIANUMSENSORS; ++i) {
strlcpy(sc->sc_data[i].device, sc->sc_dev.dv_xname,
sizeof(sc->sc_data[i].device));
- sc->sc_data[i].num = nsensors++;
- SLIST_INSERT_HEAD(&sensors, &sc->sc_data[i], list);
+ SENSOR_ADD(&sc->sc_data[i]);
}
for (i = 0; i <= 2; i++) {
diff --git a/sys/sys/sensors.h b/sys/sys/sensors.h
index 8befdc92178..818f281a757 100644
--- a/sys/sys/sensors.h
+++ b/sys/sys/sensors.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sensors.h,v 1.1 2003/04/25 20:06:41 grange Exp $ */
+/* $OpenBSD: sensors.h,v 1.2 2004/01/12 14:10:53 grange Exp $ */
/*
* Copyright (c) 2003 Alexander Yurchenko <grange@openbsd.org>
@@ -48,4 +48,14 @@ struct sensor {
SLIST_HEAD(sensors_head, sensor);
+#ifdef _KERNEL
+extern int nsensors;
+extern struct sensors_head sensors;
+
+#define SENSOR_ADD(s) do { \
+ (s)->num = nsensors++; \
+ SLIST_INSERT_HEAD(&sensors, (s), list); \
+} while (0)
+#endif /* _KERNEL */
+
#endif /* !_SYS_SENSORS_H_ */