mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-31 06:15:15 +00:00
Support and use the new I2C block read with variable length which will
be available in Linux kernel 2.6.23. Binary compatibility is guaranteed, source code compatibility isn't, but the incompatibility will be spotted quickly as the prototype of the helper function i2c_smbus_read_i2c_block_data() changed. The only problem would be if a program is calling i2c_smbus_access() directly. Hopefully this should be a rare case. The py-smbus binding code is in this case and will be adjusted soon. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@4419 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
2
CHANGES
2
CHANGES
@@ -2,6 +2,7 @@ lm_sensors CHANGES file
|
||||
-----------------------
|
||||
|
||||
SVN HEAD
|
||||
File i2c-dev.h: Support I2C block reads with specified length
|
||||
All bus modules and documentation: Delete
|
||||
All chip modules and documentation: Delete
|
||||
Legacy hotplug modules and documentation: Delete
|
||||
@@ -13,6 +14,7 @@ SVN HEAD
|
||||
Add dme1737 support
|
||||
Delete support of non-sensor drivers (ddcmon, eeprom)
|
||||
Man page sensors.conf.5: Update the chip statement section
|
||||
Program i2cdump: Use the new I2C block read function
|
||||
Program isadump: Detect when address bit 7 is a busy flag
|
||||
Fix Super-I/O exit sequence for Winbond/Fintek chips
|
||||
Program mkpatch: Delete
|
||||
|
@@ -106,8 +106,9 @@ union i2c_smbus_data {
|
||||
#define I2C_SMBUS_WORD_DATA 3
|
||||
#define I2C_SMBUS_PROC_CALL 4
|
||||
#define I2C_SMBUS_BLOCK_DATA 5
|
||||
#define I2C_SMBUS_I2C_BLOCK_DATA 6
|
||||
#define I2C_SMBUS_I2C_BLOCK_BROKEN 6
|
||||
#define I2C_SMBUS_BLOCK_PROC_CALL 7 /* SMBus 2.0 */
|
||||
#define I2C_SMBUS_I2C_BLOCK_DATA 8
|
||||
|
||||
|
||||
/* ----- commands for the ioctl like i2c_command call:
|
||||
@@ -271,12 +272,20 @@ static inline __s32 i2c_smbus_write_block_data(int file, __u8 command,
|
||||
}
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you
|
||||
ask for less than 32 bytes, your code will only work with kernels
|
||||
2.6.23 and later. */
|
||||
static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command,
|
||||
__u8 *values)
|
||||
__u8 length, __u8 *values)
|
||||
{
|
||||
union i2c_smbus_data data;
|
||||
int i;
|
||||
|
||||
if (length > 32)
|
||||
length = 32;
|
||||
data.block[0] = length;
|
||||
if (i2c_smbus_access(file,I2C_SMBUS_READ,command,
|
||||
length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN :
|
||||
I2C_SMBUS_I2C_BLOCK_DATA,&data))
|
||||
return -1;
|
||||
else {
|
||||
@@ -297,7 +306,7 @@ static inline __s32 i2c_smbus_write_i2c_block_data(int file, __u8 command,
|
||||
data.block[i] = values[i-1];
|
||||
data.block[0] = length;
|
||||
return i2c_smbus_access(file,I2C_SMBUS_WRITE,command,
|
||||
I2C_SMBUS_I2C_BLOCK_DATA, &data);
|
||||
I2C_SMBUS_I2C_BLOCK_BROKEN, &data);
|
||||
}
|
||||
|
||||
/* Returns the number of read bytes */
|
||||
|
@@ -316,7 +316,7 @@ int main(int argc, char *argv[])
|
||||
} else {
|
||||
for (res = 0; res < 256; res += i) {
|
||||
i = i2c_smbus_read_i2c_block_data(file,
|
||||
res, cblock + res);
|
||||
res, 32, cblock + res);
|
||||
if (i <= 0)
|
||||
break;
|
||||
}
|
||||
|
Reference in New Issue
Block a user