Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tpm: move endianness conversion of ordinals to tpm_input_header

Move CPU native value to big-endian conversion of ordinals to the
tpm_input_header declarations.

With the previous and this patch it will now be possible to modify TPM 1.2
functions to use tpm_buf_init(), which expects CPU native value for the
tag and ordinal arguments.

Signed-off-by: Roberto Sassu <roberto.sassu@huawei.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>

authored by

Roberto Sassu and committed by
Jarkko Sakkinen
a69faebf 06e93279

+14 -14
+12 -12
drivers/char/tpm/tpm-interface.c
··· 540 540 #define TPM_DIGEST_SIZE 20 541 541 #define TPM_RET_CODE_IDX 6 542 542 #define TPM_INTERNAL_RESULT_SIZE 200 543 - #define TPM_ORD_GET_CAP cpu_to_be32(101) 544 - #define TPM_ORD_GET_RANDOM cpu_to_be32(70) 543 + #define TPM_ORD_GET_CAP 101 544 + #define TPM_ORD_GET_RANDOM 70 545 545 546 546 static const struct tpm_input_header tpm_getcap_header = { 547 547 .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND), 548 548 .length = cpu_to_be32(22), 549 - .ordinal = TPM_ORD_GET_CAP 549 + .ordinal = cpu_to_be32(TPM_ORD_GET_CAP) 550 550 }; 551 551 552 552 ssize_t tpm_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap, ··· 581 581 } 582 582 EXPORT_SYMBOL_GPL(tpm_getcap); 583 583 584 - #define TPM_ORD_STARTUP cpu_to_be32(153) 584 + #define TPM_ORD_STARTUP 153 585 585 #define TPM_ST_CLEAR cpu_to_be16(1) 586 586 #define TPM_ST_STATE cpu_to_be16(2) 587 587 #define TPM_ST_DEACTIVATED cpu_to_be16(3) 588 588 static const struct tpm_input_header tpm_startup_header = { 589 589 .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND), 590 590 .length = cpu_to_be32(12), 591 - .ordinal = TPM_ORD_STARTUP 591 + .ordinal = cpu_to_be32(TPM_ORD_STARTUP) 592 592 }; 593 593 594 594 static int tpm_startup(struct tpm_chip *chip, __be16 startup_type) ··· 760 760 return rc; 761 761 } 762 762 763 - #define TPM_ORDINAL_PCRREAD cpu_to_be32(21) 763 + #define TPM_ORDINAL_PCRREAD 21 764 764 #define READ_PCR_RESULT_SIZE 30 765 765 #define READ_PCR_RESULT_BODY_SIZE 20 766 766 static const struct tpm_input_header pcrread_header = { 767 767 .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND), 768 768 .length = cpu_to_be32(14), 769 - .ordinal = TPM_ORDINAL_PCRREAD 769 + .ordinal = cpu_to_be32(TPM_ORDINAL_PCRREAD) 770 770 }; 771 771 772 772 int tpm_pcr_read_dev(struct tpm_chip *chip, int pcr_idx, u8 *res_buf) ··· 838 838 } 839 839 EXPORT_SYMBOL_GPL(tpm_pcr_read); 840 840 841 - #define TPM_ORD_PCR_EXTEND cpu_to_be32(20) 841 + #define TPM_ORD_PCR_EXTEND 20 842 842 #define EXTEND_PCR_RESULT_SIZE 34 843 843 #define EXTEND_PCR_RESULT_BODY_SIZE 20 844 844 static const struct tpm_input_header pcrextend_header = { 845 845 .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND), 846 846 .length = cpu_to_be32(34), 847 - .ordinal = TPM_ORD_PCR_EXTEND 847 + .ordinal = cpu_to_be32(TPM_ORD_PCR_EXTEND) 848 848 }; 849 849 850 850 /** ··· 1060 1060 } 1061 1061 EXPORT_SYMBOL_GPL(wait_for_tpm_stat); 1062 1062 1063 - #define TPM_ORD_SAVESTATE cpu_to_be32(152) 1063 + #define TPM_ORD_SAVESTATE 152 1064 1064 #define SAVESTATE_RESULT_SIZE 10 1065 1065 1066 1066 static const struct tpm_input_header savestate_header = { 1067 1067 .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND), 1068 1068 .length = cpu_to_be32(10), 1069 - .ordinal = TPM_ORD_SAVESTATE 1069 + .ordinal = cpu_to_be32(TPM_ORD_SAVESTATE) 1070 1070 }; 1071 1071 1072 1072 /* ··· 1151 1151 static const struct tpm_input_header tpm_getrandom_header = { 1152 1152 .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND), 1153 1153 .length = cpu_to_be32(14), 1154 - .ordinal = TPM_ORD_GET_RANDOM 1154 + .ordinal = cpu_to_be32(TPM_ORD_GET_RANDOM) 1155 1155 }; 1156 1156 1157 1157 /**
+2 -2
drivers/char/tpm/tpm-sysfs.c
··· 22 22 23 23 #define READ_PUBEK_RESULT_SIZE 314 24 24 #define READ_PUBEK_RESULT_MIN_BODY_SIZE (28 + 256) 25 - #define TPM_ORD_READPUBEK cpu_to_be32(124) 25 + #define TPM_ORD_READPUBEK 124 26 26 static const struct tpm_input_header tpm_readpubek_header = { 27 27 .tag = cpu_to_be16(TPM_TAG_RQU_COMMAND), 28 28 .length = cpu_to_be32(30), 29 - .ordinal = TPM_ORD_READPUBEK 29 + .ordinal = cpu_to_be32(TPM_ORD_READPUBEK) 30 30 }; 31 31 static ssize_t pubek_show(struct device *dev, struct device_attribute *attr, 32 32 char *buf)