diff --git a/lib/access.c b/lib/access.c index 2adeed44..f63634ec 100644 --- a/lib/access.c +++ b/lib/access.c @@ -367,6 +367,8 @@ const char *sensors_get_adapter_name(const sensors_bus_id *bus) HID buses have a name nor where to find it. */ case SENSORS_BUS_TYPE_HID: return "HID adapter"; + case SENSORS_BUS_TYPE_MDIO: + return "MDIO adapter"; } /* bus types with several instances */ diff --git a/lib/data.c b/lib/data.c index 69f86466..937709f2 100644 --- a/lib/data.c +++ b/lib/data.c @@ -123,6 +123,8 @@ int sensors_parse_chip_name(const char *name, sensors_chip_name *res) res->bus.type = SENSORS_BUS_TYPE_ACPI; else if (!strncmp(name, "hid", dash - name)) res->bus.type = SENSORS_BUS_TYPE_HID; + else if (!strncmp(name, "mdio", dash - name)) + res->bus.type = SENSORS_BUS_TYPE_MDIO; else goto ERROR; name = dash + 1; @@ -193,6 +195,9 @@ int sensors_snprintf_chip_name(char *str, size_t size, case SENSORS_BUS_TYPE_HID: return snprintf(str, size, "%s-hid-%hd-%x", chip->prefix, chip->bus.nr, chip->addr); + case SENSORS_BUS_TYPE_MDIO: + return snprintf(str, size, "%s-mdio-%x", chip->prefix, + chip->addr); } return -SENSORS_ERR_CHIP_NAME; diff --git a/lib/sensors.conf.5 b/lib/sensors.conf.5 index dbf1ba21..d8695239 100644 --- a/lib/sensors.conf.5 +++ b/lib/sensors.conf.5 @@ -86,9 +86,10 @@ The name of the bus is either .IR isa , .IR pci , .IR virtual , -.I spi-* -or +.I spi-*, .I i2c-N +or +.I mdio with .I N being a bus number as bound with a diff --git a/lib/sensors.h b/lib/sensors.h index ed2d9a80..4c4b60ab 100644 --- a/lib/sensors.h +++ b/lib/sensors.h @@ -44,6 +44,7 @@ #define SENSORS_BUS_TYPE_VIRTUAL 4 #define SENSORS_BUS_TYPE_ACPI 5 #define SENSORS_BUS_TYPE_HID 6 +#define SENSORS_BUS_TYPE_MDIO 7 #define SENSORS_BUS_NR_ANY (-1) #define SENSORS_BUS_NR_IGNORE (-2) diff --git a/lib/sysfs.c b/lib/sysfs.c index f44a88de..dcc6af5a 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -717,6 +717,12 @@ static int sensors_read_one_sysfs_chip(const char *dev_path, /* As of kernel 2.6.32, the hid device names don't look good */ entry.chip.bus.nr = bus; entry.chip.addr = id; + } else + if (subsys && !strcmp(subsys, "mdio_bus")) { + if (sscanf(dev_name, "%*[^:]:%d", &entry.chip.addr) != 1) + entry.chip.addr = 0; + entry.chip.bus.type = SENSORS_BUS_TYPE_MDIO; + entry.chip.bus.nr = 0; } else { /* Ignore unknown device */ err = 0;