mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-10-30 13:00:30 +00:00
Add support for virtual hwmon devices. This closes Red Hat bug #437637
and ticket #2305. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5176 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
c84fd9820e
commit
39b96fa477
6 files changed
+47
-10
No files matched your search
@@ -5,6 +5,7 @@ SVN-HEAD
|
||||
libsensors: Use __func__ instead of __FUNCTION__
|
||||
Parse the configuration file in C locale
|
||||
Late compute statements override early ones
|
||||
Support virtual hwmon devices (#2309)
|
||||
sensors-detect: Add SMSC SCH5027D detection
|
||||
Do not access I/O ports on PPC
|
||||
Move south bridge sensor detection to the right section
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
libsensors API history
|
||||
======================
|
||||
|
||||
SENSORS_API_VERSION tracks the evolutions made to the libsensors API
|
||||
over time. This document summarizes these evolutions so that application
|
||||
authors can quickly figure out how to test for the availability of a
|
||||
given new feature.
|
||||
|
||||
0x401 lm-sensors SVN
|
||||
* Added bus type "virtual":
|
||||
#define SENSORS_BUS_TYPE_VIRTUAL 4
|
||||
|
||||
0x400 lm-sensors 3.0.0 to 3.0.1
|
||||
* Initial API.
|
||||
@@ -347,6 +347,8 @@ const char *sensors_get_adapter_name(const sensors_bus_id *bus)
|
||||
so we don't have any custom string to return. */
|
||||
case SENSORS_BUS_TYPE_SPI:
|
||||
return "SPI adapter";
|
||||
case SENSORS_BUS_TYPE_VIRTUAL:
|
||||
return "Virtual device";
|
||||
}
|
||||
|
||||
/* bus types with several instances */
|
||||
|
||||
@@ -109,6 +109,8 @@ int sensors_parse_chip_name(const char *name, sensors_chip_name *res)
|
||||
res->bus.type = SENSORS_BUS_TYPE_PCI;
|
||||
else if (!strncmp(name, "spi", dash - name))
|
||||
res->bus.type = SENSORS_BUS_TYPE_SPI;
|
||||
else if (!strncmp(name, "virtual", dash - name))
|
||||
res->bus.type = SENSORS_BUS_TYPE_VIRTUAL;
|
||||
else
|
||||
goto ERROR;
|
||||
name = dash + 1;
|
||||
@@ -169,6 +171,9 @@ int sensors_snprintf_chip_name(char *str, size_t size,
|
||||
case SENSORS_BUS_TYPE_SPI:
|
||||
return snprintf(str, size, "%s-spi-%hd-%x", chip->prefix,
|
||||
chip->bus.nr, chip->addr);
|
||||
case SENSORS_BUS_TYPE_VIRTUAL:
|
||||
return snprintf(str, size, "%s-virtual-%x", chip->prefix,
|
||||
chip->addr);
|
||||
}
|
||||
|
||||
return -SENSORS_ERR_CHIP_NAME;
|
||||
|
||||
+2
-1
@@ -31,7 +31,7 @@
|
||||
when the API + ABI breaks), the third digit is incremented to track small
|
||||
API additions like new flags / enum values. The second digit is for tracking
|
||||
larger additions like new methods. */
|
||||
#define SENSORS_API_VERSION 0x400
|
||||
#define SENSORS_API_VERSION 0x401
|
||||
|
||||
#define SENSORS_CHIP_NAME_PREFIX_ANY NULL
|
||||
#define SENSORS_CHIP_NAME_ADDR_ANY -1
|
||||
@@ -41,6 +41,7 @@
|
||||
#define SENSORS_BUS_TYPE_ISA 1
|
||||
#define SENSORS_BUS_TYPE_PCI 2
|
||||
#define SENSORS_BUS_TYPE_SPI 3
|
||||
#define SENSORS_BUS_TYPE_VIRTUAL 4
|
||||
#define SENSORS_BUS_NR_ANY (-1)
|
||||
#define SENSORS_BUS_NR_IGNORE (-2)
|
||||
|
||||
|
||||
+23
-9
@@ -476,6 +476,15 @@ static int sensors_read_one_sysfs_chip(const char *dev_path,
|
||||
if (!entry.chip.path)
|
||||
sensors_fatal_error(__func__, "Out of memory");
|
||||
|
||||
if (dev_path == NULL) {
|
||||
/* Virtual device */
|
||||
entry.chip.bus.type = SENSORS_BUS_TYPE_VIRTUAL;
|
||||
entry.chip.bus.nr = 0;
|
||||
/* For now we assume that virtual devices are unique */
|
||||
entry.chip.addr = 0;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Find bus type */
|
||||
snprintf(linkpath, NAME_MAX, "%s/subsystem", dev_path);
|
||||
sub_len = readlink(linkpath, subsys_path, NAME_MAX - 1);
|
||||
@@ -545,6 +554,7 @@ static int sensors_read_one_sysfs_chip(const char *dev_path,
|
||||
goto exit_free;
|
||||
}
|
||||
|
||||
done:
|
||||
if (sensors_read_dynamic_chip(&entry, hwmon_path) < 0)
|
||||
goto exit_free;
|
||||
if (!entry.subfeature) { /* No subfeature, discard chip */
|
||||
@@ -593,16 +603,20 @@ static int sensors_add_hwmon_device(const char *path, const char *classdev)
|
||||
|
||||
snprintf(linkpath, NAME_MAX, "%s/device", path);
|
||||
dev_len = readlink(linkpath, device, NAME_MAX - 1);
|
||||
if (dev_len < 0)
|
||||
return -SENSORS_ERR_KERNEL;
|
||||
device[dev_len] = '\0';
|
||||
device_p = strrchr(device, '/') + 1;
|
||||
if (dev_len < 0) {
|
||||
/* No device link? Treat as virtual */
|
||||
err = sensors_read_one_sysfs_chip(NULL, NULL, path);
|
||||
} else {
|
||||
device[dev_len] = '\0';
|
||||
device_p = strrchr(device, '/') + 1;
|
||||
|
||||
/* The attributes we want might be those of the hwmon class device,
|
||||
or those of the device itself. */
|
||||
err = sensors_read_one_sysfs_chip(linkpath, device_p, path);
|
||||
if (err == 0)
|
||||
err = sensors_read_one_sysfs_chip(linkpath, device_p, linkpath);
|
||||
/* The attributes we want might be those of the hwmon class
|
||||
device, or those of the device itself. */
|
||||
err = sensors_read_one_sysfs_chip(linkpath, device_p, path);
|
||||
if (err == 0)
|
||||
err = sensors_read_one_sysfs_chip(linkpath, device_p,
|
||||
linkpath);
|
||||
}
|
||||
if (err < 0)
|
||||
return err;
|
||||
return 0;
|
||||
|
||||
Reference in new issue
Block a user