From abdc7b8a2d7f2b8527ce4f9133b777942af99126 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 18 Nov 2018 14:22:27 -0700 Subject: tpm: Convert to use a device parameter At present many TPM calls assume there is only one TPM in the system and look up this TPM themselves. This is inconsistent with driver model, which expects all driver methods to have a device parameter. Update the code to correct this. Signed-off-by: Simon Glass --- lib/tpm-common.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'lib/tpm-common.c') diff --git a/lib/tpm-common.c b/lib/tpm-common.c index a440639..6afe59b 100644 --- a/lib/tpm-common.c +++ b/lib/tpm-common.c @@ -151,9 +151,9 @@ u32 tpm_return_code(const void *response) return get_unaligned_be32(response + return_code_offset); } -u32 tpm_sendrecv_command(const void *command, void *response, size_t *size_ptr) +u32 tpm_sendrecv_command(struct udevice *dev, const void *command, + void *response, size_t *size_ptr) { - struct udevice *dev; int err, ret; u8 response_buffer[COMMAND_BUFFER_SIZE]; size_t response_length; @@ -166,9 +166,6 @@ u32 tpm_sendrecv_command(const void *command, void *response, size_t *size_ptr) response_length = sizeof(response_buffer); } - ret = uclass_first_device_err(UCLASS_TPM, &dev); - if (ret) - return ret; err = tpm_xfer(dev, command, tpm_command_size(command), response, &response_length); @@ -188,14 +185,7 @@ u32 tpm_sendrecv_command(const void *command, void *response, size_t *size_ptr) return ret; } -int tpm_init(void) +int tpm_init(struct udevice *dev) { - struct udevice *dev; - int err; - - err = uclass_first_device_err(UCLASS_TPM, &dev); - if (err) - return err; - return tpm_open(dev); } -- cgit v1.1