Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/sysmon Validate limit-based monitoring in one place, ...
details: https://anonhg.NetBSD.org/src/rev/358f0afbe1dc
branches: trunk
changeset: 751250:358f0afbe1dc
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sat Jan 30 02:46:52 2010 +0000
description:
Validate limit-based monitoring in one place, so we can apply the
constraints to both driver-requested and user-requested monitoring.
While here, clean up some of the debugging DPRINTFs.
diffstat:
sys/dev/sysmon/sysmon_envsys.c | 48 ++++------------------------------
sys/dev/sysmon/sysmon_envsys_events.c | 42 +++++++++++++++++++++--------
2 files changed, 36 insertions(+), 54 deletions(-)
diffs (206 lines):
diff -r 43274018fb84 -r 358f0afbe1dc sys/dev/sysmon/sysmon_envsys.c
--- a/sys/dev/sysmon/sysmon_envsys.c Fri Jan 29 23:50:01 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys.c Sat Jan 30 02:46:52 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.90 2009/07/10 13:09:09 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.91 2010/01/30 02:46:52 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.90 2009/07/10 13:09:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.91 2010/01/30 02:46:52 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -1791,12 +1791,6 @@
obj2 = prop_dictionary_get(udict, "critical-capacity");
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
targetfound = true;
- if ((edata->flags & ENVSYS_FMONNOTSUPP) ||
- (edata->flags & ENVSYS_FPERCENT) == 0) {
- error = ENOTSUP;
- goto out;
- }
-
lims.sel_critmin = prop_number_integer_value(obj2);
lims.sel_flags |= PROP_BATTCAP;
}
@@ -1807,12 +1801,6 @@
obj2 = prop_dictionary_get(udict, "warning-capacity");
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
targetfound = true;
- if ((edata->flags & ENVSYS_FMONNOTSUPP) ||
- (edata->flags & ENVSYS_FPERCENT) == 0) {
- error = ENOTSUP;
- goto out;
- }
-
lims.sel_warnmin = prop_number_integer_value(obj2);
lims.sel_flags |= PROP_BATTWARN;
}
@@ -1823,13 +1811,6 @@
obj2 = prop_dictionary_get(udict, "critical-max");
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
targetfound = true;
- if (edata->units == ENVSYS_INDICATOR ||
- edata->flags &
- (ENVSYS_FPERCENT | ENVSYS_FMONNOTSUPP)) {
- error = ENOTSUP;
- goto out;
- }
-
lims.sel_critmax = prop_number_integer_value(obj2);
lims.sel_flags |= PROP_CRITMAX;
}
@@ -1840,13 +1821,6 @@
obj2 = prop_dictionary_get(udict, "warning-max");
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
targetfound = true;
- if (edata->units == ENVSYS_INDICATOR ||
- edata->flags &
- (ENVSYS_FPERCENT | ENVSYS_FMONNOTSUPP)) {
- error = ENOTSUP;
- goto out;
- }
-
lims.sel_warnmax = prop_number_integer_value(obj2);
lims.sel_flags |= PROP_WARNMAX;
}
@@ -1857,13 +1831,6 @@
obj2 = prop_dictionary_get(udict, "critical-min");
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
targetfound = true;
- if (edata->units == ENVSYS_INDICATOR ||
- edata->flags &
- (ENVSYS_FPERCENT | ENVSYS_FMONNOTSUPP)) {
- error = ENOTSUP;
- goto out;
- }
-
lims.sel_critmin = prop_number_integer_value(obj2);
lims.sel_flags |= PROP_CRITMIN;
}
@@ -1874,18 +1841,15 @@
obj2 = prop_dictionary_get(udict, "warning-min");
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
targetfound = true;
- if (edata->units == ENVSYS_INDICATOR ||
- edata->flags &
- (ENVSYS_FPERCENT | ENVSYS_FMONNOTSUPP)) {
- error = ENOTSUP;
- goto out;
- }
-
lims.sel_warnmin = prop_number_integer_value(obj2);
lims.sel_flags |= PROP_WARNMIN;
}
if (lims.sel_flags) {
+ if (edata->flags & ENVSYS_FMONNOTSUPP) {
+ error = ENOTSUP;
+ goto out;
+ }
error = sme_event_register(dict, edata, sme, &lims,
(edata->flags & ENVSYS_FPERCENT)?
PENVSYS_EVENT_CAPACITY:
diff -r 43274018fb84 -r 358f0afbe1dc sys/dev/sysmon/sysmon_envsys_events.c
--- a/sys/dev/sysmon/sysmon_envsys_events.c Fri Jan 29 23:50:01 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys_events.c Sat Jan 30 02:46:52 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys_events.c,v 1.76 2010/01/26 14:22:00 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys_events.c,v 1.77 2010/01/30 02:46:52 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.76 2010/01/26 14:22:00 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.77 2010/01/30 02:46:52 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -93,6 +93,27 @@
KASSERT(sdict != NULL);
KASSERT(edata != NULL);
KASSERT(sme != NULL);
+ KASSERT(lims != NULL);
+
+ /*
+ * Some validation first for limit-checking events
+ *
+ * Capacity limits are permitted only if the sensor has the
+ * ENVSYS_FPERCENT flag set.
+ * Value limits are permitted only if the ENVSYS_FPERCENT
+ * flag is not set and the units is not ENVSYS_INDICATOR.
+ */
+
+ DPRINTF(("%s: units %d lim-flags 0x%04x edata-flags 0x%04x\n",
+ __func__, edata->units, lims->sel_flags, edata->flags));
+
+ if ((lims->sel_flags & PROP_VAL_LIMITS) &&
+ ((edata->flags & ENVSYS_FPERCENT) ||
+ (edata->units == ENVSYS_INDICATOR)))
+ return ENOTSUP;
+ if ((lims->sel_flags & PROP_CAP_LIMITS) &&
+ !(edata->flags & ENVSYS_FPERCENT))
+ return ENOTSUP;
/*
* check if the event is already on the list and return
@@ -111,8 +132,8 @@
*/
KASSERT(edata == osee->see_edata);
- DPRINTF(("%s: dev %s sensor %s lim_flags 0x%04x event exists\n",
- __func__, sme->sme_name, edata->desc, lims->sel_flags));
+ DPRINTF(("%s: dev %s sensor %s: event type %d exists\n",
+ __func__, sme->sme_name, edata->desc, crittype));
see = osee;
if (lims->sel_flags & PROP_CRITMAX) {
@@ -125,16 +146,14 @@
}
if (lims->sel_flags & PROP_WARNMAX) {
if (lims->sel_warnmax == edata->limits.sel_warnmax) {
- DPRINTF(("%s: type=%d (warnmax exists)\n",
- __func__, crittype));
+ DPRINTF(("%s: warnmax exists\n", __func__));
error = EEXIST;
lims->sel_flags &= ~PROP_WARNMAX;
}
}
if (lims->sel_flags & (PROP_WARNMIN | PROP_BATTWARN)) {
if (lims->sel_warnmin == edata->limits.sel_warnmin) {
- DPRINTF(("%s: type=%d (warnmin exists)\n",
- __func__, crittype));
+ DPRINTF(("%s: warnmin exists\n", __func__));
error = EEXIST;
lims->sel_flags &=
~(PROP_WARNMIN | PROP_BATTWARN);
@@ -142,8 +161,7 @@
}
if (lims->sel_flags & (PROP_CRITMIN | PROP_BATTCAP)) {
if (lims->sel_critmin == edata->limits.sel_critmin) {
- DPRINTF(("%s: type=%d (critmin exists)\n",
- __func__, crittype));
+ DPRINTF(("%s: critmin exists\n", __func__));
error = EEXIST;
lims->sel_flags &=
~(PROP_CRITMIN | PROP_BATTCAP);
@@ -159,8 +177,8 @@
if (see == NULL)
return ENOMEM;
- DPRINTF(("%s: dev %s sensor %s lim_flags 0x%04x new event\n",
- __func__, sme->sme_name, edata->desc, lims->sel_flags));
+ DPRINTF(("%s: dev %s sensor %s: new event\n",
+ __func__, sme->sme_name, edata->des));
see->see_type = crittype;
see->see_sme = sme;
Home |
Main Index |
Thread Index |
Old Index