From fe14085d934833995a217394473b1f8650d5b9a8 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Tue, 5 Sep 2006 11:35:51 +0000 Subject: [PATCH] sensors-detect: Add generic PCI SMBus adapter detection. The detection is based of the PCI device class (SMBus is 0x0c05). This will let us spot new adapters. Of course we can't load or even suggest a driver for an unknown adapter, but at least the user will know there's something to be investigated, and this should help us when users report such configurations. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4143 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/detect/sensors-detect | 48 ++++++++++++++++++++++++++++---------- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/CHANGES b/CHANGES index dddf1797..5a24248d 100644 --- a/CHANGES +++ b/CHANGES @@ -82,6 +82,7 @@ lm_sensors CHANGES file Add VT8237A and VT8251 Remove detection of nVidia graphics adapters Use sysfs for PCI device enumeration + Add generic PCI SMBus adapter detection 2.10.0 (20060214) diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index ffc51a85..4027b05c 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -2208,27 +2208,42 @@ sub adapter_pci_detection_sis_96x } } +# Build and return a PCI device's bus ID +sub pci_busid($) +{ + my $device = shift; + my $busid; + + $busid = sprintf("\%02x:\%02x.\%x", + $device->{bus}, $device->{slot}, $device->{func}); + $busid = sprintf("\%04x:", $device->{domain}) . $busid + if defined $device->{domain}; + + return $busid; +} + sub adapter_pci_detection { - my ($key,$device,$try,@res); + my ($key, $device, $try, @res, %smbus); print "Probing for PCI bus adapters...\n"; # Custom detection routine for some SiS chipsets adapter_pci_detection_sis_96x(); - # Generic detection loop + # Build a list of detected SMBus devices + foreach $key (keys %pci_list) { + $device = $pci_list{$key}; + $smbus{$key}++ + if exists $device->{class} && $device->{class} == 0x0c05; # SMBus + } + + # Loop over the known I2C/SMBus adapters foreach $try (@pci_adapters) { $key = sprintf("%04x:%04x", $try->{vendid}, $try->{devid}); if (exists $pci_list{$key}) { $device = $pci_list{$key}; printf "Use driver `\%s' for device \%s: \%s\n", - $try->{driver}, - (defined $device->{domain} ? - sprintf("\%04x:\%02x:\%02x.\%x", $device->{domain}, - $device->{bus}, $device->{slot}, $device->{func}) : - sprintf("\%02x:\%02x.\%x", - $device->{bus}, $device->{slot}, $device->{func})), - $try->{procid}; + $try->{driver}, pci_busid($device), $try->{procid}; if ($try->{driver} eq "to-be-tested") { print "\nWe are currently looking for testers for this adapter!\n". "Please see http://www.lm-sensors.org/wiki/NewDrivers\n". @@ -2238,12 +2253,21 @@ sub adapter_pci_detection print "\n"; } push @res,$try->{driver}; + + # Delete from detected SMBus device list + delete $smbus{$key}; } } + + # Now see if there are unknown SMBus devices left + foreach $key (keys %smbus) { + $device = $pci_list{$key}; + printf "Found unknown SMBus adapter \%04x:\%04x at \%s.\n", + $device->{vendid}, $device->{devid}, pci_busid($device); + } + if (! @res) { - print ("Sorry, no PCI bus adapters found.\n"); - } else { - printf ("Probe successfully concluded.\n"); + print "Sorry, no known PCI bus adapters found.\n"; } return @res; }