- len = ssnprintf(filename, sizeof(filename), "%s/%s/cur_state", dirname_sysfs,
- name);
- if ((len < 0) || ((size_t)len >= sizeof(filename)))
- return -1;
-
- len = (ssize_t)read_file_contents(filename, data, sizeof(data));
- if (len > 1 && data[--len] == '\n') {
- char *endptr = NULL;
- double state;
-
- data[len] = 0;
- errno = 0;
- state = strtod(data, &endptr);
-
- if (endptr == data + len && errno == 0) {
- thermal_submit(name, COOLING_DEV, state);
- success = 1;
- }
+ ssnprintf(filename, sizeof(filename), "%s/%s/cur_state", dirname_sysfs, name);
+ if (parse_value_file(filename, &value, DS_TYPE_GAUGE) == 0) {
+ thermal_submit(name, COOLING_DEV, value);
+ success = 1;