diff --git a/CHANGES b/CHANGES index f9a685f6..dffc5dca 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ SVN-HEAD Add Maxim MAX6654/MAX6690 support Add National Semiconductor LM95231 support Add Analog Devices ADT7481 support + Refactor alias detection functions 3.0.2 (2008-05-18) documentation: Delete the FAQ, now maintained on the wiki diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index 2a1a3560..540c48bf 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -625,7 +625,7 @@ use vars qw(@pci_adapters_sis5595 @pci_adapters_sis645 @pci_adapters_sis96x); i2c_detect => sub { lm78_detect(0, @_); }, isa_addrs => [0x290], isa_detect => sub { lm78_isa_detect(0, @_); }, - alias_detect => sub { lm78_alias_detect(0, @_); }, + alias_detect => sub { winbond_alias_detect(0x2b, 0x3d, @_); }, }, { name => "National Semiconductor LM78-J", @@ -634,7 +634,7 @@ use vars qw(@pci_adapters_sis5595 @pci_adapters_sis645 @pci_adapters_sis96x); i2c_detect => sub { lm78_detect(1, @_); }, isa_addrs => [0x290], isa_detect => sub { lm78_isa_detect(1, @_); }, - alias_detect => sub { lm78_alias_detect(1, @_); }, + alias_detect => sub { winbond_alias_detect(0x2b, 0x3d, @_); }, }, { name => "National Semiconductor LM79", @@ -643,7 +643,7 @@ use vars qw(@pci_adapters_sis5595 @pci_adapters_sis645 @pci_adapters_sis96x); i2c_detect => sub { lm78_detect(2, @_); }, isa_addrs => [0x290], isa_detect => sub { lm78_isa_detect(2, @_); }, - alias_detect => sub { lm78_alias_detect(2, @_); }, + alias_detect => sub { winbond_alias_detect(0x2b, 0x3d, @_); }, }, { name => "National Semiconductor LM75", @@ -798,7 +798,7 @@ use vars qw(@pci_adapters_sis5595 @pci_adapters_sis645 @pci_adapters_sis96x); i2c_addrs => [0x28..0x2f], isa_addrs => [0x290], isa_detect => sub { w83781d_isa_detect(0, @_); }, - alias_detect => sub { w83781d_alias_detect(0, @_); }, + alias_detect => sub { winbond_alias_detect(0x2b, 0x3d, @_); }, }, { name => "Winbond W83782D", @@ -807,7 +807,7 @@ use vars qw(@pci_adapters_sis5595 @pci_adapters_sis645 @pci_adapters_sis96x); i2c_detect => sub { w83781d_detect(1, @_); }, isa_addrs => [0x290], isa_detect => sub { w83781d_isa_detect(1, @_); }, - alias_detect => sub { w83781d_alias_detect(1, @_); }, + alias_detect => sub { winbond_alias_detect(0x2b, 0x3d, @_); }, }, { name => "Winbond W83783S", @@ -1887,14 +1887,14 @@ use vars qw(@chip_kern24_ids @chip_kern26_ids driver => "vt1211", devid => 0x3c, logdev => 0x0b, - alias_detect => sub { vt1211_alias_detect(0, @_); }, + alias_detect => sub { vt1211_alias_detect(@_); }, }, { name => "Winbond W83627HF/F/HG/G Super IO Sensors", driver => "w83627hf", devid => 0x52, logdev => 0x0b, - alias_detect => sub { w83781d_alias_detect(3, @_); }, + alias_detect => sub { winbond_alias_detect(0x2b, 0x3d, @_); }, }, { name => "Winbond W83627THF/THG Super IO Sensors", @@ -1934,7 +1934,7 @@ use vars qw(@chip_kern24_ids @chip_kern26_ids devid => 0x8840, devid_mask => 0xFFC0, logdev => 0x0b, - alias_detect => sub { w83781d_alias_detect(9, @_); }, + alias_detect => sub { winbond_alias_detect(0x2b, 0x3e, @_); }, }, { name => "Winbond W83627DHG Super IO Sensors", @@ -1942,7 +1942,7 @@ use vars qw(@chip_kern24_ids @chip_kern26_ids devid => 0xA020, devid_mask => 0xFFF0, logdev => 0x0b, - alias_detect => sub { w83781d_alias_detect(10, @_); }, + alias_detect => sub { winbond_alias_detect(0x2b, 0x3e, @_); }, }, { name => "Winbond W83L517D Super IO", @@ -2030,7 +2030,7 @@ use vars qw(@chip_kern24_ids @chip_kern26_ids driver => "it87", devid => 0x8712, logdev => 0x04, - alias_detect => sub { ite_alias_detect(0, @_); }, + alias_detect => sub { winbond_alias_detect(0x30, 0x45, @_); }, }, { name => "ITE IT8716F Super IO Sensors", @@ -3601,23 +3601,6 @@ sub lm78_isa_detect return 6; } - -# $_[0]: Chip to detect (0 = LM78, 1 = LM78-J, 2 = LM79) -# $_[1]: ISA address -# $_[2]: I2C file handle -# $_[3]: I2C address -sub lm78_alias_detect -{ - my ($chip, $isa_addr, $file, $i2c_addr) = @_; - my $i; - - return 0 unless isa_read_i5d6($isa_addr, 0x48) == $i2c_addr; - for ($i = 0x2b; $i <= 0x3d; $i ++) { - return 0 unless isa_read_i5d6($isa_addr, $i) == i2c_smbus_read_byte_data($file, $i); - } - return 1; -} - # $_[0]: Chip to detect (0 = LM75, 1 = DS75) # $_[1]: A reference to the file descriptor to access this chip. # $_[2]: Address (unused) @@ -4668,19 +4651,18 @@ sub mozart_detect return 5; } -# $_[0]: Chip to detect (0 = W83781D, 1 = W83782D, 3 = W83627HF, -# 9 = W83627EHF 10, = W83627DHG) -# $_[1]: ISA address -# $_[2]: I2C file handle -# $_[3]: I2C address -sub w83781d_alias_detect +# $_[0]: First limit register to compare +# $_[1]: Last limit register to compare +# $_[2]: ISA address +# $_[3]: I2C file handle +# $_[4]: I2C address +sub winbond_alias_detect { - my ($chip, $isa_addr, $file, $i2c_addr) = @_; + my ($first, $last, $isa_addr, $file, $i2c_addr) = @_; my $i; - my $max = ($chip == 9 || $chip == 10) ? 0x3e : 0x3d; return 0 unless isa_read_i5d6($isa_addr, 0x48) == $i2c_addr; - for ($i = 0x2b; $i <= $max; $i ++) { + for ($i = $first; $i <= $last; $i++) { return 0 unless isa_read_i5d6($isa_addr, $i) == i2c_smbus_read_byte_data($file, $i); } return 1; @@ -5056,23 +5038,6 @@ sub ite_detect return (7 + ($addr == 0x2d)); } - -# $_[0]: Chip to detect (0 = IT8712F) -# $_[1]: ISA address -# $_[2]: I2C file handle -# $_[3]: I2C address -sub ite_alias_detect -{ - my ($chip, $isa_addr, $file, $i2c_addr) = @_; - my $i; - - return 0 unless isa_read_i5d6($isa_addr, 0x48) == $i2c_addr; - for ($i = 0x30; $i <= 0x45; $i++) { - return 0 unless isa_read_i5d6($isa_addr, $i) == i2c_smbus_read_byte_data($file, $i); - } - return 1; -} - # $_[0]: A reference to the file descriptor to access this chip # $_[1]: Address # Returns: 8 for a memory eeprom @@ -5537,16 +5502,15 @@ sub vt1211_i2c_detect return 2; } -# $_[0]: Chip to detect (0 = VT1211) -# $_[1]: ISA address -# $_[2]: I2C file handle -# $_[3]: I2C address +# $_[0]: ISA address +# $_[1]: I2C file handle +# $_[2]: I2C address sub vt1211_alias_detect { - my ($chip, $isa_addr, $file, $i2c_addr) = @_; + my ($isa_addr, $file, $i2c_addr) = @_; my $i; return 0 unless (inb($isa_addr + 0x48) & 0x7f) == $i2c_addr; - for ($i = 0x2b; $i <= 0x3d; $i ++) { + for ($i = 0x2b; $i <= 0x3d; $i++) { return 0 unless inb($isa_addr + $i) == i2c_smbus_read_byte_data($file, $i); } return 1;