From 6af70f282854fdb7d019a50af3db8aaddf5efdd9 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 21 Dec 2006 08:24:01 +0000 Subject: [PATCH] libsensors: Get the i2c adapter names from the class device's "name" attribute, falling back to the device's "name" attribute for compatibility only. This change is needed to match ongoing cleanups in Linux 2.6's i2c-core. i2c adapters will soon be class devices only, the legacy i2c_adapter devices and driver are being removed. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4267 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + lib/sysfs.c | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index fac2c575..ca8f51bb 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,7 @@ SVN HEAD Add config-file scanner regression tests Add f71872f support Add w83627dhg support (David Holl, #2157) + Get the i2c adapter names from classdev.name Man page i2cdetect.8: Describe the output convention Man page sensors.1: Update (option -c) and clean up Module i2c-i801: Add ICH9 support diff --git a/lib/sysfs.c b/lib/sysfs.c index 20177a31..b2d06683 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -197,7 +197,11 @@ int sensors_read_sysfs_bus(void) if (!(dev = sysfs_get_classdev_device(clsdev))) continue; - if (!(attr = sysfs_get_device_attr(dev, "name"))) + /* Get the adapter name from the classdev "name" attribute + * (Linux 2.6.20 and later). If it fails, fall back to + * the device "name" attribute (for older kernels). */ + if (!(attr = sysfs_get_classdev_attr(clsdev, "name")) + && !(attr = sysfs_get_device_attr(dev, "name"))) continue; /* NB: attr->value[attr->len-1] == '\n'; chop that off */