Changeset 5176

Show
Ignore:
Timestamp:
04/14/08 17:27:59 (7 months ago)
Author:
khali
Message:

Add support for virtual hwmon devices. This closes Red Hat bug #437637
and ticket #2305.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lm-sensors/branches/lm-sensors-3.0.0/CHANGES

    r5175 r5176  
    66              Parse the configuration file in C locale 
    77              Late compute statements override early ones 
     8              Support virtual hwmon devices (#2309) 
    89  sensors-detect: Add SMSC SCH5027D detection 
    910                  Do not access I/O ports on PPC 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/access.c

    r5175 r5176  
    348348        case SENSORS_BUS_TYPE_SPI: 
    349349                return "SPI adapter"; 
     350        case SENSORS_BUS_TYPE_VIRTUAL: 
     351                return "Virtual device"; 
    350352        } 
    351353 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/data.c

    r5163 r5176  
    110110        else if (!strncmp(name, "spi", dash - name)) 
    111111                res->bus.type = SENSORS_BUS_TYPE_SPI; 
     112        else if (!strncmp(name, "virtual", dash - name)) 
     113                res->bus.type = SENSORS_BUS_TYPE_VIRTUAL; 
    112114        else 
    113115                goto ERROR; 
     
    170172                return snprintf(str, size, "%s-spi-%hd-%x", chip->prefix, 
    171173                                chip->bus.nr, chip->addr); 
     174        case SENSORS_BUS_TYPE_VIRTUAL: 
     175                return snprintf(str, size, "%s-virtual-%x", chip->prefix, 
     176                                chip->addr); 
    172177        } 
    173178 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/sensors.h

    r5163 r5176  
    3232   API additions like new flags / enum values. The second digit is for tracking 
    3333   larger additions like new methods. */ 
    34 #define SENSORS_API_VERSION 0x400 
     34#define SENSORS_API_VERSION 0x401 
    3535 
    3636#define SENSORS_CHIP_NAME_PREFIX_ANY NULL 
     
    4242#define SENSORS_BUS_TYPE_PCI    2 
    4343#define SENSORS_BUS_TYPE_SPI    3 
     44#define SENSORS_BUS_TYPE_VIRTUAL        4 
    4445#define SENSORS_BUS_NR_ANY      (-1) 
    4546#define SENSORS_BUS_NR_IGNORE   (-2) 
  • lm-sensors/branches/lm-sensors-3.0.0/lib/sysfs.c

    r5174 r5176  
    476476        if (!entry.chip.path) 
    477477                sensors_fatal_error(__func__, "Out of memory"); 
     478 
     479        if (dev_path == NULL) { 
     480                /* Virtual device */ 
     481                entry.chip.bus.type = SENSORS_BUS_TYPE_VIRTUAL; 
     482                entry.chip.bus.nr = 0; 
     483                /* For now we assume that virtual devices are unique */ 
     484                entry.chip.addr = 0; 
     485                goto done; 
     486        } 
    478487 
    479488        /* Find bus type */ 
     
    546555        } 
    547556 
     557done: 
    548558        if (sensors_read_dynamic_chip(&entry, hwmon_path) < 0) 
    549559                goto exit_free; 
     
    594604        snprintf(linkpath, NAME_MAX, "%s/device", path); 
    595605        dev_len = readlink(linkpath, device, NAME_MAX - 1); 
    596         if (dev_len < 0) 
    597                 return -SENSORS_ERR_KERNEL; 
    598         device[dev_len] = '\0'; 
    599         device_p = strrchr(device, '/') + 1; 
    600  
    601         /* The attributes we want might be those of the hwmon class device, 
    602            or those of the device itself. */ 
    603         err = sensors_read_one_sysfs_chip(linkpath, device_p, path); 
    604         if (err == 0) 
    605                 err = sensors_read_one_sysfs_chip(linkpath, device_p, linkpath); 
     606        if (dev_len < 0) { 
     607                /* No device link? Treat as virtual */ 
     608                err = sensors_read_one_sysfs_chip(NULL, NULL, path); 
     609        } else { 
     610                device[dev_len] = '\0'; 
     611                device_p = strrchr(device, '/') + 1; 
     612 
     613                /* The attributes we want might be those of the hwmon class 
     614                   device, or those of the device itself. */ 
     615                err = sensors_read_one_sysfs_chip(linkpath, device_p, path); 
     616                if (err == 0) 
     617                        err = sensors_read_one_sysfs_chip(linkpath, device_p, 
     618                                                          linkpath); 
     619        } 
    606620        if (err < 0) 
    607621                return err;