Commit 8ced8eee8537b52ef5d77e28d7676ce81bc62359
Committed by
Greg Kroah-Hartman
1 parent
c3efacaa68
Exists in
master
and in
7 other branches
[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: Jean Delvare <khali@linux-fr.org> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Showing 2 changed files with 3 additions and 3 deletions Side-by-side Diff
drivers/i2c/busses/i2c-powermac.c
... | ... | @@ -148,8 +148,6 @@ |
148 | 148 | int read; |
149 | 149 | int addrdir; |
150 | 150 | |
151 | - if (num != 1) | |
152 | - return -EINVAL; | |
153 | 151 | if (msgs->flags & I2C_M_TEN) |
154 | 152 | return -EINVAL; |
155 | 153 | read = (msgs->flags & I2C_M_RD) != 0; |
... | ... | @@ -166,7 +164,7 @@ |
166 | 164 | rc = pmac_i2c_xfer(bus, addrdir, 0, 0, msgs->buf, msgs->len); |
167 | 165 | bail: |
168 | 166 | pmac_i2c_close(bus); |
169 | - return rc < 0 ? rc : msgs->len; | |
167 | + return rc < 0 ? rc : 1; | |
170 | 168 | } |
171 | 169 | |
172 | 170 | static u32 i2c_powermac_func(struct i2c_adapter * adapter) |
include/linux/i2c.h
... | ... | @@ -193,6 +193,8 @@ |
193 | 193 | to NULL. If an adapter algorithm can do SMBus access, set |
194 | 194 | smbus_xfer. If set to NULL, the SMBus protocol is simulated |
195 | 195 | using common I2C messages */ |
196 | + /* master_xfer should return the number of messages successfully | |
197 | + processed, or a negative value on error */ | |
196 | 198 | int (*master_xfer)(struct i2c_adapter *adap,struct i2c_msg *msgs, |
197 | 199 | int num); |
198 | 200 | int (*smbus_xfer) (struct i2c_adapter *adap, u16 addr, |