summaryrefslogtreecommitdiff
path: root/src/openbsd
diff options
context:
space:
mode:
authorLandry Breuil <landry@rhaalovely.net>2011-03-07 20:28:08 +0100
committerRichard Hughes <richard@hughsie.com>2011-03-21 18:40:09 +0000
commit1017f7399b40ec750195857a0493c3df156fffbe (patch)
tree35a6d21df8ca60f9d9398f6142dd89895f52a669 /src/openbsd
parent5e69186399741889ec369bd05b1daa006888d60c (diff)
downloadupower-1017f7399b40ec750195857a0493c3df156fffbe.tar.gz
openbsd: rename has_sensor() to get_sensor() and use it to grab the sensordev struct
Signed-off-by: Richard Hughes <richard@hughsie.com>
Diffstat (limited to 'src/openbsd')
-rw-r--r--src/openbsd/up-apm-native.h5
-rw-r--r--src/openbsd/up-native.c16
2 files changed, 12 insertions, 9 deletions
diff --git a/src/openbsd/up-apm-native.h b/src/openbsd/up-apm-native.h
index c2c3698..cbd931d 100644
--- a/src/openbsd/up-apm-native.h
+++ b/src/openbsd/up-apm-native.h
@@ -13,6 +13,9 @@
#include <machine/apmvar.h>
+/* sensor struct defs */
+#include <sys/sensors.h>
+
#include <glib.h>
#include <glib-object.h>
@@ -44,7 +47,7 @@ typedef struct
UpApmNative* up_apm_native_new (const char*);
const gchar * up_apm_native_get_path(UpApmNative*);
gboolean up_native_is_laptop();
-gboolean up_native_has_sensor(const char*);
+gboolean up_native_get_sensor(const char*, struct sensordev*);
G_END_DECLS
#endif
diff --git a/src/openbsd/up-native.c b/src/openbsd/up-native.c
index 678d840..aed89f6 100644
--- a/src/openbsd/up-native.c
+++ b/src/openbsd/up-native.c
@@ -2,7 +2,6 @@
#include "up-native.h"
#include <sys/param.h>
-#include <sys/sensors.h>
#include <sys/sysctl.h>
#include <errno.h>
/* XXX why does this macro needs to be in the .c ? */
@@ -57,8 +56,9 @@ up_native_is_laptop()
{
int apm_fd;
struct apm_power_info bstate;
+ struct sensordev acpiac;
- if (up_native_has_sensor("acpiac0"))
+ if (up_native_get_sensor("acpiac0", &acpiac))
return TRUE;
if ((apm_fd = open("/dev/apm", O_RDONLY)) == -1) {
@@ -72,25 +72,25 @@ up_native_is_laptop()
}
/**
- * detect if a sensordev is present by its xname (acpibatX/acpiacX)
+ * get a sensordev by its xname (acpibatX/acpiacX)
+ * returns a gboolean if found or not
*/
gboolean
-up_native_has_sensor(const char * id)
+up_native_get_sensor(const char * id, struct sensordev * snsrdev)
{
int devn;
- struct sensordev snsrdev;
- size_t sdlen = sizeof(snsrdev);
+ size_t sdlen = sizeof(struct sensordev);
int mib[] = {CTL_HW, HW_SENSORS, 0, 0 ,0};
for (devn = 0 ; ; devn++) {
mib[2] = devn;
- if (sysctl(mib, 3, &snsrdev, &sdlen, NULL, 0) == -1) {
+ if (sysctl(mib, 3, snsrdev, &sdlen, NULL, 0) == -1) {
if (errno == ENXIO)
continue;
if (errno == ENOENT)
break;
}
- if (!strcmp(snsrdev.xname, id))
+ if (!strcmp(snsrdev->xname, id))
return TRUE;
}
return FALSE;