Changeset 5093
- Timestamp:
- 01/05/08 16:20:13 (11 months ago)
- Files:
-
- lm-sensors/branches/lm-sensors-3.0.0/CHANGES (modified) (1 diff)
- lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lm-sensors/branches/lm-sensors-3.0.0/CHANGES
r5092 r5093 6 6 libsensors: No longer depend on libsysfs (#2262) 7 7 Don't guess the bus type from the device ID format (#2240) 8 Add support for attributes in the hwmon class device (#2260) 8 9 Makefile: No warnings about ld configuration for staged installations 9 10 pwmconfig: Really hide errors on sysfs writes lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c
r5092 r5093 455 455 } 456 456 457 /* returns: 0 if successful, !0 otherwise */ 458 static int sensors_read_one_sysfs_chip(const char *dev_path, const char *dev_name) 457 /* returns: number of devices added (0 or 1) if successful, <0 otherwise */ 458 static int sensors_read_one_sysfs_chip(const char *dev_path, 459 const char *dev_name, 460 const char *hwmon_path) 459 461 { 460 462 int domain, bus, slot, fn; … … 468 470 469 471 /* ignore any device without name attribute */ 470 if (!(entry.chip.prefix = sysfs_read_attr( dev_path, "name")))472 if (!(entry.chip.prefix = sysfs_read_attr(hwmon_path, "name"))) 471 473 return 0; 472 474 473 entry.chip.path = strdup( dev_path);475 entry.chip.path = strdup(hwmon_path); 474 476 if (!entry.chip.path) 475 477 sensors_fatal_error(__FUNCTION__, "out of memory"); … … 543 545 } 544 546 545 if (sensors_read_dynamic_chip(&entry, dev_path) < 0)547 if (sensors_read_dynamic_chip(&entry, hwmon_path) < 0) 546 548 goto exit_free; 547 549 if (!entry.subfeature) { /* No subfeature, discard chip */ … … 551 553 sensors_add_proc_chips(&entry); 552 554 553 return 0;555 return 1; 554 556 555 557 exit_free: … … 559 561 } 560 562 563 static int sensors_add_hwmon_device_compat(const char *path, 564 const char *dev_name) 565 { 566 int err; 567 568 err = sensors_read_one_sysfs_chip(path, dev_name, path); 569 if (err < 0) 570 return err; 571 return 0; 572 } 573 561 574 /* returns 0 if successful, !0 otherwise */ 562 575 static int sensors_read_sysfs_chips_compat(void) … … 564 577 int ret; 565 578 566 ret = sysfs_foreach_busdev("i2c", sensors_ read_one_sysfs_chip);579 ret = sysfs_foreach_busdev("i2c", sensors_add_hwmon_device_compat); 567 580 if (ret && ret != ENOENT) 568 581 return -SENSORS_ERR_KERNEL; … … 574 587 { 575 588 char linkpath[NAME_MAX]; 576 char device[NAME_MAX] ;577 int dev_len ;589 char device[NAME_MAX], *device_p; 590 int dev_len, err; 578 591 (void)classdev; /* hide warning */ 579 592 … … 583 596 return -SENSORS_ERR_KERNEL; 584 597 device[dev_len] = '\0'; 585 586 return sensors_read_one_sysfs_chip(linkpath, strrchr(device, '/') + 1); 598 device_p = strrchr(device, '/') + 1; 599 600 /* The attributes we want might be those of the hwmon class device, 601 or those of the device itself. */ 602 err = sensors_read_one_sysfs_chip(linkpath, device_p, path); 603 if (err == 0) 604 err = sensors_read_one_sysfs_chip(linkpath, device_p, linkpath); 605 if (err < 0) 606 return err; 607 return 0; 587 608 } 588 609
