Changeset 4474
- Timestamp:
- 06/26/07 13:33:09 (6 years ago)
- Location:
- lm-sensors/branches/lm-sensors-3.0.0/lib
- Files:
-
- 5 modified
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/lib/access.c
r4465 r4474 305 305 const sensors_chip_name *res; 306 306 res = (*nr >= sensors_proc_chips_count ? 307 NULL : &sensors_proc_chips[*nr] .name);307 NULL : &sensors_proc_chips[*nr]); 308 308 (*nr)++; 309 309 return res; -
lm-sensors/branches/lm-sensors-3.0.0/lib/data.c
r4465 r4474 37 37 int sensors_config_busses_max = 0; 38 38 39 sensors_ proc_chips_entry*sensors_proc_chips = NULL;39 sensors_chip_name *sensors_proc_chips = NULL; 40 40 int sensors_proc_chips_count = 0; 41 41 int sensors_proc_chips_max = 0; -
lm-sensors/branches/lm-sensors-3.0.0/lib/data.h
r4473 r4474 119 119 } sensors_bus; 120 120 121 /* /proc/sys/dev/sensors/chips line representation */122 typedef struct sensors_proc_chips_entry {123 sensors_chip_name name;124 } sensors_proc_chips_entry;125 126 121 /* Internal data about a single chip feature. 127 122 name is the string name used to refer to this feature (both in config … … 165 160 extern int sensors_config_busses_max; 166 161 167 extern sensors_ proc_chips_entry*sensors_proc_chips;162 extern sensors_chip_name *sensors_proc_chips; 168 163 extern int sensors_proc_chips_count; 169 164 extern int sensors_proc_chips_max; … … 171 166 #define sensors_add_proc_chips(el) sensors_add_array_el( \ 172 167 (el), &sensors_proc_chips, &sensors_proc_chips_count,\ 173 &sensors_proc_chips_max, sizeof(struct sensors_ proc_chips_entry))168 &sensors_proc_chips_max, sizeof(struct sensors_chip_name)) 174 169 175 170 extern sensors_bus *sensors_proc_bus; -
lm-sensors/branches/lm-sensors-3.0.0/lib/init.c
r4462 r4474 28 28 #include "scanner.h" 29 29 30 static void free_proc_chips_entry(sensors_proc_chips_entry entry);31 30 static void free_chip_name(sensors_chip_name name); 32 31 static void free_bus(sensors_bus bus); … … 62 61 63 62 for (i = 0; i < sensors_proc_chips_count; i++) 64 free_ proc_chips_entry(sensors_proc_chips[i]);63 free_chip_name(sensors_proc_chips[i]); 65 64 free(sensors_proc_chips); 66 65 sensors_proc_chips = NULL; … … 84 83 sensors_proc_bus = NULL; 85 84 sensors_proc_bus_count = sensors_proc_bus_max = 0; 86 }87 88 void free_proc_chips_entry(sensors_proc_chips_entry entry)89 {90 free_chip_name(entry.name);91 85 } 92 86 -
lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c
r4464 r4474 220 220 struct sysfs_attribute *attr, *bus_attr; 221 221 char bus_path[SYSFS_PATH_MAX]; 222 sensors_ proc_chips_entry entry;222 sensors_chip_name name; 223 223 224 224 /* ignore any device without name attribute */ … … 232 232 233 233 /* NB: attr->value[attr->len-1] == '\n'; chop that off */ 234 entry.name.prefix = strndup(attr->value, attr->len - 1);235 if (! entry.name.prefix)234 name.prefix = strndup(attr->value, attr->len - 1); 235 if (!name.prefix) 236 236 sensors_fatal_error(__FUNCTION__, "out of memory"); 237 237 238 entry.name.busname = strdup(dev->path);239 if (! entry.name.busname)238 name.busname = strdup(dev->path); 239 if (!name.busname) 240 240 sensors_fatal_error(__FUNCTION__, "out of memory"); 241 241 242 if (sscanf(dev->name, "%d-%x", & entry.name.bus, &entry.name.addr) == 2) {242 if (sscanf(dev->name, "%d-%x", &name.bus, &name.addr) == 2) { 243 243 /* find out if legacy ISA or not */ 244 if ( entry.name.bus == 9191)245 entry.name.bus = SENSORS_CHIP_NAME_BUS_ISA;244 if (name.bus == 9191) 245 name.bus = SENSORS_CHIP_NAME_BUS_ISA; 246 246 else { 247 247 snprintf(bus_path, sizeof(bus_path), 248 248 "%s/class/i2c-adapter/i2c-%d/device/name", 249 sensors_sysfs_mount, entry.name.bus);249 sensors_sysfs_mount, name.bus); 250 250 251 251 if ((bus_attr = sysfs_open_attribute(bus_path))) { … … 255 255 if (bus_attr->value 256 256 && !strncmp(bus_attr->value, "ISA ", 4)) 257 entry.name.bus = SENSORS_CHIP_NAME_BUS_ISA;257 name.bus = SENSORS_CHIP_NAME_BUS_ISA; 258 258 259 259 sysfs_close_attribute(bus_attr); 260 260 } 261 261 } 262 } else if (sscanf(dev->name, "%*[a-z0-9_].%d", & entry.name.addr) == 1) {262 } else if (sscanf(dev->name, "%*[a-z0-9_].%d", &name.addr) == 1) { 263 263 /* must be new ISA (platform driver) */ 264 entry.name.bus = SENSORS_CHIP_NAME_BUS_ISA;264 name.bus = SENSORS_CHIP_NAME_BUS_ISA; 265 265 } else if (sscanf(dev->name, "%x:%x:%x.%x", &domain, &bus, &slot, &fn) == 4) { 266 266 /* PCI */ 267 entry.name.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn;268 entry.name.bus = SENSORS_CHIP_NAME_BUS_PCI;267 name.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn; 268 name.bus = SENSORS_CHIP_NAME_BUS_PCI; 269 269 } else 270 270 return -SENSORS_ERR_PARSE; … … 272 272 /* check whether this chip is known in the static list */ 273 273 for (i = 0; sensors_chip_features_list[i].prefix; i++) 274 if (!strcasecmp(sensors_chip_features_list[i].prefix, entry.name.prefix))274 if (!strcasecmp(sensors_chip_features_list[i].prefix, name.prefix)) 275 275 break; 276 276 … … 288 288 } 289 289 290 sensors_add_proc_chips(& entry);290 sensors_add_proc_chips(&name); 291 291 292 292 return 0;
