summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2008-12-02 22:08:45 +0000
committerkhali <khali@7894878c-1315-0410-8ee3-d5d059ff63e0>2008-12-02 22:08:45 +0000
commitdcc8a2bcd1796dc93026ab0668c33159d28f9e6a (patch)
tree4be52b6b73fe2d60d609d1186f0840c34c4036e2
parentd57255debc9f8bd51159051cf74b26ab42a72ceb (diff)
downloadlm-sensors-dcc8a2bcd1796dc93026ab0668c33159d28f9e6a.tar.gz
Do not scan I2C adapters on multimedia cards by default. I've never
seen a hardware monitoring chip on such boards, and probing them can cause problems. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5504 7894878c-1315-0410-8ee3-d5d059ff63e0
-rw-r--r--CHANGES1
-rwxr-xr-xprog/detect/sensors-detect43
2 files changed, 40 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index 44673eea..1086ae41 100644
--- a/CHANGES
+++ b/CHANGES
@@ -36,6 +36,7 @@ SVN-HEAD
Probe chip types from safest to more risky (#2322)
Add an option to skip ISA probes except IPMI
Skip ISA detection by default if a Super I/O was found (#2322)
+ Do not scan I2C adapters on multimedia cards by default
3.0.3 (2008-09-28)
libsensors: Avoid namespace pollution
diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect
index f867e1d5..e06c31e0 100755
--- a/prog/detect/sensors-detect
+++ b/prog/detect/sensors-detect
@@ -2064,6 +2064,16 @@ sub sysfs_device_driver
return basename($link);
}
+# From a sysfs device path, return the subsystem name, or undef
+sub sysfs_device_subsystem
+{
+ my $device = shift;
+
+ my $link = readlink("$device/subsystem");
+ return unless defined $link;
+ return basename($link);
+}
+
# From a sysfs device path and an attribute name, return the attribute
# value, or undef
sub sysfs_device_attribute
@@ -2702,17 +2712,42 @@ sub probe_free_i2c_address
}
}
+# $_[0]: The number of the adapter to check
+# Returns: 1 if the I2C adapter is on a PCI multimedia adapter, 0 otherwise
+sub is_multimedia_i2c_adapter
+{
+ my ($adapter_nr) = @_;
+ my ($adapter, $subsystem, $class);
+
+ $adapter = "$sysfs_root/class/i2c-adapter/i2c-$adapter_nr";
+ $subsystem = sysfs_device_subsystem("$adapter/device");
+ return 0 unless defined $subsystem && $subsystem eq "pci";
+
+ $class = sysfs_device_attribute("$adapter/device", "class");
+ return 0 unless defined $class;
+ $class = oct($class) if $class =~ /^0/;
+ return ($class & 0xff0000) == 0x040000;
+}
+
# $_[0]: The number of the adapter to scan
sub scan_i2c_adapter
{
my ($adapter_nr) = @_;
- my ($funcs, $chip, $addr, $input, @not_to_scan);
+ my ($funcs, $chip, $addr, $multimedia, $input, @not_to_scan);
- print "Next adapter: $i2c_adapters[$adapter_nr]->{name} (i2c-$adapter_nr)\n".
- "Do you want to scan it? (YES/no/selectively): ";
+ # Do not probe adapters on PCI multimedia cards by default
+ $multimedia = is_multimedia_i2c_adapter($adapter_nr);
+
+ printf "Next adapter: $i2c_adapters[$adapter_nr]->{name} (i2c-$adapter_nr)\n".
+ "Do you want to scan it? (\%s): ",
+ $multimedia ? "yes/NO/selectively" : "YES/no/selectively";
$input = <STDIN>;
- return if $input =~ /^\s*n/i;
+ if ($input =~ /^\s*n/i
+ || ($multimedia && $input !~ /^\s*[ys]/i)) {
+ print "\n";
+ return;
+ }
if ($input =~ /^\s*s/i) {
print "Please enter one or more addresses not to scan. Separate them with commas.\n",