Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Remove the flags member of the limits structure. Its va...
details: https://anonhg.NetBSD.org/src/rev/4717ef159755
branches: trunk
changeset: 752100:4717ef159755
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sun Feb 14 23:06:01 2010 +0000
description:
Remove the flags member of the limits structure. Its value was only
meaningful for a few limited function calls; all persitent storage
of limit-present flags is maintained in the edata->upropset member.
diffstat:
sys/dev/sysmon/sysmon_envsys.c | 30 +++++++--------
sys/dev/sysmon/sysmon_envsys_events.c | 69 +++++++++++++++++-----------------
sys/dev/sysmon/sysmon_envsysvar.h | 4 +-
sys/dev/sysmon/sysmonvar.h | 6 +-
sys/sys/envsys.h | 4 +-
5 files changed, 54 insertions(+), 59 deletions(-)
diffs (truncated from 405 to 300 lines):
diff -r c8a8037115da -r 4717ef159755 sys/dev/sysmon/sysmon_envsys.c
--- a/sys/dev/sysmon/sysmon_envsys.c Sun Feb 14 16:22:09 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys.c Sun Feb 14 23:06:01 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.94 2010/02/05 17:44:27 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.95 2010/02/14 23:06:01 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.94 2010/02/05 17:44:27 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.95 2010/02/14 23:06:01 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -1720,6 +1720,7 @@
envsys_data_t *edata;
prop_dictionary_t dict, tdict = NULL;
prop_object_t obj, obj1, obj2, tobj = NULL;
+ uint32_t props;
uint64_t refresh_timo = 0;
sysmon_envsys_lim_t lims;
int i, error = 0;
@@ -1785,7 +1786,7 @@
if (!prop_string_equals(obj1, obj))
continue;
- lims.sel_flags = 0;
+ props = 0;
/*
* Check if a new description operation was
@@ -1860,7 +1861,7 @@
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
targetfound = true;
lims.sel_critmin = prop_number_integer_value(obj2);
- lims.sel_flags |= PROP_BATTCAP;
+ props |= PROP_BATTCAP;
}
/*
@@ -1870,7 +1871,7 @@
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
targetfound = true;
lims.sel_warnmin = prop_number_integer_value(obj2);
- lims.sel_flags |= PROP_BATTWARN;
+ props |= PROP_BATTWARN;
}
/*
@@ -1880,7 +1881,7 @@
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
targetfound = true;
lims.sel_critmax = prop_number_integer_value(obj2);
- lims.sel_flags |= PROP_CRITMAX;
+ props |= PROP_CRITMAX;
}
/*
@@ -1890,7 +1891,7 @@
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
targetfound = true;
lims.sel_warnmax = prop_number_integer_value(obj2);
- lims.sel_flags |= PROP_WARNMAX;
+ props |= PROP_WARNMAX;
}
/*
@@ -1900,7 +1901,7 @@
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
targetfound = true;
lims.sel_critmin = prop_number_integer_value(obj2);
- lims.sel_flags |= PROP_CRITMIN;
+ props |= PROP_CRITMIN;
}
/*
@@ -1910,27 +1911,24 @@
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
targetfound = true;
lims.sel_warnmin = prop_number_integer_value(obj2);
- lims.sel_flags |= PROP_WARNMIN;
+ props |= PROP_WARNMIN;
}
- if (lims.sel_flags) {
+ if (props) {
if (edata->flags & ENVSYS_FMONNOTSUPP) {
error = ENOTSUP;
goto out;
}
error = sme_event_register(dict, edata, sme, &lims,
- (edata->flags & ENVSYS_FPERCENT)?
+ props,
+ (edata->flags & ENVSYS_FPERCENT)?
PENVSYS_EVENT_CAPACITY:
PENVSYS_EVENT_LIMITS,
- sdt[i].crittype);
+ sdt[i].crittype);
if (error == EEXIST)
error = 0;
if (error)
goto out;
-
- mutex_enter(&sme->sme_mtx);
- edata->upropset |= lims.sel_flags;
- mutex_exit(&sme->sme_mtx);
}
/*
diff -r c8a8037115da -r 4717ef159755 sys/dev/sysmon/sysmon_envsys_events.c
--- a/sys/dev/sysmon/sysmon_envsys_events.c Sun Feb 14 16:22:09 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys_events.c Sun Feb 14 23:06:01 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys_events.c,v 1.81 2010/02/14 16:22:09 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys_events.c,v 1.82 2010/02/14 23:06:02 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.81 2010/02/14 16:22:09 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.82 2010/02/14 23:06:02 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -44,6 +44,7 @@
#include <sys/callout.h>
/* #define ENVSYS_DEBUG */
+/* #define ENVSYS_OBJECTS_DEBUG */
#include <dev/sysmon/sysmonvar.h>
#include <dev/sysmon/sysmon_envsysvar.h>
@@ -83,7 +84,7 @@
int
sme_event_register(prop_dictionary_t sdict, envsys_data_t *edata,
struct sysmon_envsys *sme, sysmon_envsys_lim_t *lims,
- int crittype, int powertype)
+ uint32_t props, int crittype, int powertype)
{
sme_event_t *see = NULL, *osee = NULL;
prop_object_t obj;
@@ -104,14 +105,14 @@
* 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));
+ DPRINTF(("%s: units %d props 0x%04x edata-flags 0x%04x\n",
+ __func__, edata->units, props, edata->flags));
- if ((lims->sel_flags & PROP_VAL_LIMITS) &&
+ if ((props & PROP_VAL_LIMITS) &&
((edata->flags & ENVSYS_FPERCENT) ||
(edata->units == ENVSYS_INDICATOR)))
return ENOTSUP;
- if ((lims->sel_flags & PROP_CAP_LIMITS) &&
+ if ((props & PROP_CAP_LIMITS) &&
!(edata->flags & ENVSYS_FPERCENT))
return ENOTSUP;
@@ -136,35 +137,33 @@
__func__, sme->sme_name, edata->desc, crittype));
see = osee;
- if (lims->sel_flags & PROP_CRITMAX) {
+ if (props & PROP_CRITMAX) {
if (lims->sel_critmax == edata->limits.sel_critmax) {
DPRINTF(("%s: type=%d (critmax exists)\n",
__func__, crittype));
error = EEXIST;
- lims->sel_flags &= ~PROP_CRITMAX;
+ props &= ~PROP_CRITMAX;
}
}
- if (lims->sel_flags & PROP_WARNMAX) {
+ if (props & PROP_WARNMAX) {
if (lims->sel_warnmax == edata->limits.sel_warnmax) {
DPRINTF(("%s: warnmax exists\n", __func__));
error = EEXIST;
- lims->sel_flags &= ~PROP_WARNMAX;
+ props &= ~PROP_WARNMAX;
}
}
- if (lims->sel_flags & (PROP_WARNMIN | PROP_BATTWARN)) {
+ if (props & (PROP_WARNMIN | PROP_BATTWARN)) {
if (lims->sel_warnmin == edata->limits.sel_warnmin) {
DPRINTF(("%s: warnmin exists\n", __func__));
error = EEXIST;
- lims->sel_flags &=
- ~(PROP_WARNMIN | PROP_BATTWARN);
+ props &= ~(PROP_WARNMIN | PROP_BATTWARN);
}
}
- if (lims->sel_flags & (PROP_CRITMIN | PROP_BATTCAP)) {
+ if (props & (PROP_CRITMIN | PROP_BATTCAP)) {
if (lims->sel_critmin == edata->limits.sel_critmin) {
DPRINTF(("%s: critmin exists\n", __func__));
error = EEXIST;
- lims->sel_flags &=
- ~(PROP_CRITMIN | PROP_BATTCAP);
+ props &= ~(PROP_CRITMIN | PROP_BATTCAP);
}
}
break;
@@ -219,7 +218,7 @@
/*
* Limit operation requested.
*/
- if (lims->sel_flags & PROP_CRITMAX) {
+ if (props & PROP_CRITMAX) {
objkey = "critical-max";
obj = prop_dictionary_get(sdict, objkey);
if (obj && prop_object_type(obj) != PROP_TYPE_NUMBER) {
@@ -239,7 +238,7 @@
edata->upropset |= PROP_CRITMAX;
}
- if (lims->sel_flags & PROP_WARNMAX) {
+ if (props & PROP_WARNMAX) {
objkey = "warning-max";
obj = prop_dictionary_get(sdict, objkey);
if (obj && prop_object_type(obj) != PROP_TYPE_NUMBER) {
@@ -259,7 +258,7 @@
edata->upropset |= PROP_WARNMAX;
}
- if (lims->sel_flags & PROP_WARNMIN) {
+ if (props & PROP_WARNMIN) {
objkey = "warning-min";
obj = prop_dictionary_get(sdict, objkey);
if (obj && prop_object_type(obj) != PROP_TYPE_NUMBER) {
@@ -279,7 +278,7 @@
edata->upropset |= PROP_WARNMIN;
}
- if (lims->sel_flags & PROP_CRITMIN) {
+ if (props & PROP_CRITMIN) {
objkey = "critical-min";
obj = prop_dictionary_get(sdict, objkey);
if (obj && prop_object_type(obj) != PROP_TYPE_NUMBER) {
@@ -299,7 +298,7 @@
edata->upropset |= PROP_CRITMIN;
}
- if (lims->sel_flags & PROP_BATTWARN) {
+ if (props & PROP_BATTWARN) {
objkey = "warning-capacity";
obj = prop_dictionary_get(sdict, objkey);
if (obj && prop_object_type(obj) != PROP_TYPE_NUMBER) {
@@ -319,7 +318,7 @@
edata->upropset |= PROP_BATTWARN;
}
- if (lims->sel_flags & PROP_BATTCAP) {
+ if (props & PROP_BATTCAP) {
objkey = "critical-capacity";
obj = prop_dictionary_get(sdict, objkey);
if (obj && prop_object_type(obj) != PROP_TYPE_NUMBER) {
@@ -339,7 +338,7 @@
edata->upropset |= PROP_BATTCAP;
}
- if (lims->sel_flags & PROP_DRIVER_LIMITS)
+ if (props & PROP_DRIVER_LIMITS)
edata->upropset |= PROP_DRIVER_LIMITS;
else
edata->upropset &= ~PROP_DRIVER_LIMITS;
@@ -361,10 +360,9 @@
* If driver requested notification, advise it of new
* limit values
*/
- if (sme->sme_set_limits) {
- edata->limits.sel_flags = edata->upropset & PROP_LIMITS;
- (*sme->sme_set_limits)(sme, edata, &(edata->limits));
- }
+ if (sme->sme_set_limits)
+ (*sme->sme_set_limits)(sme, edata, &(edata->limits),
+ &(edata->upropset));
out:
if ((error == 0 || error == EEXIST) && osee == NULL)
@@ -483,6 +481,7 @@
{
sme_event_drv_t *sed_t = arg;
sysmon_envsys_lim_t lims;
+ uint32_t props;
int error = 0;
KASSERT(sed_t != NULL);
@@ -495,7 +494,7 @@
error = sme_event_register(sed_t->sed_sdict, \
sed_t->sed_edata, \
sed_t->sed_sme, \
Home |
Main Index |
Thread Index |
Old Index