Changeset 4417

Show
Ignore:
Timestamp:
05/28/07 10:57:41 (1 year ago)
Author:
khali
Message:

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.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lm-sensors/trunk/CHANGES

    r4414 r4417  
    33 
    44SVN HEAD 
     5  File i2c-dev.h: Support I2C block reads with specified length 
    56  File sensors.conf.eg: Add a dme1737 section 
    67  File lm_sensors.sysconfig: Delete, now generated by sensors-detect 
     
    1011  Man page sensors.conf.5: Update the chip statement section 
    1112  Module i2c-nforce2: Add nForce MCP61, MCP65 support (2.6 backport) 
     13  Program i2cdump: Use the new I2C block read function 
    1214  Program isadump: Detect when address bit 7 is a busy flag 
    1315                   Fix Super-I/O exit sequence for Winbond/Fintek chips 
  • lm-sensors/trunk/kernel/include/i2c-dev.h

    r3177 r4417  
    107107#define I2C_SMBUS_PROC_CALL         4 
    108108#define I2C_SMBUS_BLOCK_DATA        5 
    109 #define I2C_SMBUS_I2C_BLOCK_DATA    6 
     109#define I2C_SMBUS_I2C_BLOCK_BROKEN  6 
    110110#define I2C_SMBUS_BLOCK_PROC_CALL   7           /* SMBus 2.0 */ 
     111#define I2C_SMBUS_I2C_BLOCK_DATA    8 
    111112 
    112113 
     
    272273 
    273274/* Returns the number of read bytes */ 
     275/* Until kernel 2.6.22, the length is hardcoded to 32 bytes. If you 
     276   ask for less than 32 bytes, your code will only work with kernels 
     277   2.6.23 and later. */ 
    274278static inline __s32 i2c_smbus_read_i2c_block_data(int file, __u8 command, 
    275                                                   __u8 *values) 
    276 
    277         union i2c_smbus_data data; 
    278         int i; 
     279                                                  __u8 length, __u8 *values) 
     280
     281        union i2c_smbus_data data; 
     282        int i; 
     283 
     284        if (length > 32) 
     285                length = 32; 
     286        data.block[0] = length; 
    279287        if (i2c_smbus_access(file,I2C_SMBUS_READ,command, 
     288                             length == 32 ? I2C_SMBUS_I2C_BLOCK_BROKEN : 
    280289                              I2C_SMBUS_I2C_BLOCK_DATA,&data)) 
    281290                return -1; 
     
    298307        data.block[0] = length; 
    299308        return i2c_smbus_access(file,I2C_SMBUS_WRITE,command, 
    300                                 I2C_SMBUS_I2C_BLOCK_DATA, &data); 
     309                                I2C_SMBUS_I2C_BLOCK_BROKEN, &data); 
    301310} 
    302311 
  • lm-sensors/trunk/prog/dump/i2cdump.c

    r4335 r4417  
    317317                                for (res = 0; res < 256; res += i) { 
    318318                                        i = i2c_smbus_read_i2c_block_data(file, 
    319                                                 res, cblock + res); 
     319                                                res, 32, cblock + res); 
    320320                                        if (i <= 0) 
    321321                                                break;