summaryrefslogtreecommitdiffstats
path: root/include/tpm-common.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-11-18 14:22:27 -0700
committerSimon Glass <sjg@chromium.org>2018-11-29 09:30:06 -0700
commitabdc7b8a2d7f2b8527ce4f9133b777942af99126 (patch)
treee45abe92dc40db0d684f7ed82453504469b99cc3 /include/tpm-common.h
parent51f00c1704e505f51a02a3687e4384231ce8ae20 (diff)
downloadu-boot-abdc7b8a2d7f2b8527ce4f9133b777942af99126.tar.gz
u-boot-abdc7b8a2d7f2b8527ce4f9133b777942af99126.tar.xz
u-boot-abdc7b8a2d7f2b8527ce4f9133b777942af99126.zip
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 <sjg@chromium.org>
Diffstat (limited to 'include/tpm-common.h')
-rw-r--r--include/tpm-common.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/include/tpm-common.h b/include/tpm-common.h
index f8c5569003..3d88b44db7 100644
--- a/include/tpm-common.h
+++ b/include/tpm-common.h
@@ -176,9 +176,15 @@ struct tpm_ops {
int do_##cmd(cmd_tbl_t *cmdtp, int flag, \
int argc, char * const argv[]) \
{ \
+ struct udevice *dev; \
+ int rc; \
+ \
+ rc = get_tpm(&dev); \
+ if (rc) \
+ return rc; \
if (argc != 1) \
return CMD_RET_USAGE; \
- return report_return_code(cmd()); \
+ return report_return_code(cmd(dev)); \
}
/**
@@ -187,6 +193,7 @@ int do_##cmd(cmd_tbl_t *cmdtp, int flag, \
* After all commands have been completed the caller is supposed to
* call tpm_close().
*
+ * @dev - TPM device
* Returns 0 on success, -ve on failure.
*/
int tpm_open(struct udevice *dev);
@@ -196,6 +203,9 @@ int tpm_open(struct udevice *dev);
*
* Releasing the locked locality. Returns 0 on success, -ve 1 on
* failure (in case lock removal did not succeed).
+ *
+ * @dev - TPM device
+ * Returns 0 on success, -ve on failure.
*/
int tpm_close(struct udevice *dev);
@@ -222,6 +232,7 @@ int tpm_get_desc(struct udevice *dev, char *buf, int size);
* Note that the outgoing data is inspected to determine command type
* (ordinal) and a timeout is used for that command type.
*
+ * @dev - TPM device
* @sendbuf - buffer of the data to send
* @send_size size of the data to send
* @recvbuf - memory to save the response to
@@ -236,9 +247,10 @@ int tpm_xfer(struct udevice *dev, const u8 *sendbuf, size_t send_size,
/**
* Initialize TPM device. It must be called before any TPM commands.
*
+ * @dev - TPM device
* @return 0 on success, non-0 on error.
*/
-int tpm_init(void);
+int tpm_init(struct udevice *dev);
/**
* Retrieve the array containing all the v1 (resp. v2) commands.