summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES1
-rw-r--r--doc/libsensors-API.txt4
-rw-r--r--lib/access.c4
-rw-r--r--lib/data.c6
-rw-r--r--lib/sensors.h3
-rw-r--r--lib/sysfs.c9
6 files changed, 25 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index 54f04ee1..7042421a 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,7 @@ lm-sensors CHANGES file
SVN-HEAD
libsensors: Support upcoming sysfs path to i2c adapters
+ Add support for HID devices
fancontrol: Check that all referenced sysfs files exist
Check that all devices match the configuration file
pwmconfig: Exit immediately if not root
diff --git a/doc/libsensors-API.txt b/doc/libsensors-API.txt
index b244370e..3f3829ed 100644
--- a/doc/libsensors-API.txt
+++ b/doc/libsensors-API.txt
@@ -6,6 +6,10 @@ 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.
+0x421 lm-sensors SVN
+* Added bus type "hid":
+ #define SENSORS_BUS_TYPE_HID
+
0x420 lm-sensors 3.1.1
* Added a method to free the memory allocated by sensors_parse_chip_name()
void sensors_free_chip_name(sensors_chip_name *chip);
diff --git a/lib/access.c b/lib/access.c
index 92e63ddf..49bf2bc5 100644
--- a/lib/access.c
+++ b/lib/access.c
@@ -363,6 +363,10 @@ const char *sensors_get_adapter_name(const sensors_bus_id *bus)
return "Virtual device";
case SENSORS_BUS_TYPE_ACPI:
return "ACPI interface";
+ /* HID should probably not be there either, but I don't know if
+ HID buses have a name nor where to find it. */
+ case SENSORS_BUS_TYPE_HID:
+ return "HID adapter";
}
/* bus types with several instances */
diff --git a/lib/data.c b/lib/data.c
index 89452c44..b3b92dca 100644
--- a/lib/data.c
+++ b/lib/data.c
@@ -121,6 +121,8 @@ int sensors_parse_chip_name(const char *name, sensors_chip_name *res)
res->bus.type = SENSORS_BUS_TYPE_VIRTUAL;
else if (!strncmp(name, "acpi", dash - name))
res->bus.type = SENSORS_BUS_TYPE_ACPI;
+ else if (!strncmp(name, "hid", dash - name))
+ res->bus.type = SENSORS_BUS_TYPE_HID;
else
goto ERROR;
name = dash + 1;
@@ -131,6 +133,7 @@ int sensors_parse_chip_name(const char *name, sensors_chip_name *res)
switch (res->bus.type) {
case SENSORS_BUS_TYPE_I2C:
case SENSORS_BUS_TYPE_SPI:
+ case SENSORS_BUS_TYPE_HID:
if (!strncmp(name, "*-", 2)) {
res->bus.nr = SENSORS_BUS_NR_ANY;
name += 2;
@@ -187,6 +190,9 @@ int sensors_snprintf_chip_name(char *str, size_t size,
case SENSORS_BUS_TYPE_ACPI:
return snprintf(str, size, "%s-acpi-%x", chip->prefix,
chip->addr);
+ case SENSORS_BUS_TYPE_HID:
+ return snprintf(str, size, "%s-hid-%hd-%x", chip->prefix,
+ chip->bus.nr, chip->addr);
}
return -SENSORS_ERR_CHIP_NAME;
diff --git a/lib/sensors.h b/lib/sensors.h
index 8471006f..4f987213 100644
--- a/lib/sensors.h
+++ b/lib/sensors.h
@@ -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 0x420
+#define SENSORS_API_VERSION 0x421
#define SENSORS_CHIP_NAME_PREFIX_ANY NULL
#define SENSORS_CHIP_NAME_ADDR_ANY (-1)
@@ -43,6 +43,7 @@
#define SENSORS_BUS_TYPE_SPI 3
#define SENSORS_BUS_TYPE_VIRTUAL 4
#define SENSORS_BUS_TYPE_ACPI 5
+#define SENSORS_BUS_TYPE_HID 6
#define SENSORS_BUS_NR_ANY (-1)
#define SENSORS_BUS_NR_IGNORE (-2)
diff --git a/lib/sysfs.c b/lib/sysfs.c
index fec94981..44cf81e2 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -518,7 +518,7 @@ static int sensors_read_one_sysfs_chip(const char *dev_path,
const char *dev_name,
const char *hwmon_path)
{
- int domain, bus, slot, fn;
+ int domain, bus, slot, fn, vendor, product, id;
int err = -SENSORS_ERR_KERNEL;
char *bus_attr;
char bus_path[NAME_MAX];
@@ -612,6 +612,13 @@ static int sensors_read_one_sysfs_chip(const char *dev_path,
/* For now we assume that acpi devices are unique */
entry.chip.bus.nr = 0;
entry.chip.addr = 0;
+ } else
+ if (subsys && !strcmp(subsys, "hid") &&
+ sscanf(dev_name, "%x:%x:%x.%x", &bus, &vendor, &product, &id) == 4) {
+ entry.chip.bus.type = SENSORS_BUS_TYPE_HID;
+ /* As of kernel 2.6.32, the hid device names don't look good */
+ entry.chip.bus.nr = bus;
+ entry.chip.addr = id;
} else {
/* Ignore unknown device */
err = 0;