Commit 7b9e7ff8 authored by Masahiro Yamada's avatar Masahiro Yamada Committed by Kleber Sacilotto de Souza

i2c: uniphier: issue STOP only for last message or I2C_M_STOP

BugLink: https://bugs.launchpad.net/bugs/1798770

[ Upstream commit 38f5d8d8 ]

This driver currently emits a STOP if the next message is not
I2C_MD_RD.  It should not do it because it disturbs the I2C_RDWR
ioctl, where read/write transactions are combined without STOP
between.

Issue STOP only when the message is the last one _or_ flagged with
I2C_M_STOP.

Fixes: dd6fd4a3 ("i2c: uniphier: add UniPhier FIFO-less I2C driver")
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent a484bc73
...@@ -247,11 +247,8 @@ static int uniphier_i2c_master_xfer(struct i2c_adapter *adap, ...@@ -247,11 +247,8 @@ static int uniphier_i2c_master_xfer(struct i2c_adapter *adap,
return ret; return ret;
for (msg = msgs; msg < emsg; msg++) { for (msg = msgs; msg < emsg; msg++) {
/* If next message is read, skip the stop condition */ /* Emit STOP if it is the last message or I2C_M_STOP is set. */
bool stop = !(msg + 1 < emsg && msg[1].flags & I2C_M_RD); bool stop = (msg + 1 == emsg) || (msg->flags & I2C_M_STOP);
/* but, force it if I2C_M_STOP is set */
if (msg->flags & I2C_M_STOP)
stop = true;
ret = uniphier_i2c_master_xfer_one(adap, msg, stop); ret = uniphier_i2c_master_xfer_one(adap, msg, stop);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment