/*
- * Copyright (C) 2010-2012 jeanfi@gmail.com
+ * Copyright (C) 2010-2014 jeanfi@gmail.com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
static double get_temp_input(struct psensor *sensor)
{
+ const sensors_subfeature *sf;
+
const sensors_chip_name *chip = sensor->iname;
- const sensors_feature *feature = sensor->feature;
- const sensors_subfeature *sf;
+ const sensors_feature *feature = sensor->feature;
sf = sensors_get_subfeature(chip,
feature, SENSORS_SUBFEATURE_TEMP_INPUT);
if (sf)
return get_value(chip, sf);
- else
- return UNKNOWN_DBL_VALUE;
+
+ return UNKNOWN_DBL_VALUE;
}
static double get_fan_input(struct psensor *sensor)
feature, SENSORS_SUBFEATURE_FAN_INPUT);
if (sf)
return get_value(chip, sf);
- else
- return UNKNOWN_DBL_VALUE;
+
+ return UNKNOWN_DBL_VALUE;
}
void lmsensor_psensor_list_update(struct psensor **sensors)
struct psensor **s_ptr = sensors;
if (!init_done)
- return ;
+ return;
while (*s_ptr) {
- struct psensor *sensor = *s_ptr;
-
- if (sensor->type == SENSOR_TYPE_LMSENSOR_TEMP)
- psensor_set_current_value
- (sensor, get_temp_input(sensor));
- else if (sensor->type == SENSOR_TYPE_LMSENSOR_FAN)
- psensor_set_current_value(sensor,
- get_fan_input(sensor));
+ struct psensor *s = *s_ptr;
+
+ if (!(s->type & SENSOR_TYPE_REMOTE)
+ && s->type & SENSOR_TYPE_LMSENSOR) {
+ if (s->type & SENSOR_TYPE_TEMP)
+ psensor_set_current_value(s,
+ get_temp_input(s));
+ else if (s->type & SENSOR_TYPE_RPM)
+ psensor_set_current_value(s, get_fan_input(s));
+ }
s_ptr++;
}
if (feature->type == SENSORS_FEATURE_TEMP) {
fault_subfeature = SENSORS_SUBFEATURE_TEMP_FAULT;
-
} else if (feature->type == SENSORS_FEATURE_FAN) {
fault_subfeature = SENSORS_SUBFEATURE_FAN_FAULT;
-
} else {
log_err(_(
"lmsensor: lmsensor_psensor_create failure: wrong feature type."));
if (!label)
return NULL;
- type = 0;
+ type = SENSOR_TYPE_LMSENSOR;
if (feature->type == SENSORS_FEATURE_TEMP)
- type = SENSOR_TYPE_LMSENSOR_TEMP;
+ type |= SENSOR_TYPE_TEMP;
else if (feature->type == SENSORS_FEATURE_FAN)
- type = SENSOR_TYPE_LMSENSOR_FAN;
+ type |= (SENSOR_TYPE_RPM|SENSOR_TYPE_FAN);
else
return NULL;
sprintf(id, "lmsensor %s %s", name, label);
if (!strcmp(chip->prefix, "coretemp"))
- cname = strdup("Intel CPU");
- else if (!strcmp(chip->prefix, "k10temp"))
- cname = strdup("AMD CPU");
+ cname = strdup(_("Intel CPU"));
+ else if (!strcmp(chip->prefix, "k10temp")
+ || !strcmp(chip->prefix, "k8temp")
+ || !strcmp(chip->prefix, "fam15h_power"))
+ cname = strdup(_("AMD CPU"));
else if (!strcmp(chip->prefix, "nouveau"))
- cname = strdup("Nvidia GPU");
+ cname = strdup(_("NVIDIA GPU"));
+ else if (!strcmp(chip->prefix, "via-cputemp"))
+ cname = strdup(_("VIA CPU"));
+ else if (!strcmp(chip->prefix, "acpitz"))
+ cname = strdup(_("ACPI"));
else
cname = strdup(chip->prefix);
return psensor;
}
-struct psensor **lmsensor_psensor_list_add(struct psensor **sensors,
- int vn)
+void lmsensor_init()
+{
+ int err = sensors_init(NULL);
+
+ if (err) {
+ log_err(_("lmsensor: initialization failure: %s."),
+ sensors_strerror(err));
+ init_done = 0;
+ } else {
+ init_done = 1;
+ }
+}
+
+void lmsensor_psensor_list_append(struct psensor ***sensors, int vn)
{
const sensors_chip_name *chip;
int chip_nr = 0;
- struct psensor **tmp, **result;
const sensors_feature *feature;
struct psensor *s;
int i;
if (!init_done)
- return NULL;
+ lmsensor_init();
+
+ if (!init_done)
+ return;
- result = sensors;
while ((chip = sensors_get_detected_chips(NULL, &chip_nr))) {
i = 0;
while ((feature = sensors_get_features(chip, &i))) {
-
if (feature->type == SENSORS_FEATURE_TEMP
|| feature->type == SENSORS_FEATURE_FAN) {
s = lmsensor_psensor_create(chip, feature, vn);
- if (s) {
- tmp = psensor_list_add(result, s);
-
- if (tmp != sensors)
- free(result);
-
- result = tmp;
- }
+ if (s)
+ psensor_list_append(sensors, s);
}
}
}
-
- return result;
-}
-
-void lmsensor_init()
-{
- int err = sensors_init(NULL);
-
- if (err) {
- log_err(_("lmsensor: initialization failure: %s."),
- sensors_strerror(err));
- init_done = 0;
- } else {
- init_done = 1;
- }
}
void lmsensor_cleanup()