From 5f70768ef0c383039937324415c2bb7640d1c871 Mon Sep 17 00:00:00 2001 From: reinelt <> Date: Mon, 16 Feb 2004 08:19:44 +0000 Subject: [lcd4linux @ 2004-02-16 08:19:44 by reinelt] i2c_sensors patch from Xavier --- plugin_i2c_sensors.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'plugin_i2c_sensors.c') diff --git a/plugin_i2c_sensors.c b/plugin_i2c_sensors.c index 662f6c2..812f676 100644 --- a/plugin_i2c_sensors.c +++ b/plugin_i2c_sensors.c @@ -1,4 +1,4 @@ -/* $Id: plugin_i2c_sensors.c,v 1.11 2004/02/15 21:43:43 reinelt Exp $ +/* $Id: plugin_i2c_sensors.c,v 1.12 2004/02/16 08:19:44 reinelt Exp $ * * I2C sensors plugin * @@ -23,6 +23,9 @@ * * * $Log: plugin_i2c_sensors.c,v $ + * Revision 1.12 2004/02/16 08:19:44 reinelt + * i2c_sensors patch from Xavier + * * Revision 1.11 2004/02/15 21:43:43 reinelt * T6963 driver nearly finished * framework for graphic displays done @@ -121,7 +124,6 @@ #endif static char *path=NULL; -static int use_sysfs=0; static HASH I2Csensors = { 0, }; static const char *procfs_tokens[4][3] = { @@ -131,6 +133,8 @@ static const char *procfs_tokens[4][3] = { {"fan_min", "fan_input", ""} // for fan# }; +static int (*parse_i2c_sensors)(char *key); + /***********************************************\ * Parsing for new 2.6 kernels 'sysfs' interface * \***********************************************/ @@ -265,11 +269,7 @@ void my_i2c_sensors(RESULT *result, RESULT *arg) age=hash_age(&I2Csensors, key, &val); if (age<0 || age>250) { - if (use_sysfs) { - parse_i2c_sensors_sysfs(key); - } else { - parse_i2c_sensors_procfs(key); - } + parse_i2c_sensors(key); val=hash_get(&I2Csensors, key); } if (val) { @@ -279,6 +279,7 @@ void my_i2c_sensors(RESULT *result, RESULT *arg) } } + void my_i2c_sensors_path(char *method) { struct dirent *dir; @@ -310,7 +311,7 @@ void my_i2c_sensors_path(char *method) while((dir = readdir(fd1))) { // Skip non-directories and '.' and '..' - if (dir->d_type!=DT_DIR || + if ((dir->d_type!=DT_DIR && dir->d_type!=DT_LNK) || strcmp(dir->d_name, "." )==0 || strcmp(dir->d_name, "..")==0) { continue; @@ -337,6 +338,7 @@ void my_i2c_sensors_path(char *method) closedir(fd1); } + int plugin_init_i2c_sensors (void) { char *path_cfg=cfg_get(NULL, "i2c_sensors-path", ""); @@ -370,14 +372,17 @@ int plugin_init_i2c_sensors (void) } // we activate the function only if there's a possibly path found - if (!path) { - free(path); - } else { + if (path!=NULL) { if (strncmp(path, "/sys", 4)==0) { - use_sysfs=1; + parse_i2c_sensors=parse_i2c_sensors_sysfs; + AddFunction ("i2c_sensors", 1, my_i2c_sensors); + } else if (strncmp(path, "/proc", 5)==0) { + parse_i2c_sensors=parse_i2c_sensors_procfs; + AddFunction ("i2c_sensors", 1, my_i2c_sensors); + } else { + error("[i2c_sensors] unknown path %s, should start with /sys or /proc"); } - AddFunction ("i2c_sensors", 1, my_i2c_sensors); } - + return 0; } -- cgit v1.2.3