diff options
author | Jean Delvare <khali@linux-fr.org> | 2007-05-01 23:26:29 +0200 |
---|---|---|
committer | Jean Delvare <khali@hyperion.delvare> | 2007-05-01 23:26:29 +0200 |
commit | 3c4bb241d34ee3d9ab87aad265734885385f179b (patch) | |
tree | 6a90d86fa2cf3e7aafeee1cc829a5396c662fffb /drivers/i2c | |
parent | 209d27c3b1676c0497108f0642c51a08b98a7856 (diff) | |
download | kernel_goldelico_gta04-3c4bb241d34ee3d9ab87aad265734885385f179b.zip kernel_goldelico_gta04-3c4bb241d34ee3d9ab87aad265734885385f179b.tar.gz kernel_goldelico_gta04-3c4bb241d34ee3d9ab87aad265734885385f179b.tar.bz2 |
i2c-algo-bit: Emulate SMBus block read
Now that i2c-core lets the i2c bus drivers emulate the SMBus block read
and SMBus block process call transaction types, let's implement that in
the popular i2c bit-banging driver. This will also act as a reference
implementation for other bus drivers which want to do the same.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/algos/i2c-algo-bit.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/i2c/algos/i2c-algo-bit.c b/drivers/i2c/algos/i2c-algo-bit.c index 28b7e25..fcef6ff 100644 --- a/drivers/i2c/algos/i2c-algo-bit.c +++ b/drivers/i2c/algos/i2c-algo-bit.c @@ -391,6 +391,21 @@ static int readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msg) }; scllo(adap); sdahi(adap); + + /* Some SMBus transactions require that we receive the + transaction length as the first read byte. */ + if (rdcount == 1 && (msg->flags & I2C_M_RECV_LEN)) { + if (inval <= 0 || inval > I2C_SMBUS_BLOCK_MAX) { + printk(KERN_ERR "i2c-algo-bit: readbytes: " + "invalid block length (%d)\n", inval); + return -EREMOTEIO; + } + /* The original count value accounts for the extra + bytes, that is, either 1 for a regular transaction, + or 2 for a PEC transaction. */ + count += inval; + msg->len += inval; + } } return rdcount; } @@ -509,6 +524,8 @@ bailout: static u32 bit_func(struct i2c_adapter *adap) { return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | + I2C_FUNC_SMBUS_READ_BLOCK_DATA | + I2C_FUNC_SMBUS_BLOCK_PROC_CALL | I2C_FUNC_10BIT_ADDR | I2C_FUNC_PROTOCOL_MANGLING; } |