提交 8ced8eee 编写于 作者: J Jean Delvare 提交者: Greg Kroah-Hartman

[PATCH] i2c-powermac: Fix master_xfer return value

Fix the value returned by the i2c-powermac's master_xfer method.
It should return the number of messages processed successfully, but
instead returns the number of data bytes in the first (and only)
processed message.

Also explicitly mention the master_xfer convention so that future
implementations get it right directly.
Signed-off-by: NJean Delvare <khali@linux-fr.org>
Acked-by: NBenjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 c3efacaa
...@@ -148,8 +148,6 @@ static int i2c_powermac_master_xfer( struct i2c_adapter *adap, ...@@ -148,8 +148,6 @@ static int i2c_powermac_master_xfer( struct i2c_adapter *adap,
int read; int read;
int addrdir; int addrdir;
if (num != 1)
return -EINVAL;
if (msgs->flags & I2C_M_TEN) if (msgs->flags & I2C_M_TEN)
return -EINVAL; return -EINVAL;
read = (msgs->flags & I2C_M_RD) != 0; read = (msgs->flags & I2C_M_RD) != 0;
...@@ -166,7 +164,7 @@ static int i2c_powermac_master_xfer( struct i2c_adapter *adap, ...@@ -166,7 +164,7 @@ static int i2c_powermac_master_xfer( struct i2c_adapter *adap,
rc = pmac_i2c_xfer(bus, addrdir, 0, 0, msgs->buf, msgs->len); rc = pmac_i2c_xfer(bus, addrdir, 0, 0, msgs->buf, msgs->len);
bail: bail:
pmac_i2c_close(bus); pmac_i2c_close(bus);
return rc < 0 ? rc : msgs->len; return rc < 0 ? rc : 1;
} }
static u32 i2c_powermac_func(struct i2c_adapter * adapter) static u32 i2c_powermac_func(struct i2c_adapter * adapter)
......
...@@ -193,6 +193,8 @@ struct i2c_algorithm { ...@@ -193,6 +193,8 @@ struct i2c_algorithm {
to NULL. If an adapter algorithm can do SMBus access, set to NULL. If an adapter algorithm can do SMBus access, set
smbus_xfer. If set to NULL, the SMBus protocol is simulated smbus_xfer. If set to NULL, the SMBus protocol is simulated
using common I2C messages */ using common I2C messages */
/* master_xfer should return the number of messages successfully
processed, or a negative value on error */
int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs, int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs,
int num); int num);
int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册