Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys For symmetry, allow warning and critical upper-limits fo...
details: https://anonhg.NetBSD.org/src/rev/cfe50bdb9f89
branches: trunk
changeset: 752112:cfe50bdb9f89
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Mon Feb 15 22:32:04 2010 +0000
description:
For symmetry, allow warning and critical upper-limits for capacity
sensors.
diffstat:
sys/dev/sysmon/sysmon_envsys.c | 36 +++++++++++++++++++++++++++++++++-
sys/dev/sysmon/sysmon_envsys_events.c | 22 +++++++++++++-------
sys/dev/sysmon/sysmon_power.c | 16 +++++++++++++-
sys/sys/envsys.h | 17 ++++++++++-----
sys/sys/power.h | 8 ++++++-
5 files changed, 80 insertions(+), 19 deletions(-)
diffs (257 lines):
diff -r 0adbd6b1825d -r cfe50bdb9f89 sys/dev/sysmon/sysmon_envsys.c
--- a/sys/dev/sysmon/sysmon_envsys.c Mon Feb 15 20:20:34 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys.c Mon Feb 15 22:32:04 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.95 2010/02/14 23:06:01 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.96 2010/02/15 22:32:04 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.95 2010/02/14 23:06:01 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.96 2010/02/15 22:32:04 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -1061,6 +1061,18 @@
"warning-capacity");
ptype = PENVSYS_EVENT_CAPACITY;
}
+
+ if (edata->upropset & PROP_BATTHIGH) {
+ prop_dictionary_remove(sdict,
+ "high-capacity");
+ ptype = PENVSYS_EVENT_CAPACITY;
+ }
+
+ if (edata->upropset & PROP_BATTMAX) {
+ prop_dictionary_remove(sdict,
+ "maximum-capacity");
+ ptype = PENVSYS_EVENT_CAPACITY;
+ }
if (ptype != 0)
sme_event_unregister(sme, edata->desc, ptype);
@@ -1875,6 +1887,26 @@
}
/*
+ * did the user want to set a high capacity event?
+ */
+ obj2 = prop_dictionary_get(udict, "high-capacity");
+ if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
+ targetfound = true;
+ lims.sel_warnmin = prop_number_integer_value(obj2);
+ props |= PROP_BATTHIGH;
+ }
+
+ /*
+ * did the user want to set a maximum capacity event?
+ */
+ obj2 = prop_dictionary_get(udict, "maximum-capacity");
+ if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
+ targetfound = true;
+ lims.sel_warnmin = prop_number_integer_value(obj2);
+ props |= PROP_BATTMAX;
+ }
+
+ /*
* did the user want to set a critical max event?
*/
obj2 = prop_dictionary_get(udict, "critical-max");
diff -r 0adbd6b1825d -r cfe50bdb9f89 sys/dev/sysmon/sysmon_envsys_events.c
--- a/sys/dev/sysmon/sysmon_envsys_events.c Mon Feb 15 20:20:34 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys_events.c Mon Feb 15 22:32:04 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys_events.c,v 1.83 2010/02/14 23:30:52 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys_events.c,v 1.84 2010/02/15 22:32:04 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.83 2010/02/14 23:30:52 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_events.c,v 1.84 2010/02/15 22:32:04 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -63,6 +63,8 @@
{ ENVSYS_BATTERY_CAPACITY_NORMAL, PENVSYS_EVENT_NORMAL },
{ ENVSYS_BATTERY_CAPACITY_WARNING, PENVSYS_EVENT_BATT_WARN },
{ ENVSYS_BATTERY_CAPACITY_CRITICAL, PENVSYS_EVENT_BATT_CRIT },
+ { ENVSYS_BATTERY_CAPACITY_HIGH, PENVSYS_EVENT_BATT_HIGH },
+ { ENVSYS_BATTERY_CAPACITY_MAX, PENVSYS_EVENT_BATT_MAX },
{ -1, -1 }
};
@@ -137,19 +139,19 @@
__func__, sme->sme_name, edata->desc, crittype));
see = osee;
- if (props & PROP_CRITMAX) {
+ if (props & (PROP_CRITMAX | PROP_BATTMAX)) {
if (lims->sel_critmax == edata->limits.sel_critmax) {
DPRINTF(("%s: type=%d (critmax exists)\n",
__func__, crittype));
error = EEXIST;
- props &= ~PROP_CRITMAX;
+ props &= ~(PROP_CRITMAX | PROP_BATTMAX);
}
}
- if (props & PROP_WARNMAX) {
+ if (props & (PROP_WARNMAX | PROP_BATTHIGH)) {
if (lims->sel_warnmax == edata->limits.sel_warnmax) {
DPRINTF(("%s: warnmax exists\n", __func__));
error = EEXIST;
- props &= ~PROP_WARNMAX;
+ props &= ~(PROP_WARNMAX | PROP_BATTHIGH);
}
}
if (props & (PROP_WARNMIN | PROP_BATTWARN)) {
@@ -246,6 +248,8 @@
LIMIT_OP("critical-min", sel_critmin, PROP_CRITMIN);
/* %Capacity-based limits */
+ LIMIT_OP("maximum-capacity", sel_critmax, PROP_BATTMAX);
+ LIMIT_OP("high-capacity", sel_warnmax, PROP_BATTHIGH);
LIMIT_OP("warning-capacity", sel_warnmin, PROP_BATTWARN);
LIMIT_OP("critical-capacity", sel_critmin, PROP_BATTCAP);
@@ -618,9 +622,11 @@
else if __EXCEED_LIM(PROP_WARNMIN | PROP_BATTWARN,
sel_warnmin, <)
edata->state = ENVSYS_SWARNUNDER;
- else if __EXCEED_LIM(PROP_CRITMAX, sel_critmax, >)
+ else if __EXCEED_LIM(PROP_CRITMAX | PROP_BATTMAX,
+ sel_critmax, >)
edata->state = ENVSYS_SCRITOVER;
- else if __EXCEED_LIM(PROP_WARNMAX, sel_warnmax, >)
+ else if __EXCEED_LIM(PROP_WARNMAX | PROP_BATTHIGH,
+ sel_warnmax, >)
edata->state = ENVSYS_SWARNOVER;
else
edata->state = ENVSYS_SVALID;
diff -r 0adbd6b1825d -r cfe50bdb9f89 sys/dev/sysmon/sysmon_power.c
--- a/sys/dev/sysmon/sysmon_power.c Mon Feb 15 20:20:34 2010 +0000
+++ b/sys/dev/sysmon/sysmon_power.c Mon Feb 15 22:32:04 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_power.c,v 1.42 2009/11/06 18:28:10 jakllsch Exp $ */
+/* $NetBSD: sysmon_power.c,v 1.43 2010/02/15 22:32:04 pgoyette Exp $ */
/*-
* Copyright (c) 2007 Juan Romero Pardines.
@@ -69,7 +69,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.42 2009/11/06 18:28:10 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.43 2010/02/15 22:32:04 pgoyette Exp $");
#include "opt_compat_netbsd.h"
#include <sys/param.h>
@@ -135,6 +135,8 @@
{ PENVSYS_EVENT_WARNUNDER, "warning-under" },
{ PENVSYS_EVENT_BATT_CRIT, "critical-capacity" },
{ PENVSYS_EVENT_BATT_WARN, "warning-capacity" },
+ { PENVSYS_EVENT_BATT_HIGH, "high-capacity" },
+ { PENVSYS_EVENT_BATT_MAX, "maximum-capacity" },
{ PENVSYS_EVENT_STATE_CHANGED, "state-changed" },
{ PENVSYS_EVENT_LOW_POWER, "low-power" },
{ -1, NULL }
@@ -318,6 +320,8 @@
case PENVSYS_EVENT_WARNOVER:
case PENVSYS_EVENT_BATT_CRIT:
case PENVSYS_EVENT_BATT_WARN:
+ case PENVSYS_EVENT_BATT_HIGH:
+ case PENVSYS_EVENT_BATT_MAX:
case PENVSYS_EVENT_STATE_CHANGED:
case PENVSYS_EVENT_LOW_POWER:
{
@@ -808,6 +812,14 @@
mystr = "warning capacity";
PENVSYS_SHOWSTATE(mystr);
break;
+ case PENVSYS_EVENT_BATT_HIGH:
+ mystr = "high capacity";
+ PENVSYS_SHOWSTATE(mystr);
+ break;
+ case PENVSYS_EVENT_BATT_MAX:
+ mystr = "maximum capacity";
+ PENVSYS_SHOWSTATE(mystr);
+ break;
case PENVSYS_EVENT_NORMAL:
printf("%s: normal capacity on '%s'\n",
pes->pes_dvname, pes->pes_sensname);
diff -r 0adbd6b1825d -r cfe50bdb9f89 sys/sys/envsys.h
--- a/sys/sys/envsys.h Mon Feb 15 20:20:34 2010 +0000
+++ b/sys/sys/envsys.h Mon Feb 15 22:32:04 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: envsys.h,v 1.29 2010/02/14 23:06:01 pgoyette Exp $ */
+/* $NetBSD: envsys.h,v 1.30 2010/02/15 22:32:04 pgoyette Exp $ */
/*-
* Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
@@ -133,6 +133,8 @@
ENVSYS_BATTERY_CAPACITY_NORMAL = 1, /* normal cap in battery */
ENVSYS_BATTERY_CAPACITY_WARNING, /* warning cap in battery */
ENVSYS_BATTERY_CAPACITY_CRITICAL, /* critical cap in battery */
+ ENVSYS_BATTERY_CAPACITY_HIGH, /* high cap in battery */
+ ENVSYS_BATTERY_CAPACITY_MAX, /* maximum cap in battery */
ENVSYS_BATTERY_CAPACITY_LOW /* low cap in battery */
};
@@ -167,13 +169,16 @@
#define PROP_WARNMIN 0x0008
#define PROP_BATTCAP 0x0010
#define PROP_BATTWARN 0x0020
-#define PROP_DESC 0x0040
-#define PROP_RFACT 0x0080
+#define PROP_BATTHIGH 0x0040
+#define PROP_BATTMAX 0x0080
+#define PROP_DESC 0x0100
+#define PROP_RFACT 0x0200
#define PROP_DRIVER_LIMITS 0x8000
-#define PROP_CAP_LIMITS (PROP_BATTCAP | PROP_BATTWARN)
-#define PROP_VAL_LIMITS (PROP_CRITMAX | PROP_CRITMIN | \
- PROP_WARNMAX | PROP_WARNMIN)
+#define PROP_CAP_LIMITS (PROP_BATTCAP | PROP_BATTWARN | \
+ PROP_BATTHIGH | PROP_BATTMAX)
+#define PROP_VAL_LIMITS (PROP_CRITMAX | PROP_CRITMIN | \
+ PROP_WARNMAX | PROP_WARNMIN)
#define PROP_LIMITS (PROP_CAP_LIMITS | PROP_VAL_LIMITS)
/*
diff -r 0adbd6b1825d -r cfe50bdb9f89 sys/sys/power.h
--- a/sys/sys/power.h Mon Feb 15 20:20:34 2010 +0000
+++ b/sys/sys/power.h Mon Feb 15 22:32:04 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: power.h,v 1.14 2009/11/06 18:28:10 jakllsch Exp $ */
+/* $NetBSD: power.h,v 1.15 2010/02/15 22:32:04 pgoyette Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -174,12 +174,18 @@
*
* PENVSYS_EVENT_BATT_WARN User warning capacity.
*
+ * PENVSYS_EVENT_BATT_HIGH User high capacity.
+ *
+ * PENVSYS_EVENT_BATT_MAX User maximum capacity.
+ *
* PENVSYS_EVENT_LOW_POWER AC Adapter is OFF and all batteries
* are discharged.
*/
#define PENVSYS_EVENT_BATT_CRIT 170
#define PENVSYS_EVENT_BATT_WARN 175
+#define PENVSYS_EVENT_BATT_HIGH 177
+#define PENVSYS_EVENT_BATT_MAX 178
#define PENVSYS_EVENT_LOW_POWER 180
/*
Home |
Main Index |
Thread Index |
Old Index