summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2008-04-07 22:50:42 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2008-04-07 22:50:42 +0000
commitbfd8c07d7d18784c1e8e8b9cf752b71043b31350 (patch)
tree1229c73c88b510a219066978b6ccf632364b091b
parentec2ba01450c82aa398fcaa130b9398631479cf1c (diff)
Allow a 1-Wire controller to request an immediate scan, and also to prevent
periodic scans. ok grange@ (until this gets replaced with a proper notification mechanism to avoid unnecessary bus polling).
-rw-r--r--sys/dev/onewire/onewire.c12
-rw-r--r--sys/dev/onewire/onewirevar.h5
2 files changed, 15 insertions, 2 deletions
diff --git a/sys/dev/onewire/onewire.c b/sys/dev/onewire/onewire.c
index e8ac801661a..fee3c266e83 100644
--- a/sys/dev/onewire/onewire.c
+++ b/sys/dev/onewire/onewire.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: onewire.c,v 1.8 2007/10/09 17:06:18 gilles Exp $ */
+/* $OpenBSD: onewire.c,v 1.9 2008/04/07 22:50:41 miod Exp $ */
/*
* Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org>
@@ -51,6 +51,7 @@ struct onewire_softc {
TAILQ_HEAD(, onewire_device) sc_devs;
int sc_dying;
+ int sc_flags;
u_int64_t sc_rombuf[ONEWIRE_MAXDEVS];
};
@@ -98,11 +99,18 @@ onewire_attach(struct device *parent, struct device *self, void *aux)
struct onewirebus_attach_args *oba = aux;
sc->sc_bus = oba->oba_bus;
+ sc->sc_flags = oba->oba_flags;
rw_init(&sc->sc_lock, sc->sc_dev.dv_xname);
TAILQ_INIT(&sc->sc_devs);
printf("\n");
+ if (sc->sc_flags & ONEWIRE_SCAN_NOW) {
+ onewire_scan(sc);
+ if (sc->sc_flags & ONEWIRE_NO_PERIODIC_SCAN)
+ return;
+ }
+
kthread_create_deferred(onewire_createthread, sc);
}
@@ -393,6 +401,8 @@ onewire_thread(void *arg)
while (!sc->sc_dying) {
onewire_scan(sc);
+ if (sc->sc_flags & ONEWIRE_NO_PERIODIC_SCAN)
+ break;
tsleep(sc->sc_thread, PWAIT, "owidle", ONEWIRE_SCANTIME * hz);
}
diff --git a/sys/dev/onewire/onewirevar.h b/sys/dev/onewire/onewirevar.h
index 3aaeb3bffd3..1aa084f61ea 100644
--- a/sys/dev/onewire/onewirevar.h
+++ b/sys/dev/onewire/onewirevar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: onewirevar.h,v 1.4 2006/10/08 21:12:51 grange Exp $ */
+/* $OpenBSD: onewirevar.h,v 1.5 2008/04/07 22:50:41 miod Exp $ */
/*
* Copyright (c) 2006 Alexander Yurchenko <grange@openbsd.org>
@@ -57,6 +57,9 @@ int onewire_search(void *, u_int64_t *, int, u_int64_t);
/* Bus attachment */
struct onewirebus_attach_args {
struct onewire_bus * oba_bus;
+ int oba_flags;
+#define ONEWIRE_SCAN_NOW 0x0001
+#define ONEWIRE_NO_PERIODIC_SCAN 0x0002
};
int onewirebus_print(void *, const char *);