mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-06 15:51:34 +00:00
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. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4312 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
db652c9e92
commit
f1a8ba3d1d
2 files changed
+5
-24
No files matched your search
@@ -9,6 +9,7 @@ SVN HEAD
|
||||
Add VIA CX700 detection
|
||||
Drop legacy W83627HF ISA detection
|
||||
Don't bufferize stdout during probes
|
||||
Speed up the LM75 and LM77 detection
|
||||
|
||||
|
||||
2.10.2 (20070115)
|
||||
|
||||
@@ -3314,7 +3314,6 @@ sub lm75_detect
|
||||
my $i;
|
||||
my ($file,$addr) = @_;
|
||||
my $cur = i2c_smbus_read_word_data($file,0x00);
|
||||
my $cur_varies = 0;
|
||||
my $conf = i2c_smbus_read_byte_data($file,0x01);
|
||||
|
||||
my $hyst = i2c_smbus_read_word_data($file,0x02);
|
||||
@@ -3329,25 +3328,14 @@ sub lm75_detect
|
||||
return if i2c_smbus_read_word_data($file,0x06) != $os;
|
||||
return if i2c_smbus_read_word_data($file,0x07) != $os;
|
||||
|
||||
for ($i = 0x00; $i < 0xff; $i += 8) {
|
||||
for ($i = 8; $i <= 248; $i += 40) {
|
||||
return if i2c_smbus_read_byte_data($file, $i + 0x01) != $conf;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x02) != $hyst;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x04) != $hyst;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x05) != $hyst;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x06) != $hyst;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x07) != $hyst;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x03) != $os;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x04) != $os;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x05) != $os;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x06) != $os;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x07) != $os;
|
||||
$cur_varies = 1
|
||||
if (! $cur_varies) and
|
||||
i2c_smbus_read_word_data($file, $i) != $cur;
|
||||
}
|
||||
|
||||
# All registers hold the same value, obviously a misdetection
|
||||
return if (! $cur_varies) and $conf == ($cur & 0xff) and $cur == $hyst
|
||||
return if $conf == ($cur & 0xff) and $cur == $hyst
|
||||
and $cur == $os;
|
||||
|
||||
$cur = swap_bytes($cur);
|
||||
@@ -3389,7 +3377,6 @@ sub lm77_detect
|
||||
my $i;
|
||||
my ($file,$addr) = @_;
|
||||
my $cur = i2c_smbus_read_word_data($file,0x00);
|
||||
my $cur_varies = 0;
|
||||
my $conf = i2c_smbus_read_byte_data($file,0x01);
|
||||
my $hyst = i2c_smbus_read_word_data($file,0x02);
|
||||
my $os = i2c_smbus_read_word_data($file,0x03);
|
||||
@@ -3402,23 +3389,16 @@ sub lm77_detect
|
||||
return if i2c_smbus_read_word_data($file,0x06) != $high;
|
||||
return if i2c_smbus_read_word_data($file,0x07) != $high;
|
||||
|
||||
for ($i = 0x00; $i < 0xff; $i += 8) {
|
||||
for ($i = 8; $i <= 248; $i += 40) {
|
||||
return if i2c_smbus_read_byte_data($file, $i + 0x01) != $conf;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x02) != $hyst;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x03) != $os;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x04) != $low;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x06) != $low;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x07) != $low;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x05) != $high;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x06) != $high;
|
||||
return if i2c_smbus_read_word_data($file, $i + 0x07) != $high;
|
||||
$cur_varies = 1
|
||||
if (! $cur_varies) and
|
||||
i2c_smbus_read_word_data($file, $i) != $cur;
|
||||
}
|
||||
|
||||
# All registers hold the same value, obviously a misdetection
|
||||
return if (! $cur_varies) and $conf == ($cur & 0xff) and $cur == $hyst
|
||||
return if $conf == ($cur & 0xff) and $cur == $hyst
|
||||
and $cur == $os and $cur == $low and $cur == $high;
|
||||
|
||||
$cur = swap_bytes($cur);
|
||||
|
||||
Reference in new issue
Block a user