Show
Ignore:
Timestamp:
11/30/08 13:34:48 (5 years ago)
Author:
khali
Message:

Reindent adapter detection functions.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/branches/lm-sensors-3.0.0/prog/detect/sensors-detect

    r5467 r5468  
    21662166sub adapter_pci_detection_sis_96x 
    21672167{ 
    2168   my $driver = ""; 
    2169  
    2170   # first, determine which driver if any... 
    2171   if (exists $pci_list{'1039:0016'}) { 
    2172     $driver = "i2c-sis96x"; 
    2173   } elsif (exists $pci_list{'1039:0008'}) { 
    2174     $driver = "i2c-sis5595"; 
    2175   } 
    2176  
    2177   # then, add the appropriate entries to @pci_adapters 
    2178   if ($driver eq "i2c-sis5595") { 
    2179     push @pci_adapters, @pci_adapters_sis5595; 
    2180   } elsif ($driver eq "i2c-sis96x") { 
    2181     push @pci_adapters, @pci_adapters_sis96x; 
    2182   } 
     2168        my $driver = ""; 
     2169 
     2170        # first, determine which driver if any... 
     2171        if (exists $pci_list{'1039:0016'}) { 
     2172                $driver = "i2c-sis96x"; 
     2173        } elsif (exists $pci_list{'1039:0008'}) { 
     2174                $driver = "i2c-sis5595"; 
     2175        } 
     2176 
     2177        # then, add the appropriate entries to @pci_adapters 
     2178        if ($driver eq "i2c-sis5595") { 
     2179                push @pci_adapters, @pci_adapters_sis5595; 
     2180        } elsif ($driver eq "i2c-sis96x") { 
     2181                push @pci_adapters, @pci_adapters_sis96x; 
     2182        } 
    21832183} 
    21842184 
     
    21862186sub pci_busid 
    21872187{ 
    2188   my $device = shift; 
    2189   my $busid; 
    2190  
    2191   $busid = sprintf("\%02x:\%02x.\%x", 
    2192                   $device->{bus}, $device->{slot}, $device->{func}); 
    2193   $busid = sprintf("\%04x:", $device->{domain}) . $busid 
    2194     if defined $device->{domain}; 
    2195  
    2196   return $busid; 
     2188        my $device = shift; 
     2189        my $busid; 
     2190 
     2191        $busid = sprintf("\%02x:\%02x.\%x", 
     2192                        $device->{bus}, $device->{slot}, $device->{func}); 
     2193        $busid = sprintf("\%04x:", $device->{domain}) . $busid 
     2194                if defined $device->{domain}; 
     2195 
     2196        return $busid; 
    21972197} 
    21982198 
    21992199sub adapter_pci_detection 
    22002200{ 
    2201   my ($key, $device, $try, %smbus, $count); 
    2202   print "Probing for PCI bus adapters...\n"; 
    2203  
    2204   # Custom detection routine for some SiS chipsets 
    2205   adapter_pci_detection_sis_96x(); 
    2206  
    2207   # Build a list of detected SMBus devices 
    2208   foreach $key (keys %pci_list) { 
    2209     $device = $pci_list{$key}; 
    2210     $smbus{$key}++ 
    2211       if exists $device->{class} && $device->{class} == 0x0c05; # SMBus 
    2212   } 
    2213  
    2214   # Loop over the known I2C/SMBus adapters 
    2215   foreach $try (@pci_adapters) { 
    2216     $key = sprintf("%04x:%04x", $try->{vendid}, $try->{devid}); 
    2217     if (exists $pci_list{$key}) { 
    2218         $device = $pci_list{$key}; 
    2219         if ($try->{driver} =~ m/^to-be-/) { 
    2220           printf "No known driver for device \%s: \%s\n", 
    2221                  pci_busid($device), $try->{procid}; 
    2222  
    2223           if ($try->{driver} eq "to-be-tested") { 
    2224             print "\nWe are currently looking for testers for this adapter!\n". 
    2225                   "Please check http://www.lm-sensors.org/wiki/Devices\n". 
    2226                   "and/or contact us if you want to help.\n\n"; 
    2227             print "Continue... "; 
    2228             <STDIN>; 
    2229             print "\n"; 
    2230           } 
    2231         } else { 
    2232           printf "Using driver `\%s' for device \%s: \%s\n", 
    2233                  $try->{driver}, pci_busid($device), $try->{procid}; 
    2234           $count++; 
    2235           load_module($try->{driver}); 
    2236         } 
    2237  
    2238         # Delete from detected SMBus device list 
    2239         delete $smbus{$key}; 
    2240     } 
    2241   } 
    2242  
    2243   # Now see if there are unknown SMBus devices left 
    2244   foreach $key (keys %smbus) { 
    2245     $device = $pci_list{$key}; 
    2246     printf "Found unknown SMBus adapter \%04x:\%04x at \%s.\n", 
    2247            $device->{vendid}, $device->{devid}, pci_busid($device); 
    2248   } 
    2249  
    2250   if (!$count) { 
    2251     print "Sorry, no supported PCI bus adapters found.\n"; 
    2252   } 
     2201        my ($key, $device, $try, %smbus, $count); 
     2202        print "Probing for PCI bus adapters...\n"; 
     2203 
     2204        # Custom detection routine for some SiS chipsets 
     2205        adapter_pci_detection_sis_96x(); 
     2206 
     2207        # Build a list of detected SMBus devices 
     2208        foreach $key (keys %pci_list) { 
     2209                $device = $pci_list{$key}; 
     2210                $smbus{$key}++ 
     2211                        if exists $device->{class} && 
     2212                           $device->{class} == 0x0c05; # SMBus 
     2213        } 
     2214 
     2215        # Loop over the known I2C/SMBus adapters 
     2216        foreach $try (@pci_adapters) { 
     2217                $key = sprintf("%04x:%04x", $try->{vendid}, $try->{devid}); 
     2218                if (exists $pci_list{$key}) { 
     2219                        $device = $pci_list{$key}; 
     2220                        if ($try->{driver} =~ m/^to-be-/) { 
     2221                                printf "No known driver for device \%s: \%s\n", 
     2222                                       pci_busid($device), $try->{procid}; 
     2223 
     2224                                if ($try->{driver} eq "to-be-tested") { 
     2225                                        print "\nWe are currently looking for testers for this adapter!\n". 
     2226                                              "Please check http://www.lm-sensors.org/wiki/Devices\n". 
     2227                                              "and/or contact us if you want to help.\n\n"; 
     2228                                        print "Continue... "; 
     2229                                        <STDIN>; 
     2230                                        print "\n"; 
     2231                                } 
     2232                        } else { 
     2233                                printf "Using driver `\%s' for device \%s: \%s\n", 
     2234                                       $try->{driver}, pci_busid($device), 
     2235                                       $try->{procid}; 
     2236                                $count++; 
     2237                                load_module($try->{driver}); 
     2238                        } 
     2239 
     2240                        # Delete from detected SMBus device list 
     2241                        delete $smbus{$key}; 
     2242                } 
     2243        } 
     2244 
     2245        # Now see if there are unknown SMBus devices left 
     2246        foreach $key (keys %smbus) { 
     2247                $device = $pci_list{$key}; 
     2248                printf "Found unknown SMBus adapter \%04x:\%04x at \%s.\n", 
     2249                       $device->{vendid}, $device->{devid}, pci_busid($device); 
     2250        } 
     2251 
     2252        print "Sorry, no supported PCI bus adapters found.\n" 
     2253                unless $count; 
    22532254} 
    22542255