Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/sysmon Add a routine to iterate over all the sensors...
details: https://anonhg.NetBSD.org/src/rev/67ab2741e69b
branches: trunk
changeset: 753407:67ab2741e69b
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Fri Mar 26 20:31:06 2010 +0000
description:
Add a routine to iterate over all the sensors on the system. This will
be needed to update acpiapm_get_powstat() which is currently slightly
broken due to recent rearrangement of acpi_bat(4)'s sensors. (This
approach is in lieu of exporting proplists between kernel entities, and
avoids exposing some internal sysmon_envsys details.)
diffstat:
sys/dev/sysmon/sysmon_envsys.c | 31 +++++++++++++++++++++++++++++--
sys/dev/sysmon/sysmonvar.h | 5 ++++-
2 files changed, 33 insertions(+), 3 deletions(-)
diffs (68 lines):
diff -r 40286e0eb537 -r 67ab2741e69b sys/dev/sysmon/sysmon_envsys.c
--- a/sys/dev/sysmon/sysmon_envsys.c Fri Mar 26 19:43:04 2010 +0000
+++ b/sys/dev/sysmon/sysmon_envsys.c Fri Mar 26 20:31:06 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmon_envsys.c,v 1.99 2010/03/26 12:36:59 pgoyette Exp $ */
+/* $NetBSD: sysmon_envsys.c,v 1.100 2010/03/26 20:31:06 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.99 2010/03/26 12:36:59 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.100 2010/03/26 20:31:06 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -2001,3 +2001,30 @@
return error;
}
+
+/*
+ * + sysmon_envsys_foreach_sensor
+ *
+ * Walk through the devices' sensor lists and execute the callback.
+ * If the callback returns false, the remainder of the current
+ * device's sensors are skipped.
+ */
+void
+sysmon_envsys_foreach_sensor(bool(*func)(struct sysmon_envsys *,
+ envsys_data_t *, void*), void *arg)
+{
+ struct sysmon_envsys *sme;
+ envsys_data_t *sensor;
+
+ mutex_enter(&sme_global_mtx);
+ LIST_FOREACH(sme, &sysmon_envsys_list, sme_list) {
+
+ mutex_enter(&sme->sme_mtx);
+ TAILQ_FOREACH(sensor, &sme->sme_sensors_list, sensors_head) {
+ if ((*func)(sme, sensor, arg))
+ break;
+ }
+ mutex_exit(&sme->sme_mtx);
+ }
+ mutex_exit(&sme_global_mtx);
+}
diff -r 40286e0eb537 -r 67ab2741e69b sys/dev/sysmon/sysmonvar.h
--- a/sys/dev/sysmon/sysmonvar.h Fri Mar 26 19:43:04 2010 +0000
+++ b/sys/dev/sysmon/sysmonvar.h Fri Mar 26 20:31:06 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysmonvar.h,v 1.34 2010/03/19 02:19:13 pgoyette Exp $ */
+/* $NetBSD: sysmonvar.h,v 1.35 2010/03/26 20:31:06 pgoyette Exp $ */
/*-
* Copyright (c) 2000 Zembu Labs, Inc.
@@ -208,6 +208,9 @@
void sysmon_envsys_sensor_event(struct sysmon_envsys *, envsys_data_t *,
int);
+void sysmon_envsys_foreach_sensor(bool(*)(struct sysmon_envsys *,
+ envsys_data_t *, void*), void *);
+
void sysmon_envsys_init(void);
/*****************************************************************************
Home |
Main Index |
Thread Index |
Old Index