diff --git a/lib/access.c b/lib/access.c index a66d2b35..6d4b67ab 100644 --- a/lib/access.c +++ b/lib/access.c @@ -304,7 +304,7 @@ const sensors_chip_name *sensors_get_detected_chips(int *nr) { const sensors_chip_name *res; res = (*nr >= sensors_proc_chips_count ? - NULL : &sensors_proc_chips[*nr].name); + NULL : &sensors_proc_chips[*nr]); (*nr)++; return res; } diff --git a/lib/data.c b/lib/data.c index 0c7fa705..70a37cf9 100644 --- a/lib/data.c +++ b/lib/data.c @@ -36,7 +36,7 @@ sensors_bus *sensors_config_busses = NULL; int sensors_config_busses_count = 0; int sensors_config_busses_max = 0; -sensors_proc_chips_entry *sensors_proc_chips = NULL; +sensors_chip_name *sensors_proc_chips = NULL; int sensors_proc_chips_count = 0; int sensors_proc_chips_max = 0; diff --git a/lib/data.h b/lib/data.h index 01b55e13..2fd0519a 100644 --- a/lib/data.h +++ b/lib/data.h @@ -118,11 +118,6 @@ typedef struct sensors_bus { int lineno; } sensors_bus; -/* /proc/sys/dev/sensors/chips line representation */ -typedef struct sensors_proc_chips_entry { - sensors_chip_name name; -} sensors_proc_chips_entry; - /* Internal data about a single chip feature. name is the string name used to refer to this feature (both in config files and through user functions); @@ -164,13 +159,13 @@ extern sensors_bus *sensors_config_busses; extern int sensors_config_busses_count; extern int sensors_config_busses_max; -extern sensors_proc_chips_entry *sensors_proc_chips; +extern sensors_chip_name *sensors_proc_chips; extern int sensors_proc_chips_count; extern int sensors_proc_chips_max; #define sensors_add_proc_chips(el) sensors_add_array_el( \ (el), &sensors_proc_chips, &sensors_proc_chips_count,\ - &sensors_proc_chips_max, sizeof(struct sensors_proc_chips_entry)) + &sensors_proc_chips_max, sizeof(struct sensors_chip_name)) extern sensors_bus *sensors_proc_bus; extern int sensors_proc_bus_count; diff --git a/lib/init.c b/lib/init.c index 79492e9f..dfc4cdf8 100644 --- a/lib/init.c +++ b/lib/init.c @@ -27,7 +27,6 @@ #include "sysfs.h" #include "scanner.h" -static void free_proc_chips_entry(sensors_proc_chips_entry entry); static void free_chip_name(sensors_chip_name name); static void free_bus(sensors_bus bus); static void free_chip(sensors_chip chip); @@ -61,7 +60,7 @@ void sensors_cleanup(void) sensors_scanner_exit(); for (i = 0; i < sensors_proc_chips_count; i++) - free_proc_chips_entry(sensors_proc_chips[i]); + free_chip_name(sensors_proc_chips[i]); free(sensors_proc_chips); sensors_proc_chips = NULL; sensors_proc_chips_count = sensors_proc_chips_max = 0; @@ -85,11 +84,6 @@ void sensors_cleanup(void) sensors_proc_bus_count = sensors_proc_bus_max = 0; } -void free_proc_chips_entry(sensors_proc_chips_entry entry) -{ - free_chip_name(entry.name); -} - void free_chip_name(sensors_chip_name name) { free(name.prefix); diff --git a/lib/sysfs.c b/lib/sysfs.c index 8be60fd0..f1fdbea5 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -219,7 +219,7 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) int domain, bus, slot, fn, i; struct sysfs_attribute *attr, *bus_attr; char bus_path[SYSFS_PATH_MAX]; - sensors_proc_chips_entry entry; + sensors_chip_name name; /* ignore any device without name attribute */ if (!(attr = sysfs_get_device_attr(dev, "name"))) @@ -231,22 +231,22 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) return 0; /* NB: attr->value[attr->len-1] == '\n'; chop that off */ - entry.name.prefix = strndup(attr->value, attr->len - 1); - if (!entry.name.prefix) + name.prefix = strndup(attr->value, attr->len - 1); + if (!name.prefix) sensors_fatal_error(__FUNCTION__, "out of memory"); - entry.name.busname = strdup(dev->path); - if (!entry.name.busname) + name.busname = strdup(dev->path); + if (!name.busname) sensors_fatal_error(__FUNCTION__, "out of memory"); - if (sscanf(dev->name, "%d-%x", &entry.name.bus, &entry.name.addr) == 2) { + if (sscanf(dev->name, "%d-%x", &name.bus, &name.addr) == 2) { /* find out if legacy ISA or not */ - if (entry.name.bus == 9191) - entry.name.bus = SENSORS_CHIP_NAME_BUS_ISA; + if (name.bus == 9191) + name.bus = SENSORS_CHIP_NAME_BUS_ISA; else { snprintf(bus_path, sizeof(bus_path), "%s/class/i2c-adapter/i2c-%d/device/name", - sensors_sysfs_mount, entry.name.bus); + sensors_sysfs_mount, name.bus); if ((bus_attr = sysfs_open_attribute(bus_path))) { if (sysfs_read_attribute(bus_attr)) @@ -254,24 +254,24 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) if (bus_attr->value && !strncmp(bus_attr->value, "ISA ", 4)) - entry.name.bus = SENSORS_CHIP_NAME_BUS_ISA; + name.bus = SENSORS_CHIP_NAME_BUS_ISA; sysfs_close_attribute(bus_attr); } } - } else if (sscanf(dev->name, "%*[a-z0-9_].%d", &entry.name.addr) == 1) { + } else if (sscanf(dev->name, "%*[a-z0-9_].%d", &name.addr) == 1) { /* must be new ISA (platform driver) */ - entry.name.bus = SENSORS_CHIP_NAME_BUS_ISA; + name.bus = SENSORS_CHIP_NAME_BUS_ISA; } else if (sscanf(dev->name, "%x:%x:%x.%x", &domain, &bus, &slot, &fn) == 4) { /* PCI */ - entry.name.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn; - entry.name.bus = SENSORS_CHIP_NAME_BUS_PCI; + name.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn; + name.bus = SENSORS_CHIP_NAME_BUS_PCI; } else return -SENSORS_ERR_PARSE; /* check whether this chip is known in the static list */ for (i = 0; sensors_chip_features_list[i].prefix; i++) - if (!strcasecmp(sensors_chip_features_list[i].prefix, entry.name.prefix)) + if (!strcasecmp(sensors_chip_features_list[i].prefix, name.prefix)) break; /* if no chip definition matches */ @@ -287,7 +287,7 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) total_dynamic++; } - sensors_add_proc_chips(&entry); + sensors_add_proc_chips(&name); return 0; }