提交 3c4bb241 编写于 作者: J Jean Delvare 提交者: Jean Delvare

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: NJean Delvare <khali@linux-fr.org>
上级 209d27c3
......@@ -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 @@ static int bit_xfer(struct i2c_adapter *i2c_adap,
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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册