summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authorThorsten Lockert <tholo@cvs.openbsd.org>2004-06-24 19:35:28 +0000
committerThorsten Lockert <tholo@cvs.openbsd.org>2004-06-24 19:35:28 +0000
commitc6cc17e855e1d9fe177fba41d00de6e89fdc852e (patch)
treebdc6bde04c820ca59fe49d60185cf6ac40b44e30 /sys/dev/ic
parent128dd71ffeec48b94e085c757b3626553d619e7c (diff)
This moves access to wall and uptime variables in MI code,
encapsulating all such access into wall-defined functions that makes sure locking is done as needed. It also cleans up some uses of wall time vs. uptime some places, but there is sure to be more of these needed as well, particularily in MD code. Also, many current calls to microtime() should probably be changed to getmicrotime(), or to the {,get}microuptime() versions. ok art@ deraadt@ aaron@ matthieu@ beck@ sturm@ millert@ others "Oh, that is not your problem!" from miod@
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/isp_openbsd.h18
-rw-r--r--sys/dev/ic/nslm7x.c18
-rw-r--r--sys/dev/ic/smc90cx6.c12
3 files changed, 19 insertions, 29 deletions
diff --git a/sys/dev/ic/isp_openbsd.h b/sys/dev/ic/isp_openbsd.h
index 8969ca5cad8..af343770bea 100644
--- a/sys/dev/ic/isp_openbsd.h
+++ b/sys/dev/ic/isp_openbsd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: isp_openbsd.h,v 1.24 2003/03/30 16:57:42 krw Exp $ */
+/* $OpenBSD: isp_openbsd.h,v 1.25 2004/06/24 19:35:23 tholo Exp $ */
/*
* OpenBSD Specific definitions for the Qlogic ISP Host Adapter
*/
@@ -125,10 +125,10 @@ struct isposinfo {
if (!MUST_POLL(isp)) \
ISP_LOCK(isp)
-#define NANOTIME_T struct timeval
-#define GET_NANOTIME microtime
-#define GET_NANOSEC(x) (((x)->tv_sec * 1000000 + (x)->tv_usec) * 1000)
-#define NANOTIME_SUB isp_microtime_sub
+#define NANOTIME_T struct timespec
+#define GET_NANOTIME nanotime
+#define GET_NANOSEC(x) (((x)->tv_sec * 1000000000 + (x)->tv_nsec))
+#define NANOTIME_SUB isp_nanotime_sub
#define MAXISPREQUEST(isp) 256
@@ -307,7 +307,7 @@ void isp_uninit(struct ispsoftc *);
static INLINE void isp_lock(struct ispsoftc *);
static INLINE void isp_unlock(struct ispsoftc *);
static INLINE u_int64_t
-isp_microtime_sub(struct timeval *, struct timeval *);
+isp_nanotime_sub(struct timespec *, struct timespec *);
static void isp_wait_complete(struct ispsoftc *);
/*
@@ -365,11 +365,11 @@ isp_unlock(struct ispsoftc *isp)
}
static INLINE u_int64_t
-isp_microtime_sub(struct timeval *b, struct timeval *a)
+isp_nanotime_sub(struct timespec *b, struct timespec *a)
{
- struct timeval x;
+ struct timespec x;
u_int64_t elapsed;
- timersub(b, a, &x);
+ timespecsub(b, a, &x);
elapsed = GET_NANOSEC(&x);
if (elapsed == 0)
elapsed++;
diff --git a/sys/dev/ic/nslm7x.c b/sys/dev/ic/nslm7x.c
index 30866f69603..d6e8aa62cdd 100644
--- a/sys/dev/ic/nslm7x.c
+++ b/sys/dev/ic/nslm7x.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nslm7x.c,v 1.7 2004/05/07 07:00:46 grange Exp $ */
+/* $OpenBSD: nslm7x.c,v 1.8 2004/06/24 19:35:23 tholo Exp $ */
/* $NetBSD: nslm7x.c,v 1.17 2002/11/15 14:55:41 ad Exp $ */
/*-
@@ -376,22 +376,18 @@ lm_gtredata(sme, tred)
struct envsys_tre_data *tred;
{
static const struct timeval onepointfive = { 1, 500000 };
- struct timeval t;
+ struct timeval t, mtv;
struct lm_softc *sc = sme->sme_cookie;
- int i, s;
+ int i;
/* read new values at most once every 1.5 seconds */
timeradd(&sc->lastread, &onepointfive, &t);
- s = splclock();
- i = timercmp(&mono_time, &t, >);
+ getmicrouptime(&mtv);
+ i = timercmp(&mtv, &t, >);
if (i) {
- sc->lastread.tv_sec = mono_time.tv_sec;
- sc->lastread.tv_usec = mono_time.tv_usec;
- }
- splx(s);
-
- if (i)
+ sc->lastread = mtv;
sc->refresh_sensor_data(sc);
+ }
*tred = sc->sensors[tred->sensor];
diff --git a/sys/dev/ic/smc90cx6.c b/sys/dev/ic/smc90cx6.c
index d011c1308c8..72f09855f94 100644
--- a/sys/dev/ic/smc90cx6.c
+++ b/sys/dev/ic/smc90cx6.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: smc90cx6.c,v 1.9 2004/06/21 23:50:35 tholo Exp $ */
+/* $OpenBSD: smc90cx6.c,v 1.10 2004/06/24 19:35:23 tholo Exp $ */
/* $NetBSD: smc90cx6.c,v 1.17 1996/05/07 01:43:18 thorpej Exp $ */
/*
@@ -667,10 +667,7 @@ bah_start(ifp)
sc->sc_arccom.ac_if.if_timer = ARCTIMEOUT;
#ifdef BAHTIMINGS
- bcopy((caddr_t)&time,
- (caddr_t)&(sc->sc_stats.lasttxstart_tv),
- sizeof(struct timeval));
-
+ getmicrotime(&sc->sc_stats.lasttxstart_tv);
sc->sc_stats.lasttxstart_mics = clkread();
#endif
}
@@ -979,10 +976,7 @@ bah_tint(sc, isr)
ifp->if_timer = ARCTIMEOUT;
#ifdef BAHTIMINGS
- bcopy((caddr_t)&time,
- (caddr_t)&(sc->sc_stats.lasttxstart_tv),
- sizeof(struct timeval));
-
+ getmicrotime(&sc->sc_stats.lasttxstart_tv);
sc->sc_stats.lasttxstart_mics = clkread();
#endif