When the user updates the sensor device's refresh timer, reset the
callout immediately rather than waiting for the previous timer to expire.
This commit is contained in:
parent
a12cad24be
commit
59fe847ec9
@ -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 @@ sme_remove_userprops(void)
|
||||
* 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 @@ sme_add_property_dictionary(struct sysmon_envsys *sme, prop_array_t array,
|
||||
* ...
|
||||
*
|
||||
*/
|
||||
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 @@ sme_userset_dictionary(struct sysmon_envsys *sme, prop_dictionary_t udict,
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ int
|
||||
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,14 +498,38 @@ sme_events_init(struct sysmon_envsys *sme)
|
||||
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));
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
@ -630,7 +648,7 @@ sme_events_check(void *arg)
|
||||
else
|
||||
timo = SME_EVTIMO;
|
||||
if (!sysmon_low_power)
|
||||
callout_schedule(&sme->sme_callout, timo);
|
||||
sme_schedule_callout(sme);
|
||||
mutex_exit(&sme->sme_callout_mtx);
|
||||
}
|
||||
|
||||
|
@ -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_check(void *);
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user