summaryrefslogtreecommitdiff
path: root/src/drivers/i2c
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2014-10-29 11:14:53 -0700
committerPatrick Georgi <pgeorgi@google.com>2015-04-10 11:57:59 +0200
commit1fd91a19664a96022cc036fcb3f6d53fe7ff8868 (patch)
tree205252062408aa4609bcfe749aec8e83c52a999d /src/drivers/i2c
parent644afa70478483144e31e08857c66c83765737fb (diff)
downloadcoreboot-1fd91a19664a96022cc036fcb3f6d53fe7ff8868.tar.xz
tpm: allow 0 as valid i2c bus number
tpm driver uses bus=0 as indication of uninitialized tpm device. this change allows 0 as a valid i2c bus number. BUG=None BRANCH=ToT TEST=Built cosmos. Change-Id: Ie8d285abff11643cc3efc0fa30e4afcc3ca1c0d5 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 493077b68cf46b08f0d1ddfe57bf6064d714d537 Original-Change-Id: Iac55e88db4ef757a292270e7201d8fdd37a90b50 Original-Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/226294 Original-Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-on: http://review.coreboot.org/9405 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'src/drivers/i2c')
-rw-r--r--src/drivers/i2c/tpm/tpm.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/drivers/i2c/tpm/tpm.c b/src/drivers/i2c/tpm/tpm.c
index bc36e3587c..dc4ab78149 100644
--- a/src/drivers/i2c/tpm/tpm.c
+++ b/src/drivers/i2c/tpm/tpm.c
@@ -86,13 +86,14 @@ static const char * const chip_name[] = {
/* Structure to store I2C TPM specific stuff */
struct tpm_inf_dev {
- unsigned bus;
+ int bus;
unsigned int addr;
uint8_t buf[TPM_BUFSIZE + sizeof(uint8_t)]; // max. buffer size + addr
enum i2c_chip_type chip_type;
};
static struct tpm_inf_dev tpm_dev = {
+ .bus = -1,
.addr = TPM_I2C_ADDR
};
@@ -115,7 +116,7 @@ static int iic_tpm_read(uint8_t addr, uint8_t *buffer, size_t len)
int rc;
int count;
- if (!tpm_dev.bus)
+ if (tpm_dev.bus < 0)
return -1;
if ((tpm_dev.chip_type == SLB9635) || (tpm_dev.chip_type == UNKNOWN)) {
/* slb9635 protocol should work in both cases */
@@ -186,7 +187,7 @@ static int iic_tpm_write_generic(uint8_t addr, uint8_t *buffer, size_t len,
tpm_dev.buf[0] = addr;
memcpy(&(tpm_dev.buf[1]), buffer, len);
- if (!tpm_dev.bus)
+ if (tpm_dev.bus < 0)
return -1;
for (count = 0; count < max_count; count++) {
rc = i2c_write_raw(tpm_dev.bus, tpm_dev.addr,