Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/sys/dev/sysmon Pull up following revision(s) (requested b...
details: https://anonhg.NetBSD.org/src/rev/9183af4bfd93
branches: netbsd-6
changeset: 775347:9183af4bfd93
user: riz <riz%NetBSD.org@localhost>
date: Wed Oct 17 21:06:55 2012 +0000
description:
Pull up following revision(s) (requested by pgoyette in ticket #544):
sys/dev/sysmon/sysmon_envsysvar.h: revision 1.42
sys/dev/sysmon/sysmon_envsys_events.c: revision 1.99
sys/dev/sysmon/sysmon_envsys.c: revision 1.119
When unregistering a sensor device, make sure we unregister and delete
all the associated events.
diffstat:
sys/dev/sysmon/sysmon_envsys.c | 5 +-
sys/dev/sysmon/sysmon_envsys_events.c | 62 +++++++++++++++++++++++++++++++---
sys/dev/sysmon/sysmon_envsysvar.h | 3 +-
3 files changed, 61 insertions(+), 9 deletions(-)
diffs (152 lines):
diff -r 9854c1dbcb3f -r 9183af4bfd93 sys/dev/sysmon/sysmon_envsys.c
--- a/sys/dev/sysmon/sysmon_envsys.c Wed Oct 17 20:59:08 2012 +0000
+++ b/sys/dev/sysmon/sysmon_envsys.c Wed Oct 17 21:06:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.117 2011/08/01 12:28:53 mbalmer Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.117.8.1 2012/10/17 21:06:56 riz 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.117 2011/08/01 12:28:53 mbalmer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.117.8.1 2012/10/17 21:06:56 riz Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -602,6 +602,7 @@
/*
* remove it and decrement the sensors count.
*/
+ sme_event_unregister_sensor(sme, edata);
TAILQ_REMOVE(&sme->sme_sensors_list, edata, sensors_head);
sme->sme_nsensors--;
sysmon_envsys_release(sme, true);
diff -r 9854c1dbcb3f -r 9183af4bfd93 sys/dev/sysmon/sysmon_envsys_events.c
--- a/sys/dev/sysmon/sysmon_envsys_events.c Wed Oct 17 20:59:08 2012 +0000
+++ b/sys/dev/sysmon/sysmon_envsys_events.c Wed Oct 17 21:06:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys_events.c,v 1.98 2011/06/08 16:14:57 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys_events.c,v 1.98.8.1 2012/10/17 21:06:55 riz 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.98 2011/06/08 16:14:57 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.98.8.1 2012/10/17 21:06:55 riz Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -77,6 +77,8 @@
static bool sme_battery_critical(envsys_data_t *);
static bool sme_acadapter_check(void);
+static void sme_remove_event(sme_event_t *, struct sysmon_envsys *);
+
/*
* sme_event_register:
*
@@ -334,11 +336,11 @@
break;
if (strcmp(see->see_pes.pes_dvname, sme->sme_name) == 0) {
- LIST_REMOVE(see, see_list);
DPRINTF(("%s: event %s %d removed (%s)\n", __func__,
see->see_pes.pes_sensname, see->see_type,
sme->sme_name));
- kmem_free(see, sizeof(*see));
+ sme_remove_event(see, sme);
+
evcounter--;
}
}
@@ -386,6 +388,56 @@
DPRINTF(("%s: removed dev=%s sensor=%s type=%d\n",
__func__, see->see_pes.pes_dvname, sensor, type));
+
+ sme_remove_event(see, sme);
+
+ mutex_exit(&sme->sme_mtx);
+ return 0;
+}
+
+/*
+ * sme_event_unregister_sensor:
+ *
+ * + Unregisters any event associated with a specific sensor
+ * The caller must already own the sme_mtx.
+ */
+int
+sme_event_unregister_sensor(struct sysmon_envsys *sme, envsys_data_t *edata)
+{
+ sme_event_t *see;
+ bool found = false;
+
+ KASSERT(mutex_owned(&sme->sme_mtx));
+ LIST_FOREACH(see, &sme->sme_events_list, see_list) {
+ if (see->see_edata == edata) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ return EINVAL;
+
+ /*
+ * Wait for the event to finish its work, remove from the list
+ * and release resouces.
+ */
+ while (see->see_flags & SEE_EVENT_WORKING)
+ cv_wait(&sme->sme_condvar, &sme->sme_mtx);
+
+ DPRINTF(("%s: removed dev=%s sensor=%s\n",
+ __func__, see->see_pes.pes_dvname, edata->desc));
+
+ sme_remove_event(see, sme);
+
+ return 0;
+}
+
+static void
+sme_remove_event(sme_event_t *see, struct sysmon_envsys *sme)
+{
+
+ KASSERT(mutex_owned(&sme->sme_mtx));
+
LIST_REMOVE(see, see_list);
/*
* So the events list is empty, we'll do the following:
@@ -395,10 +447,8 @@
*/
if (LIST_EMPTY(&sme->sme_events_list))
sme_events_destroy(sme);
- mutex_exit(&sme->sme_mtx);
kmem_free(see, sizeof(*see));
- return 0;
}
/*
diff -r 9854c1dbcb3f -r 9183af4bfd93 sys/dev/sysmon/sysmon_envsysvar.h
--- a/sys/dev/sysmon/sysmon_envsysvar.h Wed Oct 17 20:59:08 2012 +0000
+++ b/sys/dev/sysmon/sysmon_envsysvar.h Wed Oct 17 21:06:55 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsysvar.h,v 1.40 2011/06/19 03:09:43 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsysvar.h,v 1.40.8.1 2012/10/17 21:06:55 riz Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -126,6 +126,7 @@
struct sysmon_envsys *, sysmon_envsys_lim_t *,
uint32_t, int, int);
int sme_event_unregister(struct sysmon_envsys *, const char *, int);
+int sme_event_unregister_sensor(struct sysmon_envsys *, envsys_data_t *);
void sme_event_unregister_all(struct sysmon_envsys *);
void sme_event_drvadd(void *);
int sme_events_init(struct sysmon_envsys *);
Home |
Main Index |
Thread Index |
Old Index