Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/sysmon Export the sensor device's class.



details:   https://anonhg.NetBSD.org/src/rev/d1ecfef50d71
branches:  trunk
changeset: 753396:d1ecfef50d71
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Fri Mar 26 12:36:59 2010 +0000

description:
Export the sensor device's class.

diffstat:

 sys/dev/sysmon/sysmon_envsys.c |  23 ++++++++++++++++++-----
 1 files changed, 18 insertions(+), 5 deletions(-)

diffs (65 lines):

diff -r 1cdd8b03cb92 -r d1ecfef50d71 sys/dev/sysmon/sysmon_envsys.c
--- a/sys/dev/sysmon/sysmon_envsys.c    Fri Mar 26 07:16:12 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys.c    Fri Mar 26 12:36:59 2010 +0000
@@ -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;



Home | Main Index | Thread Index | Old Index