summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/tty_msts.c9
-rw-r--r--sys/kern/tty_nmea.c9
2 files changed, 12 insertions, 6 deletions
diff --git a/sys/kern/tty_msts.c b/sys/kern/tty_msts.c
index f3e66d6d51c..660e9e2a0ee 100644
--- a/sys/kern/tty_msts.c
+++ b/sys/kern/tty_msts.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_msts.c,v 1.3 2008/05/06 08:51:44 mbalmer Exp $ */
+/* $OpenBSD: tty_msts.c,v 1.4 2008/06/11 17:11:36 mbalmer Exp $ */
/*
* Copyright (c) 2008 Marc Balmer <mbalmer@openbsd.org>
@@ -52,7 +52,7 @@ void mstsattach(int);
#define TRUSTTIME (10 * 60) /* 10 minutes */
#endif
-int msts_count; /* this is wrong, it should really be a SLIST */
+int msts_count, msts_nxid;
static int t_trust;
struct msts {
@@ -102,7 +102,8 @@ mstsopen(dev_t dev, struct tty *tp)
return error;
np = malloc(sizeof(struct msts), M_DEVBUF, M_WAITOK|M_ZERO);
snprintf(np->timedev.xname, sizeof(np->timedev.xname), "msts%d",
- msts_count++);
+ msts_nxid++);
+ msts_count++;
np->time.status = SENSOR_S_UNKNOWN;
np->time.type = SENSOR_TIMEDELTA;
#ifndef MSTS_DEBUG
@@ -148,6 +149,8 @@ mstsclose(struct tty *tp, int flags)
free(np, M_DEVBUF);
tp->t_sc = NULL;
msts_count--;
+ if (msts_count == 0)
+ msts_nxid = 0;
return linesw[TTYDISC].l_close(tp, flags);
}
diff --git a/sys/kern/tty_nmea.c b/sys/kern/tty_nmea.c
index b5c6a9022c5..4e10f2e1ccc 100644
--- a/sys/kern/tty_nmea.c
+++ b/sys/kern/tty_nmea.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_nmea.c,v 1.26 2008/05/05 19:57:01 mbalmer Exp $ */
+/* $OpenBSD: tty_nmea.c,v 1.27 2008/06/11 17:11:36 mbalmer Exp $ */
/*
* Copyright (c) 2006, 2007, 2008 Marc Balmer <mbalmer@openbsd.org>
@@ -49,7 +49,7 @@ void nmeaattach(int);
#define TRUSTTIME (10 * 60) /* 10 minutes */
#endif
-int nmea_count; /* this is wrong, it should really be a SLIST */
+int nmea_count, nmea_nxid;
static int t_trust;
struct nmea {
@@ -101,7 +101,8 @@ nmeaopen(dev_t dev, struct tty *tp)
return error;
np = malloc(sizeof(struct nmea), M_DEVBUF, M_WAITOK | M_ZERO);
snprintf(np->timedev.xname, sizeof(np->timedev.xname), "nmea%d",
- nmea_count++);
+ nmea_nxid++);
+ nmea_count++;
np->time.status = SENSOR_S_UNKNOWN;
np->time.type = SENSOR_TIMEDELTA;
np->time.value = 0LL;
@@ -144,6 +145,8 @@ nmeaclose(struct tty *tp, int flags)
free(np, M_DEVBUF);
tp->t_sc = NULL;
nmea_count--;
+ if (nmea_count == 0)
+ nmea_nxid = 0;
return linesw[TTYDISC].l_close(tp, flags);
}