Changeset 5434
- Timestamp:
- 11/26/08 17:36:04 (4 years ago)
- Location:
- lm-sensors/branches/lm-sensors-3.0.0
- Files:
-
- 2 modified
-
CHANGES (modified) (1 diff)
-
prog/detect/sensors-detect (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/CHANGES
r5433 r5434 27 27 Let kernel 2.6.28 and later handle chips aliases 28 28 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 29 31 30 32 3.0.3 (2008-09-28) -
lm-sensors/branches/lm-sensors-3.0.0/prog/detect/sensors-detect
r5433 r5434 2298 2298 local $_; 2299 2299 while (<INPUTFILE>) { 2300 tr/ _/-/;2300 tr/-/_/; # Probably not needed 2301 2301 $modules_list{$1} = 1 if m/^(\S*)/; 2302 2302 } 2303 } 2304 2305 sub is_module_loaded 2306 { 2307 my $module = shift; 2308 $module =~ tr/-/_/; 2309 return exists $modules_list{$module} 2310 } 2311 2312 sub 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; 2303 2331 } 2304 2332 … … 2448 2476 sub adapter_pci_detection 2449 2477 { 2450 my ($key, $device, $try, @res, %smbus);2478 my ($key, $device, $try, %smbus, $count); 2451 2479 print "Probing for PCI bus adapters...\n"; 2452 2480 … … 2479 2507 } 2480 2508 } else { 2481 printf "Us edriver `\%s' for device \%s: \%s\n",2509 printf "Using driver `\%s' for device \%s: \%s\n", 2482 2510 $try->{driver}, pci_busid($device), $try->{procid}; 2483 push @res, $try->{driver}; 2511 $count++; 2512 load_module($try->{driver}); 2484 2513 } 2485 2514 … … 2496 2525 } 2497 2526 2498 if (! @res) {2527 if (!$count) { 2499 2528 print "Sorry, no supported PCI bus adapters found.\n"; 2500 2529 } 2501 return @res;2502 2530 } 2503 2531 … … 5302 5330 sub main 5303 5331 { 5304 my (@adapters, $res, $did_adapter_detection, $adapter);5305 5306 5332 # We won't go very far if not root 5307 5333 unless ($> == 0) { … … 5333 5359 print "\n"; 5334 5360 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(); 5339 5362 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 }5364 5363 5365 5364 print "If you have undetectable or unsupported I2C/SMBus adapters, you can have\n". … … 5367 5366 initialize_i2c_adapters_list(); 5368 5367 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"; 5383 5369 5384 5370 $i2c_addresses_to_scan = i2c_addresses_to_scan();
