Changeset 5438
- Timestamp:
- 11/27/08 17:00:04 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/prog/detect/sensors-detect
r5437 r5438 2742 2742 # being a reference to a list of 2743 2743 # references to hashes of type 'detect_data'; 2744 # with field 'misdetected'2745 # being a reference to a list of2746 # references to hashes of type 'detect_data'2747 2744 2748 2745 # Type detect_data: … … 2773 2770 { 2774 2771 my ($chipdriver, $datahash) = @_; 2775 my ($i, $new_detected_ref, $new_misdetected_ref, $detected_ref, $misdetected_ref, 2776 $main_entry, $detected_entry, $put_in_detected, @hash_addrs, @entry_addrs, 2777 $do_not_add); 2772 my ($i, $new_detected_ref, $detected_ref, 2773 $main_entry, $detected_entry, $put_in_detected, @hash_addrs, @entry_addrs); 2778 2774 2779 2775 # First determine where the hash has to be added. … … 2783 2779 if ($i == @chips_detected) { 2784 2780 push @chips_detected, { driver => $chipdriver, 2785 detected => [], 2786 misdetected => [] }; 2781 detected => [] }; 2787 2782 } 2788 2783 $new_detected_ref = $chips_detected[$i]->{detected}; 2789 $new_misdetected_ref = $chips_detected[$i]->{misdetected}; 2790 2791 # Find out whether our new entry should go into the detected or the2792 # misdetected list. We compare all i2c addresses; if at least one matches,2793 # but our conf value is lower, we assume this is a misdetect.2784 2785 # Find out whether our new entry should go into the detected list 2786 # or not. We compare all i2c addresses; if at least one matches, 2787 # but our confidence value is lower, we assume this is a misdetection, 2788 # in which case we simply discard our new entry. 2794 2789 @hash_addrs = ($datahash->{i2c_addr}); 2795 2790 push @hash_addrs, @{$datahash->{i2c_sub_addrs}} 2796 2791 if exists $datahash->{i2c_sub_addrs}; 2797 2792 $put_in_detected = 1; 2798 $do_not_add = 0;2799 2793 FIND_LOOP: 2800 2794 foreach $main_entry (@chips_detected) { … … 2808 2802 $put_in_detected = 0; 2809 2803 } 2810 if ($chipdriver eq $main_entry->{driver}) {2811 $do_not_add = 1;2812 }2813 2804 last FIND_LOOP; 2814 2805 } … … 2817 2808 2818 2809 if ($put_in_detected) { 2819 # Here, we move all entries from detected to misdetectedwhich2810 # Here, we discard all entries which 2820 2811 # match at least in one main or sub address. This may not be the 2821 2812 # best idea to do, as it may remove detections without replacing 2822 2813 # them with second-best ones. Too bad. 2823 # (Khali 2003-09-13) If the driver is the same, the "misdetected"2824 # entry is simply deleted; failing to do so cause the configuration2825 # lines generated later to look very confusing (the driver will2826 # be told to ignore valid addresses).2827 @hash_addrs = ($datahash->{i2c_addr});2828 push @hash_addrs, @{$datahash->{i2c_sub_addrs}}2829 if exists $datahash->{i2c_sub_addrs};2830 2814 foreach $main_entry (@chips_detected) { 2831 2815 $detected_ref = $main_entry->{detected}; 2832 $misdetected_ref = $main_entry->{misdetected};2833 2816 for ($i = @$detected_ref-1; $i >=0; $i--) { 2834 2817 @entry_addrs = ($detected_ref->[$i]->{i2c_addr}); … … 2837 2820 if ($detected_ref->[$i]->{i2c_devnr} == $datahash->{i2c_devnr} and 2838 2821 any_list_match(\@entry_addrs, \@hash_addrs)) { 2839 push @$misdetected_ref, $detected_ref->[$i]2840 unless $chipdriver eq $main_entry->{driver};2841 2822 splice @$detected_ref, $i, 1; 2842 2823 } … … 2846 2827 # Now add the new entry to detected 2847 2828 push @$new_detected_ref, $datahash; 2848 } else {2849 # No hard work here2850 push @$new_misdetected_ref, $datahash2851 unless $do_not_add;2852 2829 } 2853 2830 } … … 2862 2839 { 2863 2840 my ($alias_detect, $chipdriver, $datahash) = @_; 2864 my ($i, $new_detected_ref, $new_misdetected_ref, $detected_ref, $misdetected_ref, 2865 $main_entry, $isalias); 2841 my ($i, $new_detected_ref, $detected_ref, $main_entry, $isalias); 2866 2842 2867 2843 # First determine where the hash has to be added. … … 2872 2848 if ($i == @chips_detected) { 2873 2849 push @chips_detected, { driver => $chipdriver, 2874 detected => [], 2875 misdetected => [] }; 2850 detected => [] }; 2876 2851 } 2877 2852 $new_detected_ref = $chips_detected[$i]->{detected}; 2878 $new_misdetected_ref = $chips_detected[$i]->{misdetected};2879 2853 2880 2854 # Now, we are looking for aliases. An alias can only be the same chiptype. 2881 # If an alias is found in the misdetected list, we add the new information 2882 # and terminate this function. If it is found in the detected list, we 2855 # If it is found in the detected list, we 2883 2856 # still have to check whether another chip has claimed this ISA address. 2884 2857 # So we remove the old entry from the detected list and put it in datahash. 2885 2886 # Misdetected alias detection:2887 for ($i = 0; $i < @$new_misdetected_ref; $i++) {2888 if (exists $new_misdetected_ref->[$i]->{i2c_addr} and2889 not exists $new_misdetected_ref->[$i]->{isa_addr} and2890 defined $alias_detect and2891 $new_misdetected_ref->[$i]->{chipname} eq $datahash->{chipname}) {2892 open(local *FILE, "$dev_i2c$new_misdetected_ref->[$i]->{i2c_devnr}") or2893 print("Can't open $dev_i2c$new_misdetected_ref->[$i]->{i2c_devnr}?!?\n"),2894 next;2895 binmode(FILE);2896 i2c_set_slave_addr(\*FILE, $new_misdetected_ref->[$i]->{i2c_addr}) or2897 print("Can't set I2C address for ",2898 "$dev_i2c$new_misdetected_ref->[$i]->{i2c_devnr}?!?\n"),2899 next;2900 if (&$alias_detect ($datahash->{isa_addr}, \*FILE,2901 $new_misdetected_ref->[$i]->{i2c_addr})) {2902 $new_misdetected_ref->[$i]->{isa_addr} = $datahash->{isa_addr};2903 return $new_misdetected_ref->[$i];2904 }2905 }2906 }2907 2908 # Detected alias detection:2909 2858 for ($i = 0; $i < @$new_detected_ref; $i++) { 2910 2859 if (exists $new_detected_ref->[$i]->{i2c_addr} and … … 2930 2879 } 2931 2880 2932 2933 # Find out whether our new entry should go into the detected or the 2934 # misdetected list. We only compare main isa_addr here, of course. 2935 # (Khali 2004-05-12) If the driver is the same, the "misdetected" 2936 # entry is simply deleted; same we do for I2C chips. 2881 # Find out whether our new entry should go into the detected list 2882 # or not. We only compare main isa_addr here, of course. 2937 2883 foreach $main_entry (@chips_detected) { 2938 2884 $detected_ref = $main_entry->{detected}; 2939 $misdetected_ref = $main_entry->{misdetected};2940 2885 for ($i = 0; $i < @{$main_entry->{detected}}; $i++) { 2941 2886 if (exists $detected_ref->[$i]->{isa_addr} and 2942 2887 exists $datahash->{isa_addr} and 2943 2888 $detected_ref->[$i]->{isa_addr} == $datahash->{isa_addr}) { 2944 if ($detected_ref->[$i]->{conf} >= $datahash->{conf}) { 2945 push @$new_misdetected_ref, $datahash 2946 unless $main_entry->{driver} eq $chipdriver; 2947 } else { 2948 push @$misdetected_ref, $detected_ref->[$i] 2949 unless $main_entry->{driver} eq $chipdriver; 2889 if ($detected_ref->[$i]->{conf} < $datahash->{conf}) { 2950 2890 splice @$detected_ref, $i, 1; 2951 2891 push @$new_detected_ref, $datahash; … … 5285 5225 } 5286 5226 5287 # Handle misdetects5288 foreach $detection (@{$chip->{misdetected}}) {5289 push @optionlist, $i2c_adapters[$detection->{i2c_devnr}]->{nr_later},5290 $detection->{i2c_addr}5291 if exists $detection->{i2c_addr} and5292 exists $i2c_adapters[$detection->{i2c_devnr}]->{nr_later};5293 push @optionlist, -1, $detection->{isa_addr}5294 if exists $detection->{isa_addr};5295 }5296 5297 5227 # Handle aliases 5298 5228 # As of kernel 2.6.28, alias detection is handled by kernel drivers … … 5450 5380 my ($chip, $data); 5451 5381 foreach $chip (@chips_detected) { 5452 print "\nDriver `$chip->{driver}' "; 5453 if (@{$chip->{detected}}) { 5454 if (@{$chip->{misdetected}}) { 5455 print "(should be inserted but causes problems):\n"; 5456 } else { 5457 print "(should be inserted):\n"; 5458 } 5459 } else { 5460 if (@{$chip->{misdetected}}) { 5461 print "(may not be inserted):\n"; 5462 } else { 5463 print "(should not be inserted, but is harmless):\n"; 5464 } 5465 } 5466 if (@{$chip->{detected}}) { 5467 print " Detects correctly:\n"; 5468 print_chips_report($chip->{detected}); 5469 } 5470 if (@{$chip->{misdetected}}) { 5471 print " Misdetects:\n"; 5472 print_chips_report($chip->{misdetected}); 5473 } 5382 next unless @{$chip->{detected}}; 5383 print "\nDriver `$chip->{driver}':\n"; 5384 print_chips_report($chip->{detected}); 5474 5385 } 5475 5386 print "\n";
