Changeset 5092
- Timestamp:
- 01/05/08 13:31:55 (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) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lm-sensors/branches/lm-sensors-3.0.0/CHANGES
r5090 r5092 4 4 SVN 5 5 documentation: Update the application writing guidelines 6 libsensors: No longer depend on libsysfs 6 libsensors: No longer depend on libsysfs (#2262) 7 Don't guess the bus type from the device ID format (#2240) 7 8 Makefile: No warnings about ld configuration for staged installations 8 9 pwmconfig: Really hide errors on sysfs writes lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c
r5075 r5092 462 462 char *bus_attr; 463 463 char bus_path[NAME_MAX]; 464 char linkpath[NAME_MAX]; 465 char subsys_path[NAME_MAX], *subsys; 466 int sub_len; 464 467 sensors_chip_features entry; 465 468 … … 472 475 sensors_fatal_error(__FUNCTION__, "out of memory"); 473 476 474 if (sscanf(dev_name, "%hd-%x", &entry.chip.bus.nr, &entry.chip.addr) == 2) { 477 /* Find bus type */ 478 snprintf(linkpath, NAME_MAX, "%s/subsystem", dev_path); 479 sub_len = readlink(linkpath, subsys_path, NAME_MAX - 1); 480 if (sub_len < 0 && errno == ENOENT) { 481 /* Fallback to "bus" link for kernels <= 2.6.17 */ 482 snprintf(linkpath, NAME_MAX, "%s/bus", dev_path); 483 sub_len = readlink(linkpath, subsys_path, NAME_MAX - 1); 484 } 485 if (sub_len < 0) { 486 /* Older kernels (<= 2.6.11) have neither the subsystem 487 symlink nor the bus symlink */ 488 if (errno == ENOENT) 489 subsys = NULL; 490 else 491 goto exit_free; 492 } else { 493 subsys_path[sub_len] = '\0'; 494 subsys = strrchr(subsys_path, '/') + 1; 495 } 496 497 if ((!subsys || !strcmp(subsys, "i2c")) && 498 sscanf(dev_name, "%hd-%x", &entry.chip.bus.nr, 499 &entry.chip.addr) == 2) { 475 500 /* find out if legacy ISA or not */ 476 501 if (entry.chip.bus.nr == 9191) { … … 492 517 } 493 518 } 494 } else if (sscanf(dev_name, "spi%hd.%d", &entry.chip.bus.nr, 495 &entry.chip.addr) == 2) { 519 } else 520 if ((!subsys || !strcmp(subsys, "spi")) && 521 sscanf(dev_name, "spi%hd.%d", &entry.chip.bus.nr, 522 &entry.chip.addr) == 2) { 496 523 /* SPI */ 497 524 entry.chip.bus.type = SENSORS_BUS_TYPE_SPI; 498 } else if (sscanf(dev_name, "%*[a-z0-9_].%d", &entry.chip.addr) == 1) { 525 } else 526 if ((!subsys || !strcmp(subsys, "platform"))) { 499 527 /* must be new ISA (platform driver) */ 528 if (sscanf(dev_name, "%*[a-z0-9_].%d", &entry.chip.addr) != 1) 529 entry.chip.addr = 0; 500 530 entry.chip.bus.type = SENSORS_BUS_TYPE_ISA; 501 531 entry.chip.bus.nr = 0; 502 } else if (sscanf(dev_name, "%x:%x:%x.%x", &domain, &bus, &slot, &fn) == 4) { 532 } else 533 if ((!subsys || !strcmp(subsys, "pci")) && 534 sscanf(dev_name, "%x:%x:%x.%x", &domain, &bus, &slot, &fn) == 4) { 503 535 /* PCI */ 504 536 entry.chip.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn; … … 506 538 entry.chip.bus.nr = 0; 507 539 } else { 508 /* platform device with no id? */ 509 entry.chip.bus.type = SENSORS_BUS_TYPE_ISA; 510 entry.chip.bus.nr = 0; 511 entry.chip.addr = 0; 540 /* Ignore unknown device */ 541 err = 0; 542 goto exit_free; 512 543 } 513 544
