diff options
Diffstat (limited to 'drivers/i2c/i2c-core.c')
-rw-r--r-- | drivers/i2c/i2c-core.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index cccfa867824..6971a62397d 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c | |||
@@ -1344,10 +1344,14 @@ s32 i2c_smbus_write_block_data(struct i2c_client *client, u8 command, | |||
1344 | EXPORT_SYMBOL(i2c_smbus_write_block_data); | 1344 | EXPORT_SYMBOL(i2c_smbus_write_block_data); |
1345 | 1345 | ||
1346 | /* Returns the number of read bytes */ | 1346 | /* Returns the number of read bytes */ |
1347 | s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, u8 *values) | 1347 | s32 i2c_smbus_read_i2c_block_data(struct i2c_client *client, u8 command, |
1348 | u8 length, u8 *values) | ||
1348 | { | 1349 | { |
1349 | union i2c_smbus_data data; | 1350 | union i2c_smbus_data data; |
1350 | 1351 | ||
1352 | if (length > I2C_SMBUS_BLOCK_MAX) | ||
1353 | length = I2C_SMBUS_BLOCK_MAX; | ||
1354 | data.block[0] = length; | ||
1351 | if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, | 1355 | if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, |
1352 | I2C_SMBUS_READ,command, | 1356 | I2C_SMBUS_READ,command, |
1353 | I2C_SMBUS_I2C_BLOCK_DATA,&data)) | 1357 | I2C_SMBUS_I2C_BLOCK_DATA,&data)) |
@@ -1468,7 +1472,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1468 | break; | 1472 | break; |
1469 | case I2C_SMBUS_I2C_BLOCK_DATA: | 1473 | case I2C_SMBUS_I2C_BLOCK_DATA: |
1470 | if (read_write == I2C_SMBUS_READ) { | 1474 | if (read_write == I2C_SMBUS_READ) { |
1471 | msg[1].len = I2C_SMBUS_BLOCK_MAX; | 1475 | msg[1].len = data->block[0]; |
1472 | } else { | 1476 | } else { |
1473 | msg[0].len = data->block[0] + 1; | 1477 | msg[0].len = data->block[0] + 1; |
1474 | if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 1) { | 1478 | if (msg[0].len > I2C_SMBUS_BLOCK_MAX + 1) { |
@@ -1524,9 +1528,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, | |||
1524 | data->word = msgbuf1[0] | (msgbuf1[1] << 8); | 1528 | data->word = msgbuf1[0] | (msgbuf1[1] << 8); |
1525 | break; | 1529 | break; |
1526 | case I2C_SMBUS_I2C_BLOCK_DATA: | 1530 | case I2C_SMBUS_I2C_BLOCK_DATA: |
1527 | /* fixed at 32 for now */ | 1531 | for (i = 0; i < data->block[0]; i++) |
1528 | data->block[0] = I2C_SMBUS_BLOCK_MAX; | ||
1529 | for (i = 0; i < I2C_SMBUS_BLOCK_MAX; i++) | ||
1530 | data->block[i+1] = msgbuf1[i]; | 1532 | data->block[i+1] = msgbuf1[i]; |
1531 | break; | 1533 | break; |
1532 | case I2C_SMBUS_BLOCK_DATA: | 1534 | case I2C_SMBUS_BLOCK_DATA: |