refactor: rationalise tpm_chip_data struct
Move timeouts into a constant struct.
Remove vestigial address member, which was added based on an
early interpretation of the spec but has not been shown to be
necessary.
Signed-off-by: Matthew Ellis <Matthew.Ellis@arm.com>
Change-Id: Ibf0841f06c9f99a5466de16962399e6bd0818a15
diff --git a/include/tpm2_chip.h b/include/tpm2_chip.h
index 5bee964..28441dc 100644
--- a/include/tpm2_chip.h
+++ b/include/tpm2_chip.h
@@ -10,11 +10,14 @@
#ifndef TPM2_CHIP_H
#define TPM2_CHIP_H
+struct tpm_chip_timeouts {
+ unsigned long msec_a, msec_b;
+ unsigned long msec_c, msec_d;
+};
+
struct tpm_chip_data {
uint8_t locality;
- unsigned long timeout_msec_a, timeout_msec_b;
- unsigned long timeout_msec_c, timeout_msec_d;
- uint16_t address;
+ const struct tpm_chip_timeouts *timeouts;
};
#endif /* TPM2_CHIP_H */
diff --git a/src/tpm2_chip.c b/src/tpm2_chip.c
index 9df496e..50f0a64 100644
--- a/src/tpm2_chip.c
+++ b/src/tpm2_chip.c
@@ -11,11 +11,14 @@
* TPM timeout values
* Reference: TCG PC Client Platform TPM Profile (PTP) Specification v1.05
*/
+const struct tpm_chip_timeouts tpm_timeouts = {
+ .msec_a = 750,
+ .msec_b = 2000,
+ .msec_c = 200,
+ .msec_d = 30,
+};
+
struct tpm_chip_data tpm_chip_data = {
.locality = -1,
- .timeout_msec_a = 750,
- .timeout_msec_b = 2000,
- .timeout_msec_c = 200,
- .timeout_msec_d = 30,
- .address = 0,
+ .timeouts = &tpm_timeouts,
};