From bae506f2df740c81d4260096fbc99414bf9cc6f9 Mon Sep 17 00:00:00 2001 From: Frodo Looijaard Date: Mon, 1 Mar 1999 13:49:06 +0000 Subject: [PATCH] Modified LM75 detection again. It should now be better. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@286 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/detect/detect.pl | 16 ++++++++++------ prog/detect/sensors-detect | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/prog/detect/detect.pl b/prog/detect/detect.pl index 2dd67ff5..735bd0d1 100755 --- a/prog/detect/detect.pl +++ b/prog/detect/detect.pl @@ -946,8 +946,10 @@ sub scan_adapter i2c_driver => $adapter_driver, i2c_devnr => $adapter_nr, }; - my @chips_copy = @chips, $new_hash->{i2c_sub_addrs} = \@chips_copy - if (@chips); + if (@chips) { + my @chips_copy = @chips; + $new_hash->{i2c_sub_addrs} = \@chips_copy; + } add_i2c_to_chips_detected $$chip{driver}, $new_hash; } else { print "Failed!\n"; @@ -1078,13 +1080,15 @@ sub lm75_detect { my $i; my ($file,$addr) = @_; + my $cur = i2c_smbus_read_word_data($file,0x00); 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); - for ($i = 0x00; $i <= 0xF; $i += 1) { - return if i2c_smbus_read_byte_data($file,($i * 0x10) + 0x01) != $conf; - return if i2c_smbus_read_word_data($file,($i * 0x10) + 0x02) != $hyst; - return if i2c_smbus_read_word_data($file,($i * 0x10) + 0x03) != $os; + return if $hyst & 0x7f00 or $os & 0x7f00 or $cur & 0x7f00; + for ($i = 0x00; $i <= 0x1f; $i += 1) { + return if i2c_smbus_read_byte_data($file,($i * 0x08) + 0x01) != $conf; + return if i2c_smbus_read_word_data($file,($i * 0x08) + 0x02) != $hyst; + return if i2c_smbus_read_word_data($file,($i * 0x08) + 0x03) != $os; } return (3); } diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index 2dd67ff5..735bd0d1 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -946,8 +946,10 @@ sub scan_adapter i2c_driver => $adapter_driver, i2c_devnr => $adapter_nr, }; - my @chips_copy = @chips, $new_hash->{i2c_sub_addrs} = \@chips_copy - if (@chips); + if (@chips) { + my @chips_copy = @chips; + $new_hash->{i2c_sub_addrs} = \@chips_copy; + } add_i2c_to_chips_detected $$chip{driver}, $new_hash; } else { print "Failed!\n"; @@ -1078,13 +1080,15 @@ sub lm75_detect { my $i; my ($file,$addr) = @_; + my $cur = i2c_smbus_read_word_data($file,0x00); 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); - for ($i = 0x00; $i <= 0xF; $i += 1) { - return if i2c_smbus_read_byte_data($file,($i * 0x10) + 0x01) != $conf; - return if i2c_smbus_read_word_data($file,($i * 0x10) + 0x02) != $hyst; - return if i2c_smbus_read_word_data($file,($i * 0x10) + 0x03) != $os; + return if $hyst & 0x7f00 or $os & 0x7f00 or $cur & 0x7f00; + for ($i = 0x00; $i <= 0x1f; $i += 1) { + return if i2c_smbus_read_byte_data($file,($i * 0x08) + 0x01) != $conf; + return if i2c_smbus_read_word_data($file,($i * 0x08) + 0x02) != $hyst; + return if i2c_smbus_read_word_data($file,($i * 0x08) + 0x03) != $os; } return (3); }