Changeset 5266
- Timestamp:
- 05/28/08 09:26:11 (5 years ago)
- Location:
- lm-sensors/branches/lm-sensors-3.0.0
- Files:
-
- 2 modified
-
CHANGES (modified) (1 diff)
-
prog/detect/sensors-detect (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/branches/lm-sensors-3.0.0/CHANGES
r5264 r5266 6 6 Add SMSC EMC6D103 support 7 7 Improve MAX6657, MAX6658, MAX6659 detection 8 Cache the byte data reads (#2326) 8 9 9 10 3.0.2 (2008-05-18) -
lm-sensors/branches/lm-sensors-3.0.0/prog/detect/sensors-detect
r5264 r5266 46 46 ######################### 47 47 48 use constant NO_CACHE => 1; 48 49 use vars qw(@pci_adapters @chip_ids $i2c_addresses_to_scan @superio_ids 49 @cpu_ids $revision );50 @cpu_ids $revision @i2c_byte_cache); 50 51 51 52 $revision = '$Revision$ ($Date$)'; … … 2690 2691 { 2691 2692 my ($file, $addr) = @_; 2693 2694 # Reset register data cache 2695 @i2c_byte_cache = (); 2696 2692 2697 $addr += 0; # Make sure it's a number not a string 2693 2698 ioctl $file, IOCTL_I2C_SLAVE, $addr or return 0; … … 2744 2749 # $_[1]: Command byte (usually register number) 2745 2750 # Returns: -1 on failure, the read byte on success. 2751 # Read byte data values are cached by default. As we keep reading the 2752 # same registers over and over again in the detection functions, and 2753 # SMBus can be slow, caching results in a big performance boost. 2746 2754 sub i2c_smbus_read_byte_data 2747 2755 { 2748 my ($file, $command ) = @_;2756 my ($file, $command, $nocache) = @_; 2749 2757 my @data; 2758 if (!$nocache && exists $i2c_byte_cache[$command]) { 2759 return $i2c_byte_cache[$command]; 2760 } 2750 2761 i2c_smbus_access $file, SMBUS_READ, $command, SMBUS_BYTE_DATA, \@data 2751 2762 or return -1; 2752 return $data[0];2763 return ($i2c_byte_cache[$command] = $data[0]); 2753 2764 } 2754 2765 … … 3633 3644 my $conf = i2c_smbus_read_byte_data($file, 0x01); 3634 3645 3635 my $hyst = i2c_smbus_read_byte_data($file, 0x02 );3646 my $hyst = i2c_smbus_read_byte_data($file, 0x02, NO_CACHE); 3636 3647 my $maxreg = $chip == 1 ? 0x0f : 0x07; 3637 3648 for $i (0x04 .. $maxreg) { 3638 return if i2c_smbus_read_byte_data($file, $i ) != $hyst;3639 } 3640 3641 my $os = i2c_smbus_read_byte_data($file, 0x03 );3649 return if i2c_smbus_read_byte_data($file, $i, NO_CACHE) != $hyst; 3650 } 3651 3652 my $os = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE); 3642 3653 for $i (0x04 .. $maxreg) { 3643 return if i2c_smbus_read_byte_data($file, $i ) != $os;3654 return if i2c_smbus_read_byte_data($file, $i, NO_CACHE) != $os; 3644 3655 } 3645 3656 … … 3697 3708 my $os = i2c_smbus_read_byte_data($file, 0x03); 3698 3709 3699 my $low = i2c_smbus_read_byte_data($file, 0x04 );3700 return if i2c_smbus_read_byte_data($file, 0x06 ) != $low;3701 return if i2c_smbus_read_byte_data($file, 0x07 ) != $low;3702 3703 my $high = i2c_smbus_read_byte_data($file, 0x05 );3704 return if i2c_smbus_read_byte_data($file, 0x06 ) != $high;3705 return if i2c_smbus_read_byte_data($file, 0x07 ) != $high;3710 my $low = i2c_smbus_read_byte_data($file, 0x04, NO_CACHE); 3711 return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) != $low; 3712 return if i2c_smbus_read_byte_data($file, 0x07, NO_CACHE) != $low; 3713 3714 my $high = i2c_smbus_read_byte_data($file, 0x05, NO_CACHE); 3715 return if i2c_smbus_read_byte_data($file, 0x06, NO_CACHE) != $high; 3716 return if i2c_smbus_read_byte_data($file, 0x07, NO_CACHE) != $high; 3706 3717 3707 3718 for ($i = 8; $i <= 248; $i += 40) { … … 4054 4065 { 4055 4066 my ($file, $addr) = @_; 4056 my $mid = i2c_smbus_read_byte_data($file, 0xfe );4057 my $cid = i2c_smbus_read_byte_data($file, 0xff );4058 my $conf = i2c_smbus_read_byte_data($file, 0x03 );4067 my $mid = i2c_smbus_read_byte_data($file, 0xfe, NO_CACHE); 4068 my $cid = i2c_smbus_read_byte_data($file, 0xff, NO_CACHE); 4069 my $conf = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE); 4059 4070 4060 4071 return if $mid != 0x4d; # Maxim … … 4063 4074 return if $cid != 0x4d; # No register, returns previous value 4064 4075 4065 my $rate = i2c_smbus_read_byte_data($file, 0x04 );4076 my $rate = i2c_smbus_read_byte_data($file, 0x04, NO_CACHE); 4066 4077 return if $rate > 0x09; 4067 4078 4068 $cid = i2c_smbus_read_byte_data($file, 0xff );4069 $conf = i2c_smbus_read_byte_data($file, 0x03 );4079 $cid = i2c_smbus_read_byte_data($file, 0xff, NO_CACHE); 4080 $conf = i2c_smbus_read_byte_data($file, 0x03, NO_CACHE); 4070 4081 return if ($conf & 0x0f) != $rate; # No low nibble, 4071 4082 # returns previous low nibble
