mirror of
https://github.com/Telecominfraproject/OpenNetworkLinux.git
synced 2025-12-25 17:27:01 +00:00
support SMBus block read
This commit is contained in:
@@ -66,6 +66,11 @@
|
||||
*/
|
||||
#define ONLP_I2C_F_USE_BLOCK_READ 0x20
|
||||
|
||||
/**
|
||||
* Use SMBUS block reads if possible.
|
||||
*/
|
||||
#define ONLP_I2C_F_USE_SMBUS_BLOCK_READ 0x40
|
||||
|
||||
/**
|
||||
* @brief Open and prepare for reading or writing.
|
||||
* @param bus The i2c bus number.
|
||||
|
||||
@@ -105,11 +105,17 @@ onlp_i2c_block_read(int bus, uint8_t addr, uint8_t offset, int size,
|
||||
int count = size;
|
||||
uint8_t* p = rdata;
|
||||
while(count > 0) {
|
||||
int rv;
|
||||
int rsize = (count >= ONLPLIB_CONFIG_I2C_BLOCK_SIZE) ? ONLPLIB_CONFIG_I2C_BLOCK_SIZE : count;
|
||||
int rv = i2c_smbus_read_i2c_block_data(fd,
|
||||
p - rdata,
|
||||
if(flags & ONLP_I2C_F_USE_SMBUS_BLOCK_READ) {
|
||||
rv = i2c_smbus_read_block_data(fd, offset, p);
|
||||
} else {
|
||||
rv = i2c_smbus_read_i2c_block_data(fd,
|
||||
offset,
|
||||
rsize,
|
||||
p);
|
||||
offset += rsize;
|
||||
}
|
||||
|
||||
if(rv != rsize) {
|
||||
AIM_LOG_ERROR("i2c-%d: reading address 0x%x, offset %d, size=%d failed: %{errno}",
|
||||
|
||||
Reference in New Issue
Block a user