Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/sysmon When the user updates the sensor device's ref...
details: https://anonhg.NetBSD.org/src/rev/124f851648b6
branches: trunk
changeset: 760176:124f851648b6
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Thu Dec 30 03:59:59 2010 +0000
description:
When the user updates the sensor device's refresh timer, reset the
callout immediately rather than waiting for the previous timer to
expire.
diffstat:
sys/dev/sysmon/sysmon_envsys.c | 14 +++++++++---
sys/dev/sysmon/sysmon_envsys_events.c | 38 +++++++++++++++++++++++++---------
sys/dev/sysmon/sysmon_envsysvar.h | 3 +-
3 files changed, 40 insertions(+), 15 deletions(-)
diffs (152 lines):
diff -r bc859f759bd9 -r 124f851648b6 sys/dev/sysmon/sysmon_envsys.c
--- a/sys/dev/sysmon/sysmon_envsys.c Thu Dec 30 00:46:38 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys.c Thu Dec 30 03:59:59 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.111 2010/12/16 16:08:57 njoly Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.112 2010/12/30 03:59:59 pgoyette 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.111 2010/12/16 16:08:57 njoly Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.112 2010/12/30 03:59:59 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -1175,6 +1175,7 @@
* Restore default timeout value.
*/
sme->sme_events_timeout = SME_EVENTS_DEFTIMEOUT;
+ sme_schedule_callout(sme);
sysmon_envsys_release(sme, false);
}
mutex_exit(&sme_global_mtx);
@@ -1214,8 +1215,10 @@
* ...
*
*/
- if (!sme->sme_events_timeout)
+ if (sme->sme_events_timeout == 0) {
sme->sme_events_timeout = SME_EVENTS_DEFTIMEOUT;
+ sme_schedule_callout(sme);
+ }
if (!prop_dictionary_set_uint64(pdict, "refresh-timeout",
sme->sme_events_timeout)) {
@@ -1805,7 +1808,10 @@
error = EINVAL;
else {
mutex_enter(&sme->sme_mtx);
- sme->sme_events_timeout = refresh_timo;
+ if (sme->sme_events_timeout != refresh_timo) {
+ sme->sme_events_timeout = refresh_timo;
+ sme_schedule_callout(sme);
+ }
mutex_exit(&sme->sme_mtx);
}
}
diff -r bc859f759bd9 -r 124f851648b6 sys/dev/sysmon/sysmon_envsys_events.c
--- a/sys/dev/sysmon/sysmon_envsys_events.c Thu Dec 30 00:46:38 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys_events.c Thu Dec 30 03:59:59 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys_events.c,v 1.96 2010/12/15 17:17:17 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys_events.c,v 1.97 2010/12/30 03:59:59 pgoyette 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.96 2010/12/15 17:17:17 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.97 2010/12/30 03:59:59 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -486,16 +486,10 @@
sme_events_init(struct sysmon_envsys *sme)
{
int error = 0;
- uint64_t timo;
KASSERT(sme != NULL);
KASSERT(mutex_owned(&sme->sme_mtx));
- if (sme->sme_events_timeout)
- timo = sme->sme_events_timeout * hz;
- else
- timo = SME_EVTIMO;
-
error = workqueue_create(&sme->sme_wq, sme->sme_name,
sme_events_worker, sme, PRI_NONE, IPL_SOFTCLOCK, WQ_MPSAFE);
if (error)
@@ -504,8 +498,8 @@
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;
+ sme_schedule_callout(sme);
DPRINTF(("%s: events framework initialized for '%s'\n",
__func__, sme->sme_name));
@@ -513,6 +507,30 @@
}
/*
+ * sme_schedule_callout
+ *
+ * (Re)-schedule the device's callout timer
+ */
+void
+sme_schedule_callout(struct sysmon_envsys *sme)
+{
+ uint64_t timo;
+
+ KASSERT(sme != NULL);
+
+ if ((sme->sme_flags & SME_CALLOUT_INITIALIZED) == 0)
+ return;
+
+ if (sme->sme_events_timeout)
+ timo = sme->sme_events_timeout * hz;
+ else
+ timo = SME_EVTIMO;
+
+ callout_stop(&sme->sme_callout);
+ callout_schedule(&sme->sme_callout, timo);
+}
+
+/*
* sme_events_destroy:
*
* + Destroys the event framework for this device: callout
@@ -630,7 +648,7 @@
else
timo = SME_EVTIMO;
if (!sysmon_low_power)
- callout_schedule(&sme->sme_callout, timo);
+ sme_schedule_callout(sme);
mutex_exit(&sme->sme_callout_mtx);
}
diff -r bc859f759bd9 -r 124f851648b6 sys/dev/sysmon/sysmon_envsysvar.h
--- a/sys/dev/sysmon/sysmon_envsysvar.h Thu Dec 30 00:46:38 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsysvar.h Thu Dec 30 03:59:59 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsysvar.h,v 1.37 2010/12/15 17:17:17 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsysvar.h,v 1.38 2010/12/30 03:59:59 pgoyette Exp $ */
/*-
* Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -133,6 +133,7 @@
void sme_events_worker(struct work *, void *);
void sme_deliver_event(sme_event_t *);
int sme_update_limits(struct sysmon_envsys *, envsys_data_t *);
+void sme_schedule_callout(struct sysmon_envsys *);
/*
* common functions to create/update objects in a dictionary.
Home |
Main Index |
Thread Index |
Old Index