Changeset 5476

Show
Ignore:
Timestamp:
11/30/08 16:24:53 (4 years ago)
Author:
khali
Message:

Reindent more functions.

Files:
1 modified

Legend:

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

    r5475 r5476  
    24862486sub add_i2c_to_chips_detected 
    24872487{ 
    2488   my ($chipdriver, $datahash) = @_; 
    2489   my ($i, $new_detected_ref, $detected_ref, 
    2490       $main_entry, $detected_entry, $put_in_detected, @hash_addrs, @entry_addrs); 
    2491  
    2492   # First determine where the hash has to be added. 
    2493   for ($i = 0; $i < @chips_detected; $i++) { 
    2494     last if ($chips_detected[$i]->{driver} eq $chipdriver); 
    2495   } 
    2496   if ($i == @chips_detected) { 
    2497     push @chips_detected, { driver => $chipdriver, 
    2498                             detected => [] }; 
    2499   } 
    2500   $new_detected_ref = $chips_detected[$i]->{detected}; 
    2501  
    2502   # Find out whether our new entry should go into the detected list 
    2503   # or not. We compare all i2c addresses; if at least one matches, 
    2504   # but our confidence value is lower, we assume this is a misdetection, 
    2505   # in which case we simply discard our new entry. 
    2506   @hash_addrs = ($datahash->{i2c_addr}); 
    2507   push @hash_addrs, @{$datahash->{i2c_sub_addrs}} 
    2508        if exists $datahash->{i2c_sub_addrs}; 
    2509   $put_in_detected = 1; 
    2510   FIND_LOOP: 
    2511   foreach $main_entry (@chips_detected) { 
    2512     foreach $detected_entry (@{$main_entry->{detected}}) { 
    2513       @entry_addrs = ($detected_entry->{i2c_addr}); 
    2514       push @entry_addrs, @{$detected_entry->{i2c_sub_addrs}} 
    2515                if exists $detected_entry->{i2c_sub_addrs}; 
    2516       if ($detected_entry->{i2c_devnr} == $datahash->{i2c_devnr} and 
    2517           any_list_match(\@entry_addrs, \@hash_addrs)) { 
    2518         if ($detected_entry->{conf} >= $datahash->{conf}) { 
    2519           $put_in_detected = 0; 
    2520         } 
    2521         last FIND_LOOP; 
    2522       } 
    2523     } 
    2524   } 
    2525  
    2526   if ($put_in_detected) { 
    2527     # Here, we discard all entries which 
    2528     # match at least in one main or sub address. This may not be the 
    2529     # best idea to do, as it may remove detections without replacing 
    2530     # them with second-best ones. Too bad. 
    2531     foreach $main_entry (@chips_detected) { 
    2532       $detected_ref = $main_entry->{detected}; 
    2533       for ($i = @$detected_ref-1; $i >=0; $i--) { 
    2534         @entry_addrs = ($detected_ref->[$i]->{i2c_addr}); 
    2535         push @entry_addrs, @{$detected_ref->[$i]->{i2c_sub_addrs}} 
    2536              if exists $detected_ref->[$i]->{i2c_sub_addrs}; 
    2537         if ($detected_ref->[$i]->{i2c_devnr} == $datahash->{i2c_devnr} and 
    2538             any_list_match(\@entry_addrs, \@hash_addrs)) { 
    2539           splice @$detected_ref, $i, 1; 
    2540         } 
    2541       } 
    2542     } 
    2543  
    2544     # Now add the new entry to detected 
    2545     push @$new_detected_ref, $datahash; 
    2546   } 
     2488        my ($chipdriver, $datahash) = @_; 
     2489        my ($i, $new_detected_ref, $detected_ref, $main_entry, $detected_entry, 
     2490            $put_in_detected, @hash_addrs, @entry_addrs); 
     2491 
     2492        # First determine where the hash has to be added. 
     2493        for ($i = 0; $i < @chips_detected; $i++) { 
     2494                last if ($chips_detected[$i]->{driver} eq $chipdriver); 
     2495        } 
     2496        if ($i == @chips_detected) { 
     2497                push @chips_detected, { 
     2498                        driver => $chipdriver, 
     2499                        detected => [], 
     2500                }; 
     2501        } 
     2502        $new_detected_ref = $chips_detected[$i]->{detected}; 
     2503 
     2504        # Find out whether our new entry should go into the detected list 
     2505        # or not. We compare all i2c addresses; if at least one matches, 
     2506        # but our confidence value is lower, we assume this is a misdetection, 
     2507        # in which case we simply discard our new entry. 
     2508        @hash_addrs = ($datahash->{i2c_addr}); 
     2509        push @hash_addrs, @{$datahash->{i2c_sub_addrs}} 
     2510                if exists $datahash->{i2c_sub_addrs}; 
     2511        $put_in_detected = 1; 
     2512 FIND_LOOP: 
     2513        foreach $main_entry (@chips_detected) { 
     2514                foreach $detected_entry (@{$main_entry->{detected}}) { 
     2515                        @entry_addrs = ($detected_entry->{i2c_addr}); 
     2516                        push @entry_addrs, @{$detected_entry->{i2c_sub_addrs}} 
     2517                                if exists $detected_entry->{i2c_sub_addrs}; 
     2518                        if ($detected_entry->{i2c_devnr} == $datahash->{i2c_devnr} && 
     2519                            any_list_match(\@entry_addrs, \@hash_addrs)) { 
     2520                                if ($detected_entry->{conf} >= $datahash->{conf}) { 
     2521                                        $put_in_detected = 0; 
     2522                                } 
     2523                                last FIND_LOOP; 
     2524                        } 
     2525                } 
     2526        } 
     2527 
     2528        return unless $put_in_detected; 
     2529 
     2530        # Here, we discard all entries which match at least in one main or 
     2531        # sub address. This may not be the best idea to do, as it may remove 
     2532        # detections without replacing them with second-best ones. Too bad. 
     2533        foreach $main_entry (@chips_detected) { 
     2534                $detected_ref = $main_entry->{detected}; 
     2535                for ($i = @$detected_ref-1; $i >=0; $i--) { 
     2536                        @entry_addrs = ($detected_ref->[$i]->{i2c_addr}); 
     2537                        push @entry_addrs, @{$detected_ref->[$i]->{i2c_sub_addrs}} 
     2538                                if exists $detected_ref->[$i]->{i2c_sub_addrs}; 
     2539                        if ($detected_ref->[$i]->{i2c_devnr} == $datahash->{i2c_devnr} && 
     2540                            any_list_match(\@entry_addrs, \@hash_addrs)) { 
     2541                                splice @$detected_ref, $i, 1; 
     2542                        } 
     2543                } 
     2544        } 
     2545 
     2546        # Now add the new entry to detected 
     2547        push @$new_detected_ref, $datahash; 
    25472548} 
    25482549 
     
    25552556sub add_isa_to_chips_detected 
    25562557{ 
    2557   my ($alias_detect, $chipdriver, $datahash) = @_; 
    2558   my ($i, $new_detected_ref, $detected_ref, $main_entry, $isalias); 
    2559  
    2560   # First determine where the hash has to be added. 
    2561   $isalias = 0; 
    2562   for ($i = 0; $i < @chips_detected; $i++) { 
    2563     last if ($chips_detected[$i]->{driver} eq $chipdriver); 
    2564   } 
    2565   if ($i == @chips_detected) { 
    2566     push @chips_detected, { driver => $chipdriver, 
    2567                             detected => [] }; 
    2568   } 
    2569   $new_detected_ref = $chips_detected[$i]->{detected}; 
    2570  
    2571   # Now, we are looking for aliases. An alias can only be the same chiptype. 
    2572   # If it is found in the detected list, we 
    2573   # still have to check whether another chip has claimed this ISA address. 
    2574   # So we remove the old entry from the detected list and put it in datahash. 
    2575   for ($i = 0; $i < @$new_detected_ref; $i++) { 
    2576     if (exists $new_detected_ref->[$i]->{i2c_addr} and 
    2577         not exists $new_detected_ref->[$i]->{isa_addr} and 
    2578         defined $alias_detect and 
    2579         $new_detected_ref->[$i]->{chipname} eq $datahash->{chipname}) { 
    2580       open(local *FILE, "$dev_i2c$new_detected_ref->[$i]->{i2c_devnr}") or 
    2581         print("Can't open $dev_i2c$new_detected_ref->[$i]->{i2c_devnr}?!?\n"), 
    2582         next; 
    2583       binmode(FILE); 
    2584       i2c_set_slave_addr(\*FILE, $new_detected_ref->[$i]->{i2c_addr}) or 
    2585            print("Can't set I2C address for ", 
    2586                  "$dev_i2c$new_detected_ref->[$i]->{i2c_devnr}?!?\n"), 
    2587            next; 
    2588       if (&$alias_detect ($datahash->{isa_addr}, \*FILE, 
    2589                           $new_detected_ref->[$i]->{i2c_addr})) { 
    2590         $new_detected_ref->[$i]->{isa_addr} = $datahash->{isa_addr}; 
    2591         ($datahash) = splice (@$new_detected_ref, $i, 1); 
    2592         $isalias = 1; 
    2593         last; 
    2594       } 
    2595     } 
    2596   } 
    2597  
    2598   # Find out whether our new entry should go into the detected list 
    2599   # or not. We only compare main isa_addr here, of course. 
    2600   foreach $main_entry (@chips_detected) { 
    2601     $detected_ref = $main_entry->{detected}; 
    2602     for ($i = 0; $i < @{$main_entry->{detected}}; $i++) { 
    2603       if (exists $detected_ref->[$i]->{isa_addr} and 
    2604           exists $datahash->{isa_addr} and 
    2605           $detected_ref->[$i]->{isa_addr} == $datahash->{isa_addr}) { 
    2606         if ($detected_ref->[$i]->{conf} < $datahash->{conf}) { 
    2607           splice @$detected_ref, $i, 1; 
    2608           push @$new_detected_ref, $datahash; 
    2609         } 
    2610         if ($isalias) { 
    2611           return $datahash; 
    2612         } else { 
    2613           return 0; 
    2614         } 
    2615       } 
    2616     } 
    2617   } 
    2618  
    2619   # Not found? OK, put it in the detected list 
    2620   push @$new_detected_ref, $datahash; 
    2621   if ($isalias) { 
    2622     return $datahash; 
    2623   } else { 
    2624     return 0; 
    2625   } 
     2558        my ($alias_detect, $chipdriver, $datahash) = @_; 
     2559        my ($i, $new_detected_ref, $detected_ref, $main_entry, $isalias); 
     2560 
     2561        # First determine where the hash has to be added. 
     2562        $isalias = 0; 
     2563        for ($i = 0; $i < @chips_detected; $i++) { 
     2564                last if ($chips_detected[$i]->{driver} eq $chipdriver); 
     2565        } 
     2566        if ($i == @chips_detected) { 
     2567                push @chips_detected, { 
     2568                        driver => $chipdriver, 
     2569                        detected => [], 
     2570                }; 
     2571        } 
     2572        $new_detected_ref = $chips_detected[$i]->{detected}; 
     2573 
     2574        # Now, we are looking for aliases. An alias can only be the same 
     2575        # chiptype. If it is found in the detected list, we still have to 
     2576        # check whether another chip has claimed this ISA address. So we 
     2577        # remove the old entry from the detected list and put it in datahash. 
     2578        for ($i = 0; $i < @$new_detected_ref; $i++) { 
     2579                if (exists $new_detected_ref->[$i]->{i2c_addr} and 
     2580                    not exists $new_detected_ref->[$i]->{isa_addr} and 
     2581                    defined $alias_detect and 
     2582                    $new_detected_ref->[$i]->{chipname} eq $datahash->{chipname}) { 
     2583                        open(local *FILE, "$dev_i2c$new_detected_ref->[$i]->{i2c_devnr}") or 
     2584                                print("Can't open $dev_i2c$new_detected_ref->[$i]->{i2c_devnr}?!?\n"), 
     2585                                next; 
     2586                        binmode(FILE); 
     2587                        i2c_set_slave_addr(\*FILE, $new_detected_ref->[$i]->{i2c_addr}) or 
     2588                                print("Can't set I2C address for ", 
     2589                                      "$dev_i2c$new_detected_ref->[$i]->{i2c_devnr}?!?\n"), 
     2590                                next; 
     2591                        if (&$alias_detect($datahash->{isa_addr}, \*FILE, 
     2592                                           $new_detected_ref->[$i]->{i2c_addr})) { 
     2593                                $new_detected_ref->[$i]->{isa_addr} = $datahash->{isa_addr}; 
     2594                                ($datahash) = splice (@$new_detected_ref, $i, 1); 
     2595                                $isalias = 1; 
     2596                                last; 
     2597                        } 
     2598                } 
     2599        } 
     2600 
     2601        # Find out whether our new entry should go into the detected list 
     2602        # or not. We only compare main isa_addr here, of course. 
     2603        foreach $main_entry (@chips_detected) { 
     2604                $detected_ref = $main_entry->{detected}; 
     2605                for ($i = 0; $i < @{$main_entry->{detected}}; $i++) { 
     2606                        if (exists $detected_ref->[$i]->{isa_addr} and 
     2607                            exists $datahash->{isa_addr} and 
     2608                            $detected_ref->[$i]->{isa_addr} == $datahash->{isa_addr}) { 
     2609                                if ($detected_ref->[$i]->{conf} < $datahash->{conf}) { 
     2610                                        splice @$detected_ref, $i, 1; 
     2611                                        push @$new_detected_ref, $datahash; 
     2612                                } 
     2613                                if ($isalias) { 
     2614                                        return $datahash; 
     2615                                } else { 
     2616                                        return 0; 
     2617                                } 
     2618                        } 
     2619                } 
     2620        } 
     2621 
     2622        # Not found? OK, put it in the detected list 
     2623        push @$new_detected_ref, $datahash; 
     2624        if ($isalias) { 
     2625                return $datahash; 
     2626        } else { 
     2627                return 0; 
     2628        } 
    26262629} 
    26272630 
     
    26322635sub i2c_addresses_to_scan 
    26332636{ 
    2634   my @used; 
    2635   my @addresses; 
    2636   my $addr; 
    2637  
    2638   foreach my $chip (@chip_ids) { 
    2639     next unless defined $chip->{i2c_addrs}; 
    2640     foreach $addr (@{$chip->{i2c_addrs}}) { 
    2641       $used[$addr]++; 
    2642     } 
    2643   } 
    2644  
    2645   for ($addr = 0x03; $addr <= 0x77; $addr++) { 
    2646     push @addresses, $addr if $used[$addr]; 
    2647   } 
    2648   return \@addresses; 
     2637        my @used; 
     2638        my @addresses; 
     2639        my $addr; 
     2640 
     2641        foreach my $chip (@chip_ids) { 
     2642                next unless defined $chip->{i2c_addrs}; 
     2643                foreach $addr (@{$chip->{i2c_addrs}}) { 
     2644                        $used[$addr]++; 
     2645                } 
     2646        } 
     2647 
     2648        for ($addr = 0x03; $addr <= 0x77; $addr++) { 
     2649                push @addresses, $addr if $used[$addr]; 
     2650        } 
     2651        return \@addresses; 
    26492652} 
    26502653 
     
    26552658sub scan_adapter 
    26562659{ 
    2657   my ($adapter_nr, $adapter_name, $adapter_driver, $not_to_scan) = @_; 
    2658   my ($funcs, $chip, $addr, $conf, @chips, $new_hash, $other_addr); 
    2659  
    2660   # As we modify it, we need a copy 
    2661   my @not_to_scan = @$not_to_scan; 
    2662  
    2663   open(local *FILE, "$dev_i2c$adapter_nr") or 
    2664     (print "Can't open $dev_i2c$adapter_nr\n"), return; 
    2665   binmode(FILE); 
    2666  
    2667   # Can we probe this adapter? 
    2668   $funcs = i2c_get_funcs(\*FILE); 
    2669   if ($funcs < 0) { 
    2670     print "Adapter failed to provide its functionalities, skipping.\n"; 
    2671     return; 
    2672   } 
    2673   if (!($funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE))) { 
    2674     print "Adapter cannot be probed, skipping.\n"; 
    2675     return; 
    2676   } 
    2677   if (~$funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE)) { 
    2678     print "Adapter doesn't support all probing functions.\n", 
    2679           "Some addresses won't be probed.\n"; 
    2680   } 
    2681  
    2682   # Now scan each address in turn 
    2683   foreach $addr (@{$i2c_addresses_to_scan}) { 
    2684     # As the not_to_scan list is sorted, we can check it fast 
    2685     shift @not_to_scan # User skipped an address which we didn't intend to probe anyway 
    2686       while (@not_to_scan and $not_to_scan[0] < $addr); 
    2687     if (@not_to_scan and $not_to_scan[0] == $addr) { 
    2688       shift @not_to_scan; 
    2689       next; 
    2690     } 
    2691  
    2692     if (!i2c_set_slave_addr(\*FILE, $addr)) { 
    2693       # If the address is busy, we can normally find out which driver 
    2694       # requested it (if the kernel is recent enough, at least 2.6.16 
    2695       # and later are known to work), and we assume it is the right one. 
    2696       my ($device, $driver); 
    2697  
    2698       $device = sprintf("$sysfs_root/bus/i2c/devices/\%d-\%04x", 
    2699                              $adapter_nr, $addr); 
    2700       $driver = sysfs_device_driver($device); 
    2701  
    2702       if (defined($driver)) { 
    2703         $new_hash = { 
    2704           conf => 6, # Arbitrary confidence 
    2705           i2c_addr => $addr, 
    2706           chipname => sysfs_device_attribute($device, "name") || "unknown", 
    2707           i2c_adap => $adapter_name, 
    2708           i2c_driver => $adapter_driver, 
    2709           i2c_devnr => $adapter_nr, 
    2710         }; 
    2711  
    2712         printf "Client found at address 0x\%02x\n", $addr; 
    2713         printf "Handled by driver `\%s' (already loaded), chip type `\%s'\n", 
    2714                $driver, $new_hash->{chipname}; 
    2715  
    2716         # Only add it to the list if this is something we would have 
    2717         # detected, else we end up with random i2c chip drivers listed 
    2718         # (for example media/video drivers.) 
    2719         if (exists $modules_supported{$driver}) { 
    2720           add_i2c_to_chips_detected($driver, $new_hash); 
    2721         } else { 
    2722           print "    (note: this is probably NOT a sensor chip!)\n"; 
    2723         } 
    2724       } else { 
    2725         printf("Client at address 0x%02x can not be probed - ". 
    2726                "unload all client drivers first!\n", $addr); 
    2727       } 
    2728       next; 
    2729     } 
    2730  
    2731     next unless i2c_probe(\*FILE, $addr, $funcs); 
    2732     printf "Client found at address 0x%02x\n", $addr; 
    2733     if (!i2c_safety_check(\*FILE)) { 
    2734       print "Seems to be a 1-register-only device, skipping.\n"; 
    2735       next; 
    2736     } 
    2737  
    2738     $| = 1; 
    2739     foreach $chip (@chip_ids, @non_hwmon_chip_ids) { 
    2740       if (exists $chip->{i2c_addrs} and contains($addr, @{$chip->{i2c_addrs}})) { 
    2741         printf("\%-60s", sprintf("Probing for `\%s'... ", $chip->{name})); 
    2742         if (($conf, @chips) = &{$chip->{i2c_detect}} (\*FILE, $addr)) { 
    2743           if ($chip->{driver} eq "not-a-sensor") { 
    2744             print "Yes\n", 
    2745                   "    (confidence $conf, not a hardware monitoring chip"; 
    2746           } else { 
    2747             print "Success!\n", 
    2748                   "    (confidence $conf, driver `$chip->{driver}'"; 
    2749           } 
    2750           if (@chips) { 
    2751             print ", other addresses:"; 
    2752             @chips = sort @chips; 
    2753             foreach $other_addr (@chips) { 
    2754               printf(" 0x%02x", $other_addr); 
    2755             } 
    2756           } 
    2757           printf ")\n"; 
    2758  
    2759           next if ($chip->{driver} eq "not-a-sensor" 
    2760                 || $chip->{driver} eq "use-isa-instead"); 
    2761  
    2762           $new_hash = { conf => $conf, 
    2763                         i2c_addr => $addr, 
    2764                         chipname => $chip->{name}, 
    2765                         i2c_adap => $adapter_name, 
    2766                         i2c_driver => $adapter_driver, 
    2767                         i2c_devnr => $adapter_nr, 
    2768                       }; 
    2769           if (@chips) { 
    2770             my @chips_copy = @chips; 
    2771             $new_hash->{i2c_sub_addrs} = \@chips_copy; 
    2772           } 
    2773           add_i2c_to_chips_detected($chip->{driver}, $new_hash); 
    2774         } else { 
    2775           print "No\n"; 
    2776         } 
    2777       } 
    2778     } 
    2779     $| = 0; 
    2780   } 
     2660        my ($adapter_nr, $adapter_name, $adapter_driver, $not_to_scan) = @_; 
     2661        my ($funcs, $chip, $addr, $conf, @chips, $new_hash, $other_addr); 
     2662 
     2663        # As we modify it, we need a copy 
     2664        my @not_to_scan = @$not_to_scan; 
     2665 
     2666        open(local *FILE, "$dev_i2c$adapter_nr") or 
     2667                (print "Can't open $dev_i2c$adapter_nr\n"), return; 
     2668        binmode(FILE); 
     2669 
     2670        # Can we probe this adapter? 
     2671        $funcs = i2c_get_funcs(\*FILE); 
     2672        if ($funcs < 0) { 
     2673                print "Adapter failed to provide its functionalities, skipping.\n"; 
     2674                return; 
     2675        } 
     2676        if (!($funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE))) { 
     2677                print "Adapter cannot be probed, skipping.\n"; 
     2678                return; 
     2679        } 
     2680        if (~$funcs & (I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_READ_BYTE)) { 
     2681                print "Adapter doesn't support all probing functions.\n", 
     2682                      "Some addresses won't be probed.\n"; 
     2683        } 
     2684 
     2685        # Now scan each address in turn 
     2686        foreach $addr (@{$i2c_addresses_to_scan}) { 
     2687                # As the not_to_scan list is sorted, we can check it fast 
     2688                shift @not_to_scan # User skipped an address which we didn't intend to probe anyway 
     2689                        while (@not_to_scan and $not_to_scan[0] < $addr); 
     2690                if (@not_to_scan and $not_to_scan[0] == $addr) { 
     2691                        shift @not_to_scan; 
     2692                        next; 
     2693                } 
     2694 
     2695                if (!i2c_set_slave_addr(\*FILE, $addr)) { 
     2696                        # If the address is busy, we can normally find out 
     2697                        # which driver requested it (if the kernel is recent 
     2698                        # enough, at least 2.6.16 and later are known to work), 
     2699                        # and we assume it is the right one. 
     2700                        my ($device, $driver); 
     2701 
     2702                        $device = sprintf("$sysfs_root/bus/i2c/devices/\%d-\%04x", 
     2703                                          $adapter_nr, $addr); 
     2704                        $driver = sysfs_device_driver($device); 
     2705 
     2706                        if (defined($driver)) { 
     2707                                $new_hash = { 
     2708                                        conf => 6, # Arbitrary confidence 
     2709                                        i2c_addr => $addr, 
     2710                                        chipname => sysfs_device_attribute($device, "name") 
     2711                                                 || "unknown", 
     2712                                        i2c_adap => $adapter_name, 
     2713                                        i2c_driver => $adapter_driver, 
     2714                                        i2c_devnr => $adapter_nr, 
     2715                                }; 
     2716 
     2717                                printf "Client found at address 0x\%02x\n", $addr; 
     2718                                printf "Handled by driver `\%s' (already loaded), chip type `\%s'\n", 
     2719                                       $driver, $new_hash->{chipname}; 
     2720 
     2721                                # Only add it to the list if this is something 
     2722                                # we would have detected, else we end up with 
     2723                                # random i2c chip drivers listed (for example 
     2724                                # media/video drivers.) 
     2725                                if (exists $modules_supported{$driver}) { 
     2726                                        add_i2c_to_chips_detected($driver, $new_hash); 
     2727                                } else { 
     2728                                        print "    (note: this is probably NOT a sensor chip!)\n"; 
     2729                                } 
     2730                        } else { 
     2731                                printf("Client at address 0x%02x can not be probed - ". 
     2732                                       "unload all client drivers first!\n", $addr); 
     2733                        } 
     2734                        next; 
     2735                } 
     2736 
     2737                next unless i2c_probe(\*FILE, $addr, $funcs); 
     2738                printf "Client found at address 0x%02x\n", $addr; 
     2739                if (!i2c_safety_check(\*FILE)) { 
     2740                        print "Seems to be a 1-register-only device, skipping.\n"; 
     2741                        next; 
     2742                } 
     2743 
     2744                $| = 1; 
     2745                foreach $chip (@chip_ids, @non_hwmon_chip_ids) { 
     2746                        if (exists $chip->{i2c_addrs} and contains($addr, @{$chip->{i2c_addrs}})) { 
     2747                                printf("\%-60s", sprintf("Probing for `\%s'... ", $chip->{name})); 
     2748                                if (($conf, @chips) = &{$chip->{i2c_detect}} (\*FILE, $addr)) { 
     2749                                        if ($chip->{driver} eq "not-a-sensor") { 
     2750                                                print "Yes\n", 
     2751                                                      "    (confidence $conf, not a hardware monitoring chip"; 
     2752                                        } else { 
     2753                                                print "Success!\n", 
     2754                                                      "    (confidence $conf, driver `$chip->{driver}'"; 
     2755                                        } 
     2756                                        if (@chips) { 
     2757                                                print ", other addresses:"; 
     2758                                                @chips = sort @chips; 
     2759                                                foreach $other_addr (@chips) { 
     2760                                                        printf(" 0x%02x", $other_addr); 
     2761                                                } 
     2762                                        } 
     2763                                        printf ")\n"; 
     2764 
     2765                                        next if ($chip->{driver} eq "not-a-sensor" 
     2766                                              || $chip->{driver} eq "use-isa-instead"); 
     2767 
     2768                                        $new_hash = { 
     2769                                                conf => $conf, 
     2770                                                i2c_addr => $addr, 
     2771                                                chipname => $chip->{name}, 
     2772                                                i2c_adap => $adapter_name, 
     2773                                                i2c_driver => $adapter_driver, 
     2774                                                i2c_devnr => $adapter_nr, 
     2775                                        }; 
     2776                                        if (@chips) { 
     2777                                                my @chips_copy = @chips; 
     2778                                                $new_hash->{i2c_sub_addrs} = \@chips_copy; 
     2779                                        } 
     2780                                        add_i2c_to_chips_detected($chip->{driver}, $new_hash); 
     2781                                } else { 
     2782                                        print "No\n"; 
     2783                                } 
     2784                        } 
     2785                } 
     2786                $| = 0; 
     2787        } 
    27812788} 
    27822789 
    27832790sub scan_isa_bus 
    27842791{ 
    2785   my ($chip, $addr, $conf); 
    2786   $| = 1; 
    2787   foreach $chip (@chip_ids) { 
    2788     next if not exists $chip->{isa_addrs} or not exists $chip->{isa_detect}; 
    2789     foreach $addr (@{$chip->{isa_addrs}}) { 
    2790       printf("\%-60s", sprintf("Probing for `\%s'\ at 0x\%x... ", $chip->{name}, 
    2791                                $addr)); 
    2792       $conf = &{$chip->{isa_detect}} ($addr); 
    2793       print("No\n"), next if not defined $conf; 
    2794       print "Success!\n"; 
    2795       printf "    (confidence %d, driver `%s')\n", $conf, $chip->{driver}; 
    2796       my $new_hash = { conf => $conf, 
    2797                        isa_addr => $addr, 
    2798                        chipname => $chip->{name} 
    2799                      }; 
    2800       $new_hash = add_isa_to_chips_detected($chip->{alias_detect}, $chip->{driver}, 
    2801                                             $new_hash); 
    2802       if ($new_hash) { 
    2803         printf "    Alias of the chip on I2C bus `%s', address 0x%02x\n", 
    2804                         $new_hash->{i2c_adap}, $new_hash->{i2c_addr}; 
    2805       } 
    2806     } 
    2807   } 
    2808   $| = 0; 
     2792        my ($chip, $addr, $conf); 
     2793 
     2794        $| = 1; 
     2795        foreach $chip (@chip_ids) { 
     2796                next if not exists $chip->{isa_addrs} or not exists $chip->{isa_detect}; 
     2797                foreach $addr (@{$chip->{isa_addrs}}) { 
     2798                        printf("\%-60s", sprintf("Probing for `\%s'\ at 0x\%x... ", 
     2799                                                 $chip->{name}, $addr)); 
     2800                        $conf = &{$chip->{isa_detect}} ($addr); 
     2801                        print("No\n"), next if not defined $conf; 
     2802                        print "Success!\n"; 
     2803                        printf "    (confidence %d, driver `%s')\n", $conf, $chip->{driver}; 
     2804                        my $new_hash = { 
     2805                                conf => $conf, 
     2806                                isa_addr => $addr, 
     2807                                chipname => $chip->{name}, 
     2808                        }; 
     2809                        $new_hash = add_isa_to_chips_detected($chip->{alias_detect}, 
     2810                                                              $chip->{driver}, 
     2811                                                              $new_hash); 
     2812                        if ($new_hash) { 
     2813                                printf "    Alias of the chip on I2C bus `%s', address 0x%02x\n", 
     2814                                       $new_hash->{i2c_adap}, $new_hash->{i2c_addr}; 
     2815                        } 
     2816                } 
     2817        } 
     2818        $| = 0; 
    28092819} 
    28102820