tpm: sanitize constant expressions
Use cpu_to_b32 at the time it is needed in enum tpm_capabilities and enum tpm_sub_capabilities in order to be consistent with the other enums in drivats/char/tpm/tpm.h. Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
This commit is contained in:
@@ -442,26 +442,29 @@ static const struct tpm_input_header tpm_getcap_header = {
|
||||
.ordinal = TPM_ORD_GET_CAP
|
||||
};
|
||||
|
||||
ssize_t tpm_getcap(struct tpm_chip *chip, __be32 subcap_id, cap_t *cap,
|
||||
ssize_t tpm_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap,
|
||||
const char *desc)
|
||||
{
|
||||
struct tpm_cmd_t tpm_cmd;
|
||||
int rc;
|
||||
|
||||
tpm_cmd.header.in = tpm_getcap_header;
|
||||
if (subcap_id == CAP_VERSION_1_1 || subcap_id == CAP_VERSION_1_2) {
|
||||
tpm_cmd.params.getcap_in.cap = subcap_id;
|
||||
if (subcap_id == TPM_CAP_VERSION_1_1 ||
|
||||
subcap_id == TPM_CAP_VERSION_1_2) {
|
||||
tpm_cmd.params.getcap_in.cap = cpu_to_be32(subcap_id);
|
||||
/*subcap field not necessary */
|
||||
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(0);
|
||||
tpm_cmd.header.in.length -= cpu_to_be32(sizeof(__be32));
|
||||
} else {
|
||||
if (subcap_id == TPM_CAP_FLAG_PERM ||
|
||||
subcap_id == TPM_CAP_FLAG_VOL)
|
||||
tpm_cmd.params.getcap_in.cap = TPM_CAP_FLAG;
|
||||
tpm_cmd.params.getcap_in.cap =
|
||||
cpu_to_be32(TPM_CAP_FLAG);
|
||||
else
|
||||
tpm_cmd.params.getcap_in.cap = TPM_CAP_PROP;
|
||||
tpm_cmd.params.getcap_in.cap =
|
||||
cpu_to_be32(TPM_CAP_PROP);
|
||||
tpm_cmd.params.getcap_in.subcap_size = cpu_to_be32(4);
|
||||
tpm_cmd.params.getcap_in.subcap = subcap_id;
|
||||
tpm_cmd.params.getcap_in.subcap = cpu_to_be32(subcap_id);
|
||||
}
|
||||
rc = tpm_transmit_cmd(chip, &tpm_cmd, TPM_INTERNAL_RESULT_SIZE, 0,
|
||||
desc);
|
||||
|
Reference in New Issue
Block a user