From d1d5799d51167a93b335451d25296ed844c24982 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 30 Oct 2012 17:18:45 +0000 Subject: [PATCH] sensors-detect: Fix parent class discovery when multiplexer is present Take multiplexers into account when looking up the parent device of each I2C adapter. We don't bother with old kernels as they didn't have support for multiplexers anyway. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@6085 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 5 +++-- prog/detect/sensors-detect | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 650ec83b..12c32a57 100644 --- a/CHANGES +++ b/CHANGES @@ -9,9 +9,10 @@ SVN HEAD Add long switches to manual page sensors-detect: Don't choke on systems without PCI Avoid probing EDID addresses on graphics cards (#2386) - Add detection of NCT6779D and NCT6102D/NCT6106D - Add detection of SMSC LPC47N217 and SIO10N268 + Add detection of NCT6779D and NCT6102D/NCT6106D + Add detection of SMSC LPC47N217 and SIO10N268 Do not scan I2C adapters on graphics cards by default + Fix parent class discovery when multiplexer is present 3.3.2 (2012-03-14) libsensors: Added support for new sysfs attributes diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index 4090fadc..475c76c1 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -2,7 +2,7 @@ # # sensors-detect - Detect hardware monitoring chips # Copyright (C) 1998 - 2002 Frodo Looijaard -# Copyright (C) 2004 - 2011 Jean Delvare +# Copyright (C) 2004 - 2012 Jean Delvare # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -2696,14 +2696,15 @@ sub initialize_i2c_adapters_list } elsif ($link =~ m/^(.*)\/i2c-$nr$/) { $entry->{path} = "${base_dir}/i2c-$nr/device"; $entry->{parent} = "${base_dir}/i2c-$nr/$1"; - } else { - $entry->{path} = "${base_dir}/i2c-$nr"; - $entry->{parent} = "$entry->{path}/device"; } - } else { + } + + # This works for all recent kernels (with or without + # CONFIG_I2C_COMPAT) + if (!defined $entry->{path}) { my $link = readlink("${base_dir}/i2c-$nr"); - $link =~ s/\/i2c-$nr$//; $entry->{path} = "${base_dir}/i2c-$nr"; + $link =~ s/(\/i2c-[0-9]+)+$//; # Handle multiplexers too $entry->{parent} = "${base_dir}/$link"; }