Skip to content

Commit

Permalink
tpm/tpm_i2c_infineon: Add small comment about return value of __i2c_t…
Browse files Browse the repository at this point in the history
…ransfer

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>
  • Loading branch information
Peter Huewe authored and Kent Yoder committed Apr 12, 2013
1 parent 21dc02e commit 6aa4ef4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions drivers/char/tpm/tpm_i2c_infineon.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ static int iic_tpm_read(u8 addr, u8 *buffer, size_t len)
/* take care of 'guard time' */
usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);

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

Expand Down Expand Up @@ -208,6 +212,11 @@ static int iic_tpm_write_generic(u8 addr, u8 *buffer, size_t len,
i2c_unlock_adapter(tpm_dev.client->adapter);
/* take care of 'guard time' */
usleep_range(SLEEP_DURATION_LOW, SLEEP_DURATION_HI);

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

Expand Down

0 comments on commit 6aa4ef4

Please sign in to comment.