Changeset 5497
- Timestamp:
- 12/02/08 14:53:43 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/prog/detect/sensors-detect
r5496 r5497 2413 2413 #################### 2414 2414 2415 use vars qw(@chips_detected); 2416 2417 # We will build a complicated structure @chips_detected here, being: 2418 # A list of 2419 # references to hashes 2420 # with field 'driver', being a string with the driver name for this chip; 2421 # with field 'detected' 2422 # being a reference to a list of 2423 # references to hashes of type 'detect_data'; 2415 use vars qw(%chips_detected); 2416 2417 # We will build a complicated structure %chips_detected here, being a hash 2418 # where keys are driver names and values are detected chip information in 2419 # the form of a list of hashes of type 'detect_data'. 2424 2420 2425 2421 # Type detect_data: … … 2447 2443 { 2448 2444 my ($chipdriver, $datahash) = @_; 2449 my ($i, $new_detected_ref, $detected_ref, $ main_entry, $detected_entry,2445 my ($i, $new_detected_ref, $detected_ref, $detected_entry, 2450 2446 $put_in_detected, @hash_addrs, @entry_addrs); 2451 2447 2452 2448 # First determine where the hash has to be added. 2453 for ($i = 0; $i < @chips_detected; $i++) { 2454 last if ($chips_detected[$i]->{driver} eq $chipdriver); 2455 } 2456 if ($i == @chips_detected) { 2457 push @chips_detected, { 2458 driver => $chipdriver, 2459 detected => [], 2460 }; 2461 } 2462 $new_detected_ref = $chips_detected[$i]->{detected}; 2449 $chips_detected{$chipdriver} = [] 2450 unless exists $chips_detected{$chipdriver}; 2451 $new_detected_ref = $chips_detected{$chipdriver}; 2463 2452 2464 2453 # Find out whether our new entry should go into the detected list … … 2471 2460 $put_in_detected = 1; 2472 2461 FIND_LOOP: 2473 foreach $ main_entry (@chips_detected) {2474 foreach $detected_entry (@{$ main_entry->{detected}}) {2462 foreach $detected_ref (values %chips_detected) { 2463 foreach $detected_entry (@{$detected_ref}) { 2475 2464 @entry_addrs = ($detected_entry->{i2c_addr}); 2476 2465 push @entry_addrs, @{$detected_entry->{i2c_sub_addrs}} … … 2491 2480 # sub address. This may not be the best idea to do, as it may remove 2492 2481 # detections without replacing them with second-best ones. Too bad. 2493 foreach $main_entry (@chips_detected) { 2494 $detected_ref = $main_entry->{detected}; 2482 foreach $detected_ref (values %chips_detected) { 2495 2483 for ($i = @$detected_ref-1; $i >=0; $i--) { 2496 2484 @entry_addrs = ($detected_ref->[$i]->{i2c_addr}); … … 2514 2502 { 2515 2503 my ($chipdriver, $datahash) = @_; 2516 my ($i, $new_detected_ref, $detected_ref , $main_entry);2504 my ($i, $new_detected_ref, $detected_ref); 2517 2505 2518 2506 # First determine where the hash has to be added. 2519 for ($i = 0; $i < @chips_detected; $i++) { 2520 last if ($chips_detected[$i]->{driver} eq $chipdriver); 2521 } 2522 if ($i == @chips_detected) { 2523 push @chips_detected, { 2524 driver => $chipdriver, 2525 detected => [], 2526 }; 2527 } 2528 $new_detected_ref = $chips_detected[$i]->{detected}; 2507 $chips_detected{$chipdriver} = [] 2508 unless exists $chips_detected{$chipdriver}; 2509 $new_detected_ref = $chips_detected{$chipdriver}; 2529 2510 2530 2511 # Find out whether our new entry should go into the detected list 2531 2512 # or not. We only compare main isa_addr here, of course. 2532 foreach $main_entry (@chips_detected) { 2533 $detected_ref = $main_entry->{detected}; 2534 for ($i = 0; $i < @{$main_entry->{detected}}; $i++) { 2513 foreach $detected_ref (values %chips_detected) { 2514 for ($i = 0; $i < @{$detected_ref}; $i++) { 2535 2515 if (exists $detected_ref->[$i]->{isa_addr} and 2536 2516 exists $datahash->{isa_addr} and … … 4787 4767 sub generate_modprobes 4788 4768 { 4789 my ($ chip, $detection, $adap);4769 my ($driver, $detection, $adap); 4790 4770 my ($isa, $ipmi); 4791 4771 my ($modprobes, $configfile); 4792 4772 4793 foreach $ chip (@chips_detected) {4794 foreach $detection (@{$chip ->{detected}}) {4773 foreach $driver (keys %chips_detected) { 4774 foreach $detection (@{$chips_detected{$driver}}) { 4795 4775 # Tag adapters which host hardware monitoring chips we want to access 4796 4776 if (exists $detection->{i2c_devnr} … … 4803 4783 } 4804 4784 } 4805 if ($ chip->{driver}eq "ipmisensors") {4785 if ($driver eq "ipmisensors") { 4806 4786 $ipmi = 1; 4807 4787 } … … 4812 4792 # directly, so module options are no longer needed. 4813 4793 unless (kernel_version_at_least(2, 6, 28)) { 4814 foreach $ chip (@chips_detected) {4794 foreach $driver (keys %chips_detected) { 4815 4795 my @optionlist = (); 4816 foreach $detection (@{$chip ->{detected}}) {4796 foreach $detection (@{$chips_detected{$driver}}) { 4817 4797 next unless exists $detection->{i2c_addr} 4818 4798 && exists $detection->{isa_addr} … … 4827 4807 $configfile = "# hwmon module options\n" 4828 4808 unless defined $configfile; 4829 $configfile .= "options $ chip->{driver}ignore=".4809 $configfile .= "options $driver ignore=". 4830 4810 (join ",", @optionlist)."\n"; 4831 4811 } … … 4853 4833 # Now determine the chip probe lines 4854 4834 $modprobes .= "# Chip drivers\n"; 4855 foreach $ chip (@chips_detected) {4856 next if not @{$chip ->{detected}};4857 if ($ chip->{driver}eq "to-be-written") {4858 $modprobes .= "# no driver for $ chip->{detected}[0]{chipname} yet\n";4835 foreach $driver (keys %chips_detected) { 4836 next if not @{$chips_detected{$driver}}; 4837 if ($driver eq "to-be-written") { 4838 $modprobes .= "# no driver for ${$chips_detected{$driver}}[0]{chipname} yet\n"; 4859 4839 } else { 4860 open(local *INPUTFILE, "modprobe -l $ chip->{driver}2>/dev/null |");4840 open(local *INPUTFILE, "modprobe -l $driver 2>/dev/null |"); 4861 4841 local $_; 4862 4842 my $modulefound = 0; … … 4871 4851 # isn't supported 4872 4852 if ((($? >> 8) == 0) && ! $modulefound) { 4873 $modprobes .= "# Warning: the required module $ chip->{driver}is not currently installed\n".4853 $modprobes .= "# Warning: the required module $driver is not currently installed\n". 4874 4854 "# on your system. For status of 2.6 kernel ports check\n". 4875 4855 "# http://www.lm-sensors.org/wiki/Devices. If driver is built\n". 4876 4856 "# into the kernel, or unavailable, comment out the following line.\n"; 4877 4857 } 4878 $modprobes .= "modprobe $ chip->{driver}\n";4858 $modprobes .= "modprobe $driver\n"; 4879 4859 } 4880 4860 } … … 4989 4969 print "\n"; 4990 4970 4991 if (! @chips_detected) {4971 if (!keys %chips_detected) { 4992 4972 print "Sorry, no sensors were detected.\n", 4993 4973 "Either your sensors are not supported, or they are connected to an\n", … … 5003 4983 <STDIN>; 5004 4984 5005 my ($chip, $data); 5006 foreach $chip (@chips_detected) { 5007 next unless @{$chip->{detected}}; 5008 find_aliases($chip->{detected}); 5009 print "\nDriver `$chip->{driver}':\n"; 5010 print_chips_report($chip->{detected}); 4985 foreach my $driver (keys %chips_detected) { 4986 next unless @{$chips_detected{$driver}}; 4987 find_aliases($chips_detected{$driver}); 4988 print "\nDriver `$driver':\n"; 4989 print_chips_report($chips_detected{$driver}); 5011 4990 } 5012 4991 print "\n";
