Changeset 4510
- Timestamp:
- 06/28/07 16:39:34 (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
r4508 r4510 106 106 const sensors_chip_feature *features; 107 107 108 for (i = 0; sensors_chip_features_list[i].chip.prefix; i++)109 if (sensors_match_chip(sensors_ chip_features_list[i].chip, *chip)) {110 features = sensors_ chip_features_list[i].feature;108 for (i = 0; i < sensors_proc_chips_count; i++) 109 if (sensors_match_chip(sensors_proc_chips[i].chip, *chip)) { 110 features = sensors_proc_chips[i].feature; 111 111 for (j = 0; features[j].data.name; j++) 112 112 if (features[j].data.number == feature) … … 125 125 const sensors_chip_feature *features; 126 126 127 for (i = 0; sensors_chip_features_list[i].chip.prefix; i++)128 if (sensors_match_chip(sensors_ chip_features_list[i].chip, *chip)) {129 features = sensors_ chip_features_list[i].feature;127 for (i = 0; i < sensors_proc_chips_count; i++) 128 if (sensors_match_chip(sensors_proc_chips[i].chip, *chip)) { 129 features = sensors_proc_chips[i].feature; 130 130 for (j = 0; features[j].data.name; j++) 131 131 if (!strcasecmp(features[j].data.name, feature)) … … 305 305 const sensors_chip_name *res; 306 306 res = (*nr >= sensors_proc_chips_count ? 307 NULL : &sensors_proc_chips[*nr] );307 NULL : &sensors_proc_chips[*nr].chip); 308 308 (*nr)++; 309 309 return res; … … 333 333 int i; 334 334 335 for (i = 0; sensors_chip_features_list[i].chip.prefix; i++)336 if (sensors_match_chip(sensors_ chip_features_list[i].chip, name)) {337 feature_list = sensors_ chip_features_list[i].feature;335 for (i = 0; i < sensors_proc_chips_count; i++) 336 if (sensors_match_chip(sensors_proc_chips[i].chip, name)) { 337 feature_list = sensors_proc_chips[i].feature; 338 338 if (!*nr1 && !*nr2) { /* Return the first entry */ 339 339 if (!feature_list[0].data.name) /* The list may be empty */ -
lm-sensors/branches/lm-sensors-3.0.0/lib/data.c
r4508 r4510 37 37 int sensors_config_busses_max = 0; 38 38 39 sensors_chip_ name*sensors_proc_chips = NULL;39 sensors_chip_features *sensors_proc_chips = NULL; 40 40 int sensors_proc_chips_count = 0; 41 41 int sensors_proc_chips_max = 0; … … 44 44 int sensors_proc_bus_count = 0; 45 45 int sensors_proc_bus_max = 0; 46 47 #define PLACEHOLDER_ELEMENTS {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}, {{0}}48 49 sensors_chip_features sensors_chip_features_list[] = {50 PLACEHOLDER_ELEMENTS,51 { { 0 } }52 };53 46 54 47 static int sensors_substitute_chip(sensors_chip_name *name,int lineno); -
lm-sensors/branches/lm-sensors-3.0.0/lib/data.h
r4508 r4510 160 160 extern int sensors_config_busses_max; 161 161 162 extern sensors_chip_ name*sensors_proc_chips;162 extern sensors_chip_features *sensors_proc_chips; 163 163 extern int sensors_proc_chips_count; 164 164 extern int sensors_proc_chips_max; … … 166 166 #define sensors_add_proc_chips(el) sensors_add_array_el( \ 167 167 (el), &sensors_proc_chips, &sensors_proc_chips_count,\ 168 &sensors_proc_chips_max, sizeof(struct sensors_chip_ name))168 &sensors_proc_chips_max, sizeof(struct sensors_chip_features)) 169 169 170 170 extern sensors_bus *sensors_proc_bus; … … 176 176 &sensors_proc_bus_max, sizeof(struct sensors_bus)) 177 177 178 extern sensors_chip_features sensors_chip_features_list[];179 180 /* this should match the total number of elements in PLACEHOLDER_ELEMENTS */181 #define N_PLACEHOLDER_ELEMENTS 10182 183 178 #endif /* def LIB_SENSORS_DATA_H */ -
lm-sensors/branches/lm-sensors-3.0.0/lib/init.c
r4474 r4510 29 29 30 30 static void free_chip_name(sensors_chip_name name); 31 static void free_chip_features(sensors_chip_feature *features); 31 32 static void free_bus(sensors_bus bus); 32 33 static void free_chip(sensors_chip chip); … … 60 61 sensors_scanner_exit(); 61 62 62 for (i = 0; i < sensors_proc_chips_count; i++) 63 free_chip_name(sensors_proc_chips[i]); 63 for (i = 0; i < sensors_proc_chips_count; i++) { 64 free_chip_name(sensors_proc_chips[i].chip); 65 free_chip_features(sensors_proc_chips[i].feature); 66 } 64 67 free(sensors_proc_chips); 65 68 sensors_proc_chips = NULL; … … 89 92 free(name.prefix); 90 93 free(name.busname); 94 } 95 96 void free_chip_features(sensors_chip_feature *features) 97 { 98 int i; 99 100 for (i = 0; features[i].data.name; i++) 101 free(features[i].data.name); 102 free(features); 91 103 } 92 104 -
lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c
r4509 r4510 62 62 } 63 63 64 static 65 sensors_chip_features sensors_read_dynamic_chip(struct sysfs_device *sysdir)64 static int sensors_read_dynamic_chip(sensors_chip_features *chip, 65 struct sysfs_device *sysdir) 66 66 { 67 67 int i, type, fnum = 1; 68 68 struct sysfs_attribute *attr; 69 69 struct dlist *attrs; 70 sensors_chip_features ret = {{0}, 0};71 70 /* room for all 3 (in, fan, temp) types, with all their subfeatures 72 71 + misc features. We use a large sparse table at first to store all … … 82 81 83 82 if (attrs == NULL) 84 return ret;83 return -ENOENT; 85 84 86 85 memset(features, 0, sizeof(features)); … … 91 90 92 91 if (!strcmp(name, "name")) { 93 ret.chip.prefix = strndup(attr->value, strlen(attr->value) - 1);92 /* Already done */ 94 93 continue; 95 94 } … … 193 192 } 194 193 195 ret.feature = dyn_features;196 197 return ret;194 chip->feature = dyn_features; 195 196 return 0; 198 197 } 199 198 … … 216 215 static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) 217 216 { 218 static int total_dynamic = 0; 219 int domain, bus, slot, fn, i; 217 int domain, bus, slot, fn; 220 218 struct sysfs_attribute *attr, *bus_attr; 221 219 char bus_path[SYSFS_PATH_MAX]; 222 sensors_chip_ name name;220 sensors_chip_features entry; 223 221 224 222 /* ignore any device without name attribute */ … … 232 230 233 231 /* NB: attr->value[attr->len-1] == '\n'; chop that off */ 234 name.prefix = strndup(attr->value, attr->len - 1);235 if (! name.prefix)232 entry.chip.prefix = strndup(attr->value, attr->len - 1); 233 if (!entry.chip.prefix) 236 234 sensors_fatal_error(__FUNCTION__, "out of memory"); 237 235 238 name.busname = strdup(dev->path);239 if (! name.busname)236 entry.chip.busname = strdup(dev->path); 237 if (!entry.chip.busname) 240 238 sensors_fatal_error(__FUNCTION__, "out of memory"); 241 239 242 if (sscanf(dev->name, "%d-%x", & name.bus, &name.addr) == 2) {240 if (sscanf(dev->name, "%d-%x", &entry.chip.bus, &entry.chip.addr) == 2) { 243 241 /* find out if legacy ISA or not */ 244 if ( name.bus == 9191)245 name.bus = SENSORS_CHIP_NAME_BUS_ISA;242 if (entry.chip.bus == 9191) 243 entry.chip.bus = SENSORS_CHIP_NAME_BUS_ISA; 246 244 else { 247 245 snprintf(bus_path, sizeof(bus_path), 248 246 "%s/class/i2c-adapter/i2c-%d/device/name", 249 sensors_sysfs_mount, name.bus);247 sensors_sysfs_mount, entry.chip.bus); 250 248 251 249 if ((bus_attr = sysfs_open_attribute(bus_path))) { … … 255 253 if (bus_attr->value 256 254 && !strncmp(bus_attr->value, "ISA ", 4)) 257 name.bus = SENSORS_CHIP_NAME_BUS_ISA;255 entry.chip.bus = SENSORS_CHIP_NAME_BUS_ISA; 258 256 259 257 sysfs_close_attribute(bus_attr); 260 258 } 261 259 } 262 } else if (sscanf(dev->name, "%*[a-z0-9_].%d", & name.addr) == 1) {260 } else if (sscanf(dev->name, "%*[a-z0-9_].%d", &entry.chip.addr) == 1) { 263 261 /* must be new ISA (platform driver) */ 264 name.bus = SENSORS_CHIP_NAME_BUS_ISA;262 entry.chip.bus = SENSORS_CHIP_NAME_BUS_ISA; 265 263 } else if (sscanf(dev->name, "%x:%x:%x.%x", &domain, &bus, &slot, &fn) == 4) { 266 264 /* PCI */ 267 name.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn;268 name.bus = SENSORS_CHIP_NAME_BUS_PCI;265 entry.chip.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn; 266 entry.chip.bus = SENSORS_CHIP_NAME_BUS_PCI; 269 267 } else 270 268 return -SENSORS_ERR_PARSE; 271 269 272 if (total_dynamic < N_PLACEHOLDER_ELEMENTS) { 273 sensors_chip_features n_entry = sensors_read_dynamic_chip(dev); 274 n_entry.chip.addr = name.addr; 275 n_entry.chip.bus = name.bus; 276 277 /* skip to end of list */ 278 for(i = 0; sensors_chip_features_list[i].chip.prefix; i++); 279 280 sensors_chip_features_list[i] = n_entry; 281 282 total_dynamic++; 283 } 284 285 sensors_add_proc_chips(&name); 270 if (sensors_read_dynamic_chip(&entry, dev) < 0) 271 return -SENSORS_ERR_PARSE; 272 sensors_add_proc_chips(&entry); 286 273 287 274 return 0;
