tpm1: reimplement tpm1_continue_selftest() using tpm_buf
authorTomas Winkler <tomas.winkler@intel.com>
Fri, 19 Oct 2018 18:23:06 +0000 (21:23 +0300)
committerJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tue, 13 Nov 2018 11:46:31 +0000 (13:46 +0200)
Reimplement tpm1_continue_selftest() using tpm_buf structure.
This is the last command using the old tpm_cmd_t structure
and now the structure can be removed.

Cc: Nayna Jain <nayna@linux.vnet.ibm.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Tested-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
drivers/char/tpm/tpm.h
drivers/char/tpm/tpm1-cmd.c

index bf2ef1eeda500e0945025f2a8a9ac8917eaded46..e0778d19da98cd6d1cc9df5860fad7cbdedfa6b4 100644 (file)
@@ -377,15 +377,6 @@ enum tpm_sub_capabilities {
        TPM_CAP_PROP_TIS_DURATION = 0x120,
 };
 
-typedef union {
-       struct  tpm_input_header in;
-       struct  tpm_output_header out;
-} tpm_cmd_header;
-
-struct tpm_cmd_t {
-       tpm_cmd_header  header;
-} __packed;
-
 
 /* 128 bytes is an arbitrary cap. This could be as large as TPM_BUFSIZE - 18
  * bytes, but 128 is still a relatively large number of random bytes and
index d418a27a75e03641692a9f114eed98ea8488ce7d..6b04648f81840a72ab925b0c39a60a95cc7b62c0 100644 (file)
@@ -602,15 +602,8 @@ out:
 }
 
 #define TPM_ORD_CONTINUE_SELFTEST 83
-#define CONTINUE_SELFTEST_RESULT_SIZE 10
-static const struct tpm_input_header continue_selftest_header = {
-       .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND),
-       .length = cpu_to_be32(10),
-       .ordinal = cpu_to_be32(TPM_ORD_CONTINUE_SELFTEST),
-};
-
 /**
- * tpm_continue_selftest -- run TPM's selftest
+ * tpm_continue_selftest() - run TPM's selftest
  * @chip: TPM chip to use
  *
  * Returns 0 on success, < 0 in case of fatal error or a value > 0 representing
@@ -618,12 +611,18 @@ static const struct tpm_input_header continue_selftest_header = {
  */
 static int tpm1_continue_selftest(struct tpm_chip *chip)
 {
+       struct tpm_buf buf;
        int rc;
-       struct tpm_cmd_t cmd;
 
-       cmd.header.in = continue_selftest_header;
-       rc = tpm_transmit_cmd(chip, NULL, &cmd, CONTINUE_SELFTEST_RESULT_SIZE,
+       rc = tpm_buf_init(&buf, TPM_TAG_RQU_COMMAND, TPM_ORD_CONTINUE_SELFTEST);
+       if (rc)
+               return rc;
+
+       rc = tpm_transmit_cmd(chip, NULL, buf.data, PAGE_SIZE,
                              0, 0, "continue selftest");
+
+       tpm_buf_destroy(&buf);
+
        return rc;
 }