Changeset 5434

Show
Ignore:
Timestamp:
11/26/08 17:36:04 (5 years ago)
Author:
khali
Message:

Fix handling of bus driver names with an underscore.
Simplify loading of bus drivers: we don't really need to make this
part interactive, as nothing can really go wrong at this point.

Location:
lm-sensors/branches/lm-sensors-3.0.0
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/branches/lm-sensors-3.0.0/CHANGES

    r5433 r5434  
    2727                  Let kernel 2.6.28 and later handle chips aliases 
    2828                  Unload kernel drivers when we are done with them (#2329) 
     29                  Fix handling of bus driver names with an underscore 
     30                  Simplify loading of bus drivers 
    2931 
    30323.0.3 (2008-09-28) 
  • lm-sensors/branches/lm-sensors-3.0.0/prog/detect/sensors-detect

    r5433 r5434  
    22982298  local $_; 
    22992299  while (<INPUTFILE>) { 
    2300     tr/_/-/; 
     2300    tr/-/_/; # Probably not needed 
    23012301    $modules_list{$1} = 1 if m/^(\S*)/; 
    23022302  } 
     2303} 
     2304 
     2305sub is_module_loaded 
     2306{ 
     2307        my $module = shift; 
     2308        $module =~ tr/-/_/; 
     2309        return exists $modules_list{$module} 
     2310} 
     2311 
     2312sub load_module 
     2313{ 
     2314        my $module = shift; 
     2315 
     2316        return if is_module_loaded($module); 
     2317 
     2318        system("modprobe", $module); 
     2319        if (($? >> 8) != 0) { 
     2320                print "Failed to load module $module.\n"; 
     2321                return -1; 
     2322        } 
     2323         
     2324        print "Module $module loaded successfully.\n"; 
     2325        push @modules_we_loaded, $module; 
     2326 
     2327        # Update the list of loaded modules 
     2328        my $normalized = $module; 
     2329        $normalized =~ tr/-/_/; 
     2330        $modules_list{$normalized} = 1; 
    23032331} 
    23042332 
     
    24482476sub adapter_pci_detection 
    24492477{ 
    2450   my ($key, $device, $try, @res, %smbus); 
     2478  my ($key, $device, $try, %smbus, $count); 
    24512479  print "Probing for PCI bus adapters...\n"; 
    24522480 
     
    24792507          } 
    24802508        } else { 
    2481           printf "Use driver `\%s' for device \%s: \%s\n", 
     2509          printf "Using driver `\%s' for device \%s: \%s\n", 
    24822510                 $try->{driver}, pci_busid($device), $try->{procid}; 
    2483           push @res, $try->{driver}; 
     2511          $count++; 
     2512          load_module($try->{driver}); 
    24842513        } 
    24852514 
     
    24962525  } 
    24972526 
    2498   if (! @res) { 
     2527  if (!$count) { 
    24992528    print "Sorry, no supported PCI bus adapters found.\n"; 
    25002529  } 
    2501   return @res; 
    25022530} 
    25032531 
     
    53025330sub main 
    53035331{ 
    5304   my (@adapters, $res, $did_adapter_detection, $adapter); 
    5305  
    53065332  # We won't go very far if not root 
    53075333  unless ($> == 0) { 
     
    53335359  print "\n"; 
    53345360 
    5335   print "We can start with probing for (PCI) I2C or SMBus adapters.\n"; 
    5336   print "Do you want to probe now? (YES/no): "; 
    5337   @adapters = adapter_pci_detection() 
    5338                         if ($did_adapter_detection = not <STDIN> =~ /\s*[Nn]/); 
     5361  adapter_pci_detection(); 
    53395362  print "\n"; 
    5340  
    5341   if (not $did_adapter_detection) { 
    5342     print "As you skipped adapter detection, we will only scan already loaded\n". 
    5343           "adapter modules.\n"; 
    5344   } else { 
    5345     print "We will now try to load each adapter module in turn.\n" 
    5346       if (@adapters); 
    5347     foreach $adapter (@adapters) { 
    5348       if (exists($modules_list{$adapter})) { 
    5349         print "Module `$adapter' already loaded.\n"; 
    5350       } else { 
    5351         print "Load `$adapter' (say NO if built into your kernel)? (YES/no): "; 
    5352         unless (<STDIN> =~ /^\s*[Nn]/) { 
    5353           if (system("modprobe", $adapter)) { 
    5354             print "Loading failed... skipping.\n"; 
    5355           } else { 
    5356             print "Module loaded successfully.\n"; 
    5357             push @modules_we_loaded, $adapter; 
    5358             $modules_list{$adapter} = 1; 
    5359           } 
    5360         } 
    5361       } 
    5362     } 
    5363   } 
    53645363 
    53655364  print "If you have undetectable or unsupported I2C/SMBus adapters, you can have\n". 
     
    53675366  initialize_i2c_adapters_list(); 
    53685367 
    5369   if (! -e "$sysfs_root/class/i2c-dev") { 
    5370     print "To continue, we need module `i2c-dev' to be loaded.\n"; 
    5371     print "Do you want to load `i2c-dev' now? (YES/no): "; 
    5372     if (<STDIN> =~ /^\s*n/i) { 
    5373       print "Well, you will know best.\n"; 
    5374     } elsif (system("modprobe", "i2c-dev")) { 
    5375       print "Loading failed, expect problems later on.\n"; 
    5376     } else { 
    5377       print "Module loaded successfully.\n"; 
    5378       push @modules_we_loaded, "i2c-dev"; 
    5379       $modules_list{"i2c-dev"} = 1; 
    5380     } 
    5381     print "\n"; 
    5382   } 
     5368  load_module("i2c-dev") unless -e "$sysfs_root/class/i2c-dev"; 
    53835369 
    53845370  $i2c_addresses_to_scan = i2c_addresses_to_scan();