From 09bec71f76d5fa668c218299e08ede3d99afb0a0 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Wed, 22 Jun 2016 10:16:02 -0700 Subject: [PATCH] tpm: move buffer size definition to common code Also change it to match the naming pattern of the other enums of the group. BRANCH=none BUG=chrome-os-partner:50645 TEST=veyron_jaq compiles cleanly Change-Id: I1b7b25903c20788e8487ab5ebb3ec7c51470fd76 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/354765 Reviewed-by: Aaron Durbin --- src/drivers/tpm/slb9635_i2c.c | 4 ++-- src/drivers/tpm/slb9635_i2c.h | 6 +----- src/drivers/tpm/tpm.h | 3 ++- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/drivers/tpm/slb9635_i2c.c b/src/drivers/tpm/slb9635_i2c.c index d817ac13..721a0d97 100644 --- a/src/drivers/tpm/slb9635_i2c.c +++ b/src/drivers/tpm/slb9635_i2c.c @@ -155,7 +155,7 @@ static int iic_tpm_write(Slb9635I2c *tpm, uint8_t addr, const uint8_t *buffer, int rc = 0; int count; - if (len > MaxTpmBufSize) { + if (len > TpmMaxBufSize) { printf("%s: Length %zd is too large\n", __func__, len); return -1; } @@ -409,7 +409,7 @@ static int tpm_send(I2cTpmChipOps *me, const uint8_t *buf, size_t len) size_t count = 0; uint8_t sts = TpmStsGo; - if (len > MaxTpmBufSize) + if (len > TpmMaxBufSize) return -1; // Command is too long for our tpm, sorry. status = tpm->base.chip_ops.status(&tpm->base.chip_ops); diff --git a/src/drivers/tpm/slb9635_i2c.h b/src/drivers/tpm/slb9635_i2c.h index ce21e914..4380250d 100644 --- a/src/drivers/tpm/slb9635_i2c.h +++ b/src/drivers/tpm/slb9635_i2c.h @@ -20,10 +20,6 @@ #include "drivers/tpm/i2c.h" -enum { - MaxTpmBufSize = 1260 -}; - enum i2c_chip_type { SLB9635, SLB9645, @@ -33,7 +29,7 @@ enum i2c_chip_type { typedef struct Slb9635I2c { I2cTpm base; - uint8_t buf[sizeof(uint8_t) + MaxTpmBufSize]; // addr + buff size + uint8_t buf[sizeof(uint8_t) + TpmMaxBufSize]; // addr + buff size enum i2c_chip_type chip_type; } Slb9635I2c; diff --git a/src/drivers/tpm/tpm.h b/src/drivers/tpm/tpm.h index ea3c02f6..89aee66a 100644 --- a/src/drivers/tpm/tpm.h +++ b/src/drivers/tpm/tpm.h @@ -23,7 +23,8 @@ enum { TpmCmdCountOffset = 2, - TpmCmdOrdinalOffset = 6 + TpmCmdOrdinalOffset = 6, + TpmMaxBufSize = 1260 }; typedef struct TpmOps -- 2.11.0