Module Name: src
Committed By: pgoyette
Date: Fri Mar 26 12:37:00 UTC 2010
Modified Files:
src/sys/dev/sysmon: sysmon_envsys.c
Log Message:
Export the sensor device's class.
To generate a diff of this commit:
cvs rdiff -u -r1.98 -r1.99 src/sys/dev/sysmon/sysmon_envsys.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/sysmon/sysmon_envsys.c
diff -u src/sys/dev/sysmon/sysmon_envsys.c:1.98 src/sys/dev/sysmon/sysmon_envsys.c:1.99
--- src/sys/dev/sysmon/sysmon_envsys.c:1.98 Wed Mar 24 12:15:54 2010
+++ src/sys/dev/sysmon/sysmon_envsys.c Fri Mar 26 12:36:59 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.98 2010/03/24 12:15:54 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.99 2010/03/26 12:36: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.98 2010/03/24 12:15:54 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.99 2010/03/26 12:36:59 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -1141,6 +1141,7 @@
prop_dictionary_t dict)
{
prop_dictionary_t pdict;
+ const char *class;
int error = 0;
pdict = prop_dictionary_create();
@@ -1148,8 +1149,8 @@
return EINVAL;
/*
- * Add the 'refresh-timeout' object into the 'device-properties'
- * dictionary. We use by default 30 seconds.
+ * Add the 'refresh-timeout' and 'dev-class' objects into the
+ * 'device-properties' dictionary.
*
* ...
* <dict>
@@ -1157,7 +1158,9 @@
* <dict>
* <key>refresh-timeout</key>
* <integer>120</integer<
- * </dict<
+ * <key>device-class</key>
+ * <string>class_name</string>
+ * </dict>
* </dict>
* ...
*
@@ -1170,6 +1173,16 @@
error = EINVAL;
goto out;
}
+ if (sme->sme_class == SME_CLASS_BATTERY)
+ class = "battery";
+ else if (sme->sme_class == SME_CLASS_ACADAPTER)
+ class = "ac-adapter";
+ else
+ class = "other";
+ if (!prop_dictionary_set_cstring_nocopy(pdict, "device-class", class)) {
+ error = EINVAL;
+ goto out;
+ }
if (!prop_dictionary_set(dict, "device-properties", pdict)) {
error = EINVAL;