From 337ffc5729f56796ea359cc51383ef4d60ea81ce Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 9 Jan 2006 19:55:18 +0000 Subject: [PATCH] Add support for the new platform drivers (Linux 2.6, sysfs). git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@3224 7894878c-1315-0410-8ee3-d5d059ff63e0 --- lib/sysfs.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/sysfs.c b/lib/sysfs.c index d7f81d53..fe13c6d7 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -71,24 +71,27 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) if (!entry.name.busname) sensors_fatal_error(__FUNCTION__, "out of memory"); - if (sscanf(dev->name, "%d-%x", &entry.name.bus, &entry.name.addr) != 2) + if (sscanf(dev->name, "%d-%x", &entry.name.bus, &entry.name.addr) == 2) { + /* find out if legacy ISA or not */ + snprintf(bus_path, sizeof(bus_path), + "%s/class/i2c-adapter/i2c-%d/device/name", + sensors_sysfs_mount, entry.name.bus); + + if ((bus_attr = sysfs_open_attribute(bus_path))) { + if (sysfs_read_attribute(bus_attr)) + return -SENSORS_ERR_PARSE; + + if (bus_attr->value && !strncmp(bus_attr->value, "ISA ", 4)) + entry.name.bus = SENSORS_CHIP_NAME_BUS_ISA; + + sysfs_close_attribute(bus_attr); + } + } else if (sscanf(dev->name, "%*[a-z0-9_].%d", &entry.name.addr) == 1) { + /* must be new ISA (platform driver) */ + entry.name.bus = SENSORS_CHIP_NAME_BUS_ISA; + } else return -SENSORS_ERR_PARSE; - /* find out if ISA or not */ - snprintf(bus_path, sizeof(bus_path), - "%s/class/i2c-adapter/i2c-%d/device/name", - sensors_sysfs_mount, entry.name.bus); - - if ((bus_attr = sysfs_open_attribute(bus_path))) { - if (sysfs_read_attribute(bus_attr)) - return -SENSORS_ERR_PARSE; - - if (bus_attr->value && !strncmp(bus_attr->value, "ISA ", 4)) - entry.name.bus = SENSORS_CHIP_NAME_BUS_ISA; - - sysfs_close_attribute(bus_attr); - } - sensors_add_proc_chips(&entry); return 0;