mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-08 16:11:26 +00:00
Support more bus types (part 1 of 2). Originally libsensors was very
i2c-centric. Make it more neutral so that we can cleanly support additional bus types such as SPI or One-Wire. This first part introduces sensors_bus_id, and updates sensors_chip_name to use it. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4686 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
af2880326f
commit
7ee15371df
6 files changed
+92
-67
No files matched your search
+15
-9
@@ -226,14 +226,16 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev)
|
||||
if (!entry.chip.path)
|
||||
sensors_fatal_error(__FUNCTION__, "out of memory");
|
||||
|
||||
if (sscanf(dev->name, "%d-%x", &entry.chip.bus, &entry.chip.addr) == 2) {
|
||||
if (sscanf(dev->name, "%hd-%x", &entry.chip.bus.nr, &entry.chip.addr) == 2) {
|
||||
/* find out if legacy ISA or not */
|
||||
if (entry.chip.bus == 9191)
|
||||
entry.chip.bus = SENSORS_CHIP_NAME_BUS_ISA;
|
||||
else {
|
||||
if (entry.chip.bus.nr == 9191) {
|
||||
entry.chip.bus.type = SENSORS_BUS_TYPE_ISA;
|
||||
entry.chip.bus.nr = 0;
|
||||
} else {
|
||||
entry.chip.bus.type = SENSORS_BUS_TYPE_I2C;
|
||||
snprintf(bus_path, sizeof(bus_path),
|
||||
"%s/class/i2c-adapter/i2c-%d/device/name",
|
||||
sensors_sysfs_mount, entry.chip.bus);
|
||||
sensors_sysfs_mount, entry.chip.bus.nr);
|
||||
|
||||
if ((bus_attr = sysfs_open_attribute(bus_path))) {
|
||||
if (sysfs_read_attribute(bus_attr)) {
|
||||
@@ -242,19 +244,23 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev)
|
||||
}
|
||||
|
||||
if (bus_attr->value
|
||||
&& !strncmp(bus_attr->value, "ISA ", 4))
|
||||
entry.chip.bus = SENSORS_CHIP_NAME_BUS_ISA;
|
||||
&& !strncmp(bus_attr->value, "ISA ", 4)) {
|
||||
entry.chip.bus.type = SENSORS_BUS_TYPE_ISA;
|
||||
entry.chip.bus.nr = 0;
|
||||
}
|
||||
|
||||
sysfs_close_attribute(bus_attr);
|
||||
}
|
||||
}
|
||||
} else if (sscanf(dev->name, "%*[a-z0-9_].%d", &entry.chip.addr) == 1) {
|
||||
/* must be new ISA (platform driver) */
|
||||
entry.chip.bus = SENSORS_CHIP_NAME_BUS_ISA;
|
||||
entry.chip.bus.type = SENSORS_BUS_TYPE_ISA;
|
||||
entry.chip.bus.nr = 0;
|
||||
} else if (sscanf(dev->name, "%x:%x:%x.%x", &domain, &bus, &slot, &fn) == 4) {
|
||||
/* PCI */
|
||||
entry.chip.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn;
|
||||
entry.chip.bus = SENSORS_CHIP_NAME_BUS_PCI;
|
||||
entry.chip.bus.type = SENSORS_BUS_TYPE_PCI;
|
||||
entry.chip.bus.nr = 0;
|
||||
} else
|
||||
goto exit_free;
|
||||
|
||||
|
||||
Reference in new issue
Block a user