Changeset 4312

Show
Ignore:
Timestamp:
01/25/07 10:18:23 (8 years ago)
Author:
khali
Message:

sensors-detect: Speed up the LM75 and LM77 detection. The previous code
was using a brute force approach, quite reliable but very slow. The new
code should be just as reliable but about ten times faster.

Location:
lm-sensors/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lm-sensors/trunk/CHANGES

    r4311 r4312  
    1010                          Drop legacy W83627HF ISA detection 
    1111                          Don't bufferize stdout during probes 
     12                          Speed up the LM75 and LM77 detection 
    1213 
    1314 
  • lm-sensors/trunk/prog/detect/sensors-detect

    r4311 r4312  
    33153315  my ($file,$addr) = @_; 
    33163316  my $cur = i2c_smbus_read_word_data($file,0x00); 
    3317   my $cur_varies = 0; 
    33183317  my $conf = i2c_smbus_read_byte_data($file,0x01); 
    33193318 
     
    33303329  return if i2c_smbus_read_word_data($file,0x07) != $os; 
    33313330 
    3332   for ($i = 0x00; $i < 0xff; $i += 8) { 
     3331  for ($i = 8; $i <= 248; $i += 40) { 
    33333332    return if i2c_smbus_read_byte_data($file, $i + 0x01) != $conf; 
    33343333    return if i2c_smbus_read_word_data($file, $i + 0x02) != $hyst; 
    3335     return if i2c_smbus_read_word_data($file, $i + 0x04) != $hyst; 
    3336     return if i2c_smbus_read_word_data($file, $i + 0x05) != $hyst; 
    3337     return if i2c_smbus_read_word_data($file, $i + 0x06) != $hyst; 
    3338     return if i2c_smbus_read_word_data($file, $i + 0x07) != $hyst; 
    33393334    return if i2c_smbus_read_word_data($file, $i + 0x03) != $os; 
    3340     return if i2c_smbus_read_word_data($file, $i + 0x04) != $os; 
    3341     return if i2c_smbus_read_word_data($file, $i + 0x05) != $os; 
    3342     return if i2c_smbus_read_word_data($file, $i + 0x06) != $os; 
    3343     return if i2c_smbus_read_word_data($file, $i + 0x07) != $os; 
    3344     $cur_varies = 1 
    3345       if (! $cur_varies) and 
    3346         i2c_smbus_read_word_data($file, $i) != $cur; 
    33473335  } 
    33483336 
    33493337  # All registers hold the same value, obviously a misdetection 
    3350   return if (! $cur_varies) and $conf == ($cur & 0xff) and $cur == $hyst 
     3338  return if $conf == ($cur & 0xff) and $cur == $hyst 
    33513339    and $cur == $os; 
    33523340 
     
    33903378  my ($file,$addr) = @_; 
    33913379  my $cur = i2c_smbus_read_word_data($file,0x00); 
    3392   my $cur_varies = 0; 
    33933380  my $conf = i2c_smbus_read_byte_data($file,0x01); 
    33943381  my $hyst = i2c_smbus_read_word_data($file,0x02); 
     
    34033390  return if i2c_smbus_read_word_data($file,0x07) != $high; 
    34043391 
    3405   for ($i = 0x00; $i < 0xff; $i += 8) { 
     3392  for ($i = 8; $i <= 248; $i += 40) { 
    34063393    return if i2c_smbus_read_byte_data($file, $i + 0x01) != $conf; 
    34073394    return if i2c_smbus_read_word_data($file, $i + 0x02) != $hyst; 
    34083395    return if i2c_smbus_read_word_data($file, $i + 0x03) != $os; 
    34093396    return if i2c_smbus_read_word_data($file, $i + 0x04) != $low; 
    3410     return if i2c_smbus_read_word_data($file, $i + 0x06) != $low; 
    3411     return if i2c_smbus_read_word_data($file, $i + 0x07) != $low; 
    34123397    return if i2c_smbus_read_word_data($file, $i + 0x05) != $high; 
    3413     return if i2c_smbus_read_word_data($file, $i + 0x06) != $high; 
    3414     return if i2c_smbus_read_word_data($file, $i + 0x07) != $high; 
    3415     $cur_varies = 1 
    3416       if (! $cur_varies) and 
    3417         i2c_smbus_read_word_data($file, $i) != $cur; 
    34183398  } 
    34193399 
    34203400  # All registers hold the same value, obviously a misdetection 
    3421   return if (! $cur_varies) and $conf == ($cur & 0xff) and $cur == $hyst 
     3401  return if $conf == ($cur & 0xff) and $cur == $hyst 
    34223402    and $cur == $os and $cur == $low and $cur == $high; 
    34233403