1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-27 20:44:56 +00:00

fix hwmon for 2.6.29, simplify code a bit

This commit is contained in:
Phil Sutter 2009-05-10 22:47:47 +02:00 committed by Phil Sutter
parent a01f968677
commit ae7996bdd1

View File

@ -825,6 +825,7 @@ int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
char buf[256]; char buf[256];
int fd; int fd;
int divfd; int divfd;
struct stat st;
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
@ -851,16 +852,21 @@ int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n,
} }
} }
/* change vol to in */ /* At least the acpitz hwmon doesn't have a 'device' subdir,
if (strcmp(type, "vol") == 0) { * so check it's existence and strip it from buf otherwise. */
type = "in"; snprintf(path, 255, "%s%s", dir, dev);
if (stat(path, &st)) {
buf[strlen(buf) - 7] = 0;
} }
if (strcmp(type, "tempf") == 0) { /* change vol to in, tempf to temp */
snprintf(path, 255, "%s%s/%s%d_input", dir, dev, "temp", n); if (strcmp(type, "vol") == 0) {
} else { type = "in";
snprintf(path, 255, "%s%s/%s%d_input", dir, dev, type, n); } else if (strcmp(type, "tempf") == 0) {
type = "temp";
} }
snprintf(path, 255, "%s%s/%s%d_input", dir, dev, type, n);
strncpy(devtype, path, 255); strncpy(devtype, path, 255);
/* open file */ /* open file */