Skip to content

Commit 6aa4ef4

Browse files
PeterHueweKent Yoder
authored andcommitted
tpm/tpm_i2c_infineon: Add small comment about return value of __i2c_transfer
Kent Yoder indicated that the code might be a bit clearer with a comment here, so this patch adds a small explanation of the code. Signed-off-by: Peter Huewe <peterhuewe@gmx.de> Signed-off-by: Kent Yoder <key@linux.vnet.ibm.com>
1 parent 21dc02e commit 6aa4ef4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/char/tpm/tpm_i2c_infineon.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len)
162162
/* take care of 'guard time' */
163163
usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);
164164

165+
/* __i2c_transfer returns the number of successfully transferred
166+
* messages.
167+
* So rc should be greater than 0 here otherwise we have an error.
168+
*/
165169
if (rc <= 0)
166170
return -EIO;
167171

@@ -208,6 +212,11 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
208212
i2c_unlock_adapter(tpm_dev.client->adapter);
209213
/* take care of 'guard time' */
210214
usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);
215+
216+
/* __i2c_transfer returns the number of successfully transferred
217+
* messages.
218+
* So rc should be greater than 0 here otherwise we have an error.
219+
*/
211220
if (rc <= 0)
212221
return -EIO;
213222

0 commit comments

Comments
 (0)