Changeset 336

Show
Ignore:
Timestamp:
03/23/99 22:48:41 (10 years ago)
Author:
frodo
Message:

sensors-detect new feature

The detection program can now be told that it should probe for more
addresses than the kernel driver module; it automatically generates
the necessary insmod parameters for the module if chips are found on
these non-standard addresses. Very useful for the LM78, for instance;
the driver still only check 0x20-0x2f, but the probe program checks
all addresses.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lm-sensors/trunk/prog/detect/sensors-detect

    r325 r336  
    9393#  i2c_addrs (optional): For I2C chips, the range of valid I2C addresses to 
    9494#      probe. 
     95#  i2c_driver_addrs (optional): For I2C chips, the range of valid I2C 
     96#      addresses probed by the kernel driver. Strictly optional. 
    9597#  i2c_detect (optional): For I2C chips, the function to call to detect 
    9698#      this chip. The function should take two parameters: an open file 
     
    98100#  isa_addrs (optional): For ISA chips, the range of valid port addresses to 
    99101#      probe. 
     102#  isa_driver_addrs (optional): For ISA chips, the range of valid ISA 
     103#      addresses probed by the kernel driver. Strictly optional. 
    100104#  isa_detect (optional): For ISA chips, the function to call to detect 
    101105#      this chip. The function should take one parameter: the ISA address 
     
    110114       driver => "lm78", 
    111115       i2c_addrs => [0x00..0x7f],  
     116       i2c_driver_addrs => [0x20..0x2f],  
    112117       i2c_detect => sub { lm78_detect 0, @_}, 
    113118       isa_addrs => [0x290], 
     
    119124       driver => "lm78", 
    120125       i2c_addrs => [0x00..0x7f], 
     126       i2c_driver_addrs => [0x20..0x2f],  
    121127       i2c_detect => sub { lm78_detect 1, @_ }, 
    122128       isa_addrs => [0x290], 
     
    128134       driver => "lm78", 
    129135       i2c_addrs => [0x00..0x7f], 
     136       i2c_driver_addrs => [0x20..0x2f],  
    130137       i2c_detect => sub { lm78_detect 2, @_ }, 
    131138       isa_addrs => [0x290], 
     
    712719#  with field 'i2c_sub_addrs', containing a reference to a list of 
    713720#       other I2C addresses (if this is an I2C detection) 
     721#  with field 'i2c_extra' if this is an I2C detection and the address 
     722#       is not normally probed by the kernel driver 
    714723#  with field 'isa_addr' containing the ISA address this chip is on  
    715724#       (if this is an ISA detection) 
     725#  with field 'isa_extra' if this is an ISA detection and the address 
     726#       is not normally probed by the kernel driver 
    716727#  with field 'conf', containing the confidence level of this detection 
    717728#  with field 'chipname', containing the chip name 
     
    842853                          $new_misdetected_ref->[$i]->{i2c_addr})) { 
    843854        $new_misdetected_ref->[$i]->{isa_addr} = $datahash->{isa_addr}; 
     855        $new_misdetected_ref->[$i]->{isa_extra} = $datahash->{isa_extra}  
     856               if exists $datahash->{isa_extra}; 
    844857        close FILE; 
    845858        return; 
     
    866879                          $new_detected_ref->[$i]->{i2c_addr})) { 
    867880        $new_detected_ref->[$i]->{isa_addr} = $datahash->{isa_addr}; 
     881        $new_detected_ref->[$i]->{isa_extra} = $datahash->{isa_extra}  
     882               if exists $datahash->{isa_extra}; 
    868883        ($datahash) = splice (@$new_detected_ref, $i, 1); 
    869884        close FILE; 
     
    956971            $new_hash->{i2c_sub_addrs} = \@chips_copy; 
    957972          } 
     973          $new_hash->{i2c_extra} = 0  
     974                 if exists $chip->{i2c_driver_addrs} and 
     975                    not contains( $addr , @{$chip->{i2c_driver_addrs}}); 
    958976          add_i2c_to_chips_detected $$chip{driver}, $new_hash; 
    959977        } else { 
     
    981999      print "Success!\n"; 
    9821000      printf "    (confidence %d, driver `%s')\n", $conf, $$chip{driver}; 
    983       add_isa_to_chips_detected $$chip{alias_detect},$$chip{driver},  
    984                                 { conf => $conf, 
    985                                   isa_addr => $addr, 
    986                                   chipname =>  $$chip{name}, 
    987                                 }; 
     1001      my $new_hash = { conf => $conf, 
     1002                       isa_addr => $addr, 
     1003                       chipname =>  $$chip{name} 
     1004                     }; 
     1005      $new_hash->{isa_extra} = 0  
     1006             if exists $chip->{isa_driver_addrs} and 
     1007                not contains ($addr, @{$chip->{isa_driver_addrs}}); 
     1008      add_isa_to_chips_detected $$chip{alias_detect},$$chip{driver},$new_hash; 
    9881009    } 
    9891010  } 
     
    14021423  my ($prefer_isa) = @_; 
    14031424 
    1404   my ($chip,$detection,%adapters,$nr,$i,@optionlist); 
     1425  my ($chip,$detection,%adapters,$nr,$i,@optionlist,@probelist); 
    14051426  my $modprobes = ""; 
    14061427  my $configfile = ""; 
     
    14381459  foreach $chip (@chips_detected) { 
    14391460    next if not @{$chip->{detected}}; 
    1440  
    1441     # Handle misdetects 
    14421461    $modprobes .= "modprobe $chip->{driver}\n"; 
    14431462    @optionlist = (); 
     1463    @probelist = (); 
     1464 
     1465    # Handle detects out-of-range 
     1466    foreach $detection (@{$chip->{detected}}) { 
     1467      push @probelist, %adapters->{$detection->{i2c_driver}}, 
     1468                       $detection->{i2c_addr} 
     1469           if exists $detection->{i2c_driver} and 
     1470              exists %adapters->{$detection->{i2c_driver}} and 
     1471              exists $detection->{i2c_extra}; 
     1472      push @probelist, -1, $detection->{isa_addr} 
     1473           if exists $detection->{isa_addr} and 
     1474              exists %adapters->{"i2c-isa"} and 
     1475              exists $detection->{isa_extra}; 
     1476    } 
     1477 
     1478    # Handle misdetects 
    14441479    foreach $detection (@{$chip->{misdetected}}) { 
    14451480      push @optionlist, %adapters->{$detection->{i2c_driver}}, 
     
    14671502    } 
    14681503 
    1469     next if not @optionlist
     1504    next if not (@probelist or @optionlist)
    14701505    $configfile .= "options $chip->{driver}"; 
    1471     $configfile .= sprintf " ignore=0x%02x",shift @optionlist  
    1472                 if @optionlist; 
    1473     $configfile .= sprintf ",0x%02x",shift @optionlist  
    1474                 while @optionlist; 
     1506    $configfile .= sprintf " ignore=%d,0x%02x",shift @optionlist,  
     1507                                               shift @optionlist 
     1508                  if @optionlist; 
     1509    $configfile .= sprintf ",%d,0x%02x",shift @optionlist, shift @optionlist 
     1510                  while @optionlist; 
     1511    $configfile .= sprintf " probe=%d,0x%02x",shift @probelist, 
     1512                                              shift @probelist 
     1513                  if @probelist; 
     1514    $configfile .= sprintf ",%d,0x%02x",shift @probelist, shift @probelist 
     1515                  while @probelist; 
    14751516    $configfile .= "\n"; 
    14761517  }