summaryrefslogtreecommitdiff
path: root/sys/dev/sysmon
diff options
context:
space:
mode:
authorxtraeme <xtraeme@NetBSD.org>2008-04-02 11:19:22 +0000
committerxtraeme <xtraeme@NetBSD.org>2008-04-02 11:19:22 +0000
commit6dcb9dd40c5dc903e9a62b00aeefc59f88a8fbb1 (patch)
treefa89140cb7ce29f4b04fcf636e2086f2f2783334 /sys/dev/sysmon
parent247cd610f6b10f2f3aa29c5b596058344f244679 (diff)
Initialize and destroy the callout in sme_events_init() and
sme_events_destroy() respectively. And don't stop twice the callout when calling sysmon_envsys_unregister().
Diffstat (limited to 'sys/dev/sysmon')
-rw-r--r--sys/dev/sysmon/sysmon_envsys.c14
-rw-r--r--sys/dev/sysmon/sysmon_envsys_events.c10
2 files changed, 9 insertions, 15 deletions
diff --git a/sys/dev/sysmon/sysmon_envsys.c b/sys/dev/sysmon/sysmon_envsys.c
index 2ee2cfa604a..ca517d7b5f2 100644
--- a/sys/dev/sysmon/sysmon_envsys.c
+++ b/sys/dev/sysmon/sysmon_envsys.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.82 2008/04/01 12:25:30 xtraeme Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.83 2008/04/02 11:19:22 xtraeme Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.82 2008/04/01 12:25:30 xtraeme Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.83 2008/04/02 11:19:22 xtraeme Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -488,7 +488,6 @@ sysmon_envsys_create(void)
sme = kmem_zalloc(sizeof(*sme), KM_SLEEP);
TAILQ_INIT(&sme->sme_sensors_list);
LIST_INIT(&sme->sme_events_list);
- callout_init(&sme->sme_callout, CALLOUT_MPSAFE);
mutex_init(&sme->sme_mtx, MUTEX_DEFAULT, IPL_NONE);
cv_init(&sme->sme_condvar, "sme_wait");
@@ -512,7 +511,6 @@ sysmon_envsys_destroy(struct sysmon_envsys *sme)
edata = TAILQ_FIRST(&sme->sme_sensors_list);
TAILQ_REMOVE(&sme->sme_sensors_list, edata, sensors_head);
}
- callout_destroy(&sme->sme_callout);
mutex_destroy(&sme->sme_mtx);
cv_destroy(&sme->sme_condvar);
kmem_free(sme, sizeof(*sme));
@@ -856,13 +854,9 @@ sysmon_envsys_unregister(struct sysmon_envsys *sme)
KASSERT(sme != NULL);
/*
- * Unregister all events associated with device and stop the
- * callout; after this it's safe to unregister it.
+ * Unregister all events associated with device.
*/
sme_event_unregister_all(sme);
- mutex_enter(&sme->sme_mtx);
- sysmon_envsys_acquire(sme, true);
- callout_stop(&sme->sme_callout);
/*
* Decrement global sensors counter (only used for compatibility
* with previous API) and remove the device from the list.
@@ -871,8 +865,6 @@ sysmon_envsys_unregister(struct sysmon_envsys *sme)
sysmon_envsys_next_sensor_index -= sme->sme_nsensors;
LIST_REMOVE(sme, sme_list);
mutex_exit(&sme_global_mtx);
- sysmon_envsys_release(sme, true);
- mutex_exit(&sme->sme_mtx);
/*
* Remove the device (and all its objects) from the global dictionary.
diff --git a/sys/dev/sysmon/sysmon_envsys_events.c b/sys/dev/sysmon/sysmon_envsys_events.c
index 3f35d0c659b..4508ef088b5 100644
--- a/sys/dev/sysmon/sysmon_envsys_events.c
+++ b/sys/dev/sysmon/sysmon_envsys_events.c
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys_events.c,v 1.53 2008/04/01 17:01:34 xtraeme Exp $ */
+/* $NetBSD: sysmon_envsys_events.c,v 1.54 2008/04/02 11:19:22 xtraeme Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.53 2008/04/01 17:01:34 xtraeme Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.54 2008/04/02 11:19:22 xtraeme Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -364,6 +364,7 @@ sme_events_init(struct sysmon_envsys *sme)
return error;
mutex_init(&sme->sme_callout_mtx, MUTEX_DEFAULT, IPL_SOFTCLOCK);
+ callout_init(&sme->sme_callout, CALLOUT_MPSAFE);
callout_setfunc(&sme->sme_callout, sme_events_check, sme);
callout_schedule(&sme->sme_callout, timo);
sme->sme_flags |= SME_CALLOUT_INITIALIZED;
@@ -385,11 +386,12 @@ sme_events_destroy(struct sysmon_envsys *sme)
KASSERT(mutex_owned(&sme->sme_mtx));
callout_stop(&sme->sme_callout);
+ workqueue_destroy(sme->sme_wq);
+ mutex_destroy(&sme->sme_callout_mtx);
+ callout_destroy(&sme->sme_callout);
sme->sme_flags &= ~SME_CALLOUT_INITIALIZED;
DPRINTF(("%s: events framework destroyed for '%s'\n",
__func__, sme->sme_name));
- workqueue_destroy(sme->sme_wq);
- mutex_destroy(&sme->sme_callout_mtx);
}
/*