- ENVSYS_SETDICTIONARY: use sysmon_envsys_release() if there's an error.

- sme_events_worker: use sme_list_mtx when accessing to the sysmon_envsys
  linked list.
- Improve the comments in sysmon_envsysvar.h about the mutexes and condvar.
This commit is contained in:
xtraeme 2007-07-23 17:51:16 +00:00
parent 960a35be0a
commit ac5a2b6161
3 changed files with 20 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysmon_envsys.c,v 1.42 2007/07/23 08:45:51 xtraeme Exp $ */
/* $NetBSD: sysmon_envsys.c,v 1.43 2007/07/23 17:51:16 xtraeme Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -75,7 +75,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.42 2007/07/23 08:45:51 xtraeme Exp $");
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.43 2007/07/23 17:51:16 xtraeme Exp $");
#include <sys/param.h>
#include <sys/types.h>
@ -154,11 +154,10 @@ struct sme_sensor_names {
static SLIST_HEAD(, sme_sensor_names) sme_names_list;
static prop_dictionary_t sme_propd;
static kmutex_t sme_list_mtx;
static kcondvar_t sme_list_cv;
static int sme_uniqsensors = 0;
kmutex_t sme_mtx, sme_event_mtx;
kmutex_t sme_mtx, sme_list_mtx, sme_event_mtx;
kcondvar_t sme_event_cv;
#ifdef COMPAT_40
@ -297,6 +296,7 @@ sysmonioctl_envsys(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
sme = sysmon_envsys_find(devname);
if (sme == NULL) {
DPRINTF(("%s: NULL sme\n", __func__));
sysmon_envsys_release(sme);
prop_object_release(udict);
error = EINVAL;
break;
@ -309,6 +309,7 @@ sysmonioctl_envsys(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
obj = prop_dictionary_get(sme_propd, devname);
if (prop_object_type(obj) != PROP_TYPE_ARRAY) {
DPRINTF(("%s: array device failed\n", __func__));
sysmon_envsys_release(sme);
prop_object_release(udict);
error = EINVAL;
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysmon_envsys_events.c,v 1.18 2007/07/21 15:16:58 xtraeme Exp $ */
/* $NetBSD: sysmon_envsys_events.c,v 1.19 2007/07/23 17:51:17 xtraeme Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.18 2007/07/21 15:16:58 xtraeme Exp $");
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.19 2007/07/23 17:51:17 xtraeme Exp $");
#include <sys/param.h>
#include <sys/types.h>
@ -95,7 +95,7 @@ static const struct sme_sensor_event sme_sensor_event[] = {
static struct workqueue *seewq;
static struct callout seeco;
static bool sme_events_initialized = false;
kmutex_t sme_mtx, sme_event_mtx, sme_event_init_mtx;
kmutex_t sme_mtx, sme_list_mtx, sme_event_mtx, sme_event_init_mtx;
kcondvar_t sme_event_cv;
/* 10 seconds of timeout for the callout */
@ -559,13 +559,15 @@ sme_events_worker(struct work *wk, void *arg)
* We have to find the sme device by looking
* at the power envsys device name.
*/
mutex_enter(&sme_mtx);
mutex_enter(&sme_list_mtx);
LIST_FOREACH(sme, &sysmon_envsys_list, sme_list)
if (strcmp(sme->sme_name, see->pes.pes_dvname) == 0)
break;
mutex_exit(&sme_list_mtx);
KASSERT(sme != NULL);
mutex_enter(&sme_mtx);
/* get the sensor with the index specified in see->snum */
edata = &sme->sme_sensor_data[see->snum];

View File

@ -1,4 +1,4 @@
/* $NetBSD: sysmon_envsysvar.h,v 1.11 2007/07/22 18:17:03 xtraeme Exp $ */
/* $NetBSD: sysmon_envsysvar.h,v 1.12 2007/07/23 17:51:17 xtraeme Exp $ */
/*-
* Copyright (c) 2007 The NetBSD Foundation, Inc.
@ -92,9 +92,14 @@ typedef struct sme_event_drv {
} sme_event_drv_t;
/* common */
extern kmutex_t sme_mtx; /* mutex for the sysmon envsys devices */
extern kmutex_t sme_event_mtx; /* mutex for the sysmon envsys events */
extern kmutex_t sme_event_init_mtx; /* mutex to initialize/destroy see */
extern kmutex_t sme_mtx; /* mutex to protect the sysmon envsys data */
extern kmutex_t sme_list_mtx; /* mutex to protect the sysmon envsys list */
extern kmutex_t sme_event_mtx; /* mutex to protect the sme event data */
/* mutex to intialize/destroy the sysmon envsys events framework */
extern kmutex_t sme_event_init_mtx;
/* condition variable to wait for the worker thread to finish */
extern kcondvar_t sme_event_cv;
/* linked list for the sysmon envsys devices */