Changeset 2654 for lm-sensors/trunk/lib/proc.c
- Timestamp:
- 08/08/04 18:38:28 (9 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/lib/proc.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/lib/proc.c
r2426 r2654 72 72 sizeof(struct sensors_bus)) 73 73 74 int getsysname(const sensors_chip_feature *feature, char *sysname, int *sysmag); 74 int getsysname(const sensors_chip_feature *feature, char *sysname, 75 int *sysmag, char *altsysname); 75 76 76 77 /* This reads /proc/sys/dev/sensors/chips into memory */ … … 305 306 int buflen = BUF_LEN; 306 307 int mag, eepromoffset, fd, ret=0; 307 char n[NAME_MAX];308 FILE *f;309 308 310 309 if(!foundsysfs) … … 314 313 return -SENSORS_ERR_NO_ENTRY; 315 314 if(foundsysfs) { 315 char n[NAME_MAX], altn[NAME_MAX]; 316 FILE *f; 316 317 strcpy(n, name.busname); 317 318 strcat(n, "/"); … … 336 337 return -SENSORS_ERR_PROC; 337 338 } else { 339 strcpy(altn, n); 338 340 /* use rindex to append sysname to n */ 339 getsysname(the_feature, rindex(n, '\0'), &mag); 340 if ((f = fopen(n, "r")) != NULL) { 341 getsysname(the_feature, rindex(n, '\0'), &mag, rindex(altn, '\0')); 342 if ((f = fopen(n, "r")) != NULL 343 || (f = fopen(altn, "r")) != NULL) { 341 344 fscanf(f, "%lf", value); 342 345 fclose(f); … … 369 372 int buflen = BUF_LEN; 370 373 int mag; 371 char n[NAME_MAX];372 FILE *f;373 374 374 375 if(!foundsysfs) … … 378 379 return -SENSORS_ERR_NO_ENTRY; 379 380 if(foundsysfs) { 381 char n[NAME_MAX], altn[NAME_MAX]; 382 FILE *f; 380 383 strcpy(n, name.busname); 381 384 strcat(n, "/"); 385 strcpy(altn, n); 382 386 /* use rindex to append sysname to n */ 383 getsysname(the_feature, rindex(n, '\0'), &mag); 384 if ((f = fopen(n, "w")) != NULL) { 387 getsysname(the_feature, rindex(n, '\0'), &mag, rindex(altn, '\0')); 388 if ((f = fopen(n, "w")) != NULL 389 || (f = fopen(altn, "w")) != NULL) { 385 390 for (; mag > 0; mag --) 386 391 value *= 10.0; … … 455 460 Documentation/i2c/sysfs_interface in the kernel 456 461 */ 457 int getsysname(const sensors_chip_feature *feature, char *sysname, int *sysmag) 462 int getsysname(const sensors_chip_feature *feature, char *sysname, 463 int *sysmag, char *altsysname) 458 464 { 459 465 const char * name = feature->name; … … 465 471 const char * name, * sysname; 466 472 const int sysmag; 473 const char * altsysname; 467 474 }; 468 475 … … 472 479 { "beeps", "beep_mask", 0 }, 473 480 { "pwm", "fan1_pwm", 0 }, 474 { "vid", " in0_ref", INMAG},481 { "vid", "cpu0_vid", INMAG, "in0_ref" }, 475 482 { "remote_temp", "temp2_input", TEMPMAG }, 476 483 { "remote_temp_hyst", "temp2_max_hyst", TEMPMAG }, … … 485 492 486 493 494 /* default to a non-existent alternate name (should rarely be tried) */ 495 strcpy(altsysname, "_"); 496 487 497 /* use override in feature structure if present */ 488 498 if(feature->sysname != NULL) { … … 499 509 if(!strcmp(m->name, name)) { 500 510 strcpy(sysname, m->sysname); 511 if (m->altsysname != NULL) 512 strcpy(altsysname, m->altsysname); 501 513 *sysmag = m->sysmag; 502 514 return 0;
