Changeset 5417

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

Drop $chip parameter from all detection functions which handle only
one chip. Let's not make the code more complex than needed.

Files:
1 modified

Legend:

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

    r5416 r5417  
    660660       driver => "to-be-written", 
    661661       i2c_addrs => [0x4c], 
    662        i2c_detect => sub { andigilog_aSC7511_detect(0, @_); }, 
     662       i2c_detect => sub { andigilog_aSC7511_detect(@_); }, 
    663663     }, 
    664664     { 
     
    738738       driver => "w83793", 
    739739       i2c_addrs => [0x2c..0x2f], 
    740        i2c_detect => sub { w83793_detect(0, @_); }, 
     740       i2c_detect => sub { w83793_detect(@_); }, 
    741741     }, 
    742742     { 
     
    822822       driver => "w83l785ts", 
    823823       i2c_addrs => [0x2e], 
    824        i2c_detect => sub { w83l785ts_detect(0, @_); }, 
     824       i2c_detect => sub { w83l785ts_detect(@_); }, 
    825825     }, 
    826826     { 
     
    876876       driver => "adm1026", 
    877877       i2c_addrs => [0x2c, 0x2d, 0x2e], 
    878        i2c_detect => sub { adm1026_detect(0, @_); }, 
     878       i2c_detect => sub { adm1026_detect(@_); }, 
    879879     }, 
    880880     { 
     
    936936       driver => "max6650", 
    937937       i2c_addrs => [0x1b, 0x1f, 0x48, 0x4b], 
    938        i2c_detect => sub { max6650_detect(0, @_); }, 
     938       i2c_detect => sub { max6650_detect(@_); }, 
    939939     }, 
    940940     { 
     
    942942       driver => "max6655", 
    943943       i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e], 
    944        i2c_detect => sub { max6655_detect(0, @_); }, 
     944       i2c_detect => sub { max6655_detect(@_); }, 
    945945     }, 
    946946     { 
     
    984984       driver => "lm83", 
    985985       i2c_addrs => [0x18..0x1a, 0x29..0x2b, 0x4c..0x4e], 
    986        i2c_detect => sub { lm83_detect(0, @_); }, 
     986       i2c_detect => sub { lm83_detect(@_); }, 
    987987     }, 
    988988     { 
     
    11301130       driver => "adm1029", 
    11311131       i2c_addrs => [0x28..0x2f], 
    1132        i2c_detect => sub { adm1029_detect(0, @_); }, 
     1132       i2c_detect => sub { adm1029_detect(@_); }, 
    11331133     }, 
    11341134     { 
     
    11841184       driver => "use-isa-instead", 
    11851185       i2c_addrs => [0x2d], 
    1186        i2c_detect => sub { vt1211_i2c_detect(0, @_); }, 
     1186       i2c_detect => sub { vt1211_i2c_detect(@_); }, 
    11871187     }, 
    11881188     { 
     
    11901190       driver => "it87", 
    11911191       i2c_addrs => [0x28..0x2f], 
    1192        i2c_detect => sub { ite_detect(0, @_); }, 
     1192       i2c_detect => sub { it8712_detect(@_); }, 
    11931193     }, 
    11941194     { 
     
    37593759} 
    37603760 
    3761 # $_[0]: Chip to detect 
    3762 #   (0 = LM82/LM83) 
    3763 # $_[1]: A reference to the file descriptor to access this chip. 
    3764 # $_[2]: Address 
     3761# $_[0]: A reference to the file descriptor to access this chip. 
     3762# $_[1]: Address 
    37653763# Returns: undef if not detected, 4 to 8 if detected. 
    37663764# Registers used: 
     
    37813779sub lm83_detect 
    37823780{ 
    3783   my ($chip, $file) = @_; 
     3781  my ($file, $addr) = @_; 
    37843782  return if i2c_smbus_read_byte_data($file, 0xfe) != 0x01; 
    37853783  my $chipid = i2c_smbus_read_byte_data($file, 0xff); 
     
    40164014} 
    40174015 
    4018 # $_[0]: Chip to detect 
    4019 #   (0 = ADM1029) 
    4020 # $_[1]: A reference to the file descriptor to access this chip. 
    4021 # $_[2]: Address (unused) 
     4016# $_[0]: A reference to the file descriptor to access this chip. 
     4017# $_[1]: Address (unused) 
    40224018# Returns: undef if not detected, 6 if detected. 
    40234019# Registers used: 
     
    40294025sub adm1029_detect 
    40304026{ 
    4031   my ($chip, $file, $addr) = @_; 
     4027  my ($file, $addr) = @_; 
    40324028  my $mid = i2c_smbus_read_byte_data($file, 0x0d); 
    40334029  my $cid = i2c_smbus_read_byte_data($file, 0x0e); 
    40344030  my $cfg; 
    40354031 
    4036   if ($chip == 0) { 
    4037     return unless $mid == 0x41;             # Analog Devices 
    4038     return unless ($cid & 0xF0) == 0x00;    # ADM1029 
    4039  
    4040     # Extra check on unused bits 
    4041     $cfg = i2c_smbus_read_byte_data($file, 0x02); 
    4042     return unless $cfg == 0x03; 
    4043     $cfg = i2c_smbus_read_byte_data($file, 0x06); 
    4044     return unless ($cfg & 0xF9) == 0x01; 
    4045     foreach my $reg (0x03, 0x07, 0x08, 0x09) { 
    4046       $cfg = i2c_smbus_read_byte_data($file, $reg); 
    4047       return unless ($cfg & 0xFC) == 0x00; 
    4048     } 
    4049  
    4050     return 7; 
    4051   } 
    4052   return; 
     4032  return unless $mid == 0x41;             # Analog Devices 
     4033  return unless ($cid & 0xF0) == 0x00;    # ADM1029 
     4034 
     4035  # Extra check on unused bits 
     4036  $cfg = i2c_smbus_read_byte_data($file, 0x02); 
     4037  return unless $cfg == 0x03; 
     4038  $cfg = i2c_smbus_read_byte_data($file, 0x06); 
     4039  return unless ($cfg & 0xF9) == 0x01; 
     4040  foreach my $reg (0x03, 0x07, 0x08, 0x09) { 
     4041    $cfg = i2c_smbus_read_byte_data($file, $reg); 
     4042    return unless ($cfg & 0xFC) == 0x00; 
     4043  } 
     4044 
     4045  return 7; 
    40534046} 
    40544047 
     
    42544247} 
    42554248 
    4256 # $_[0]: Chip to detect 
    4257 #   (0 = aSC7511) 
    4258 # $_[1]: A reference to the file descriptor to access this chip. 
    4259 # $_[2]: Address (unused) 
     4249# $_[0]: A reference to the file descriptor to access this chip. 
     4250# $_[1]: Address (unused) 
    42604251# Returns: undef if not detected, 1 if detected. 
    42614252# Registers used: 
     
    42644255sub andigilog_aSC7511_detect 
    42654256{ 
    4266   my ($chip, $file, $addr) = @_; 
     4257  my ($file, $addr) = @_; 
    42674258  my $mid = i2c_smbus_read_byte_data($file, 0xfe); 
    42684259  my $die = i2c_smbus_read_byte_data($file, 0xff); 
    42694260 
    4270   if ($chip == 0) { 
    4271     return if $mid != 0x61;     # Andigilog 
    4272     if ($die == 0x0) { 
    4273         return 3; 
    4274     } else { 
    4275         return 1; 
    4276     } 
    4277   } 
    4278   return; 
     4261  return if $mid != 0x61;     # Andigilog 
     4262  if ($die == 0x0) { 
     4263      return 3; 
     4264  } else { 
     4265      return 1; 
     4266  } 
    42794267} 
    42804268 
     
    44254413} 
    44264414 
    4427 # $_[0]: Chip to detect (0 = W83793) 
    4428 # $_[1]: A reference to the file descriptor to access this chip. 
    4429 # $_[2]: Address 
     4415# $_[0]: A reference to the file descriptor to access this chip. 
     4416# $_[1]: Address 
    44304417# Returns: undef if not detected 
    44314418#          6 if detected and bank different from 0 
     
    44414428{ 
    44424429  my ($bank, $reg, @res); 
    4443   my ($chip, $file, $addr) = @_; 
     4430  my ($file, $addr) = @_; 
    44444431 
    44454432  $bank = i2c_smbus_read_byte_data($file, 0x00); 
     
    44504437 
    44514438  $reg = i2c_smbus_read_byte_data($file, 0x0e); 
    4452   return if $chip == 0 and $reg != 0x7b; 
     4439  return if $reg != 0x7b; 
    44534440 
    44544441# If bank 0 is selected, we can do more checks 
     
    46844671} 
    46854672 
    4686 # $_[0]: Chip to detect (0 = ADM1026) 
    4687 # $_[1]: A reference to the file descriptor to access this chip. 
    4688 # $_[2]: Address 
     4673# $_[0]: A reference to the file descriptor to access this chip. 
     4674# $_[1]: Address 
    46894675# Returns: undef if not detected, (8) if detected. 
    46904676# Registers used: 
     
    46944680{ 
    46954681  my $reg; 
    4696   my ($chip, $file, $addr) = @_; 
     4682  my ($file, $addr) = @_; 
    46974683  $reg = i2c_smbus_read_byte_data($file, 0x16); 
    46984684  return unless ($reg == 0x41); 
     
    48634849} 
    48644850 
    4865 # $_[0]: Chip to detect (0 = IT8712F) 
    4866 # $_[1]: A reference to the file descriptor to access this chip. 
    4867 # $_[2]: Address 
     4851# $_[0]: A reference to the file descriptor to access this chip. 
     4852# $_[1]: Address 
    48684853# Returns: undef if not detected, 7 or 8 if detected (tops LM78). 
    48694854# Registers used: 
     
    48714856#   0x48: Full I2C Address 
    48724857#   0x58: Mfr ID 
    4873 #   0x5b: Device ID (not on IT8705) 
    4874 sub ite_detect 
     4858#   0x5b: Device ID 
     4859sub it8712_detect 
    48754860{ 
    48764861  my $reg; 
    4877   my ($chip, $file, $addr) = @_; 
     4862  my ($file, $addr) = @_; 
    48784863  return unless i2c_smbus_read_byte_data($file, 0x48) == $addr; 
    48794864  return unless (i2c_smbus_read_byte_data($file, 0x00) & 0x90) == 0x10; 
    48804865  return unless i2c_smbus_read_byte_data($file, 0x58) == 0x90; 
    4881   return if $chip == 0 and i2c_smbus_read_byte_data($file, 0x5b) != 0x12; 
     4866  return if i2c_smbus_read_byte_data($file, 0x5b) != 0x12; 
    48824867  return (7 + ($addr == 0x2d)); 
    48834868} 
     
    51605145} 
    51615146 
    5162 # $_[0]: Chip to detect (0 = W83L785TS-S) 
    5163 # $_[1]: A reference to the file descriptor to access this chip. 
    5164 # $_[2]: Address 
     5147# $_[0]: A reference to the file descriptor to access this chip. 
     5148# $_[1]: Address 
    51655149# Returns: undef if not detected, 8 if detected 
    51665150# Registers used: 
     
    51685152sub w83l785ts_detect 
    51695153{ 
    5170   my ($chip, $file, $addr) = @_; 
     5154  my ($file, $addr) = @_; 
    51715155  return unless i2c_smbus_read_byte_data($file, 0x4c) == 0xa3; 
    51725156  return unless i2c_smbus_read_byte_data($file, 0x4d) == 0x5c; 
     
    51755159} 
    51765160 
    5177 # $_[0]: Chip to detect. Always zero for now, but available for future use 
    5178 #        if somebody finds a way to distinguish MAX6650 and MAX6651. 
    5179 # $_[1]: A reference to the file descriptor to access this chip. 
    5180 # $_[2]: Address 
     5161# $_[0]: A reference to the file descriptor to access this chip. 
     5162# $_[1]: Address 
    51815163# Returns: undef if not detected, 3 if detected. 
    51825164# 
     
    51965178sub max6650_detect 
    51975179{ 
    5198   my ($chip, $file) = @_; 
     5180  my ($file, $addr) = @_; 
    51995181 
    52005182  my $conf = i2c_smbus_read_byte_data($file, 0x02); 
     
    52095191} 
    52105192 
    5211 # $_[0]: Chip to detect. Always zero. 
    5212 # $_[1]: A reference to the file descriptor to access this chip. 
    5213 # $_[2]: Address. 
     5193# $_[0]: A reference to the file descriptor to access this chip. 
     5194# $_[1]: Address. 
    52145195# 
    52155196# Returns: undef if not detected, 6 if detected. 
    52165197sub max6655_detect 
    52175198{ 
    5218   my ($chip, $file, $addr) = @_; 
     5199  my ($file, $addr) = @_; 
    52195200 
    52205201  # checking RDID (Device ID) 
     
    52315212} 
    52325213 
    5233 # $_[0]: Chip to detect (0 = VT1211) 
    5234 # $_[1]: A reference to the file descriptor to access this chip. 
    5235 # $_[2]: Address 
     5214# $_[0]: A reference to the file descriptor to access this chip. 
     5215# $_[1]: Address 
    52365216# 
    52375217# This isn't very good detection. 
     
    52415221sub vt1211_i2c_detect 
    52425222{ 
    5243   my ($chip, $file, $addr) = @_; 
     5223  my ($file, $addr) = @_; 
    52445224  return unless (i2c_smbus_read_byte_data($file, 0x48) & 0x7f) == $addr; 
    52455225  return unless i2c_smbus_read_byte_data($file, 0x3f) == 0xb0;