tpm(4): Nix TPM_BE16/TPM_BE32. Just use sys/endian.h.
This commit is contained in:
parent
3c0daa59b0
commit
2c163b14db
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: tpm.c,v 1.24 2022/01/16 20:24:34 riastradh Exp $ */
|
/* $NetBSD: tpm.c,v 1.25 2022/01/29 12:27:30 riastradh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 The NetBSD Foundation, Inc.
|
* Copyright (c) 2019 The NetBSD Foundation, Inc.
|
||||||
|
@ -48,7 +48,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.24 2022/01/16 20:24:34 riastradh Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.25 2022/01/29 12:27:30 riastradh Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
@ -205,14 +205,14 @@ tpm12_suspend(struct tpm_softc *sc)
|
||||||
/*
|
/*
|
||||||
* Verify the response looks reasonable.
|
* Verify the response looks reasonable.
|
||||||
*/
|
*/
|
||||||
if (TPM_BE16(response.tag) != TPM_TAG_RSP_COMMAND ||
|
if (be16toh(response.tag) != TPM_TAG_RSP_COMMAND ||
|
||||||
TPM_BE32(response.length) != sizeof(response) ||
|
be32toh(response.length) != sizeof(response) ||
|
||||||
TPM_BE32(response.code) != 0) {
|
be32toh(response.code) != 0) {
|
||||||
device_printf(sc->sc_dev,
|
device_printf(sc->sc_dev,
|
||||||
"TPM_ORD_SaveState failed: tag=0x%x length=0x%x code=0x%x",
|
"TPM_ORD_SaveState failed: tag=0x%x length=0x%x code=0x%x",
|
||||||
TPM_BE16(response.tag),
|
be16toh(response.tag),
|
||||||
TPM_BE32(response.length),
|
be32toh(response.length),
|
||||||
TPM_BE32(response.code));
|
be32toh(response.code));
|
||||||
error = EIO;
|
error = EIO;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -303,14 +303,14 @@ tpm20_suspend(struct tpm_softc *sc)
|
||||||
/*
|
/*
|
||||||
* Verify the response looks reasonable.
|
* Verify the response looks reasonable.
|
||||||
*/
|
*/
|
||||||
if (TPM_BE16(response.tag) != TPM2_ST_NO_SESSIONS ||
|
if (be16toh(response.tag) != TPM2_ST_NO_SESSIONS ||
|
||||||
TPM_BE32(response.length) != sizeof(response) ||
|
be32toh(response.length) != sizeof(response) ||
|
||||||
TPM_BE32(response.code) != TPM2_RC_SUCCESS) {
|
be32toh(response.code) != TPM2_RC_SUCCESS) {
|
||||||
device_printf(sc->sc_dev,
|
device_printf(sc->sc_dev,
|
||||||
"TPM_CC_Shutdown failed: tag=0x%x length=0x%x code=0x%x",
|
"TPM_CC_Shutdown failed: tag=0x%x length=0x%x code=0x%x",
|
||||||
TPM_BE16(response.tag),
|
be16toh(response.tag),
|
||||||
TPM_BE32(response.length),
|
be32toh(response.length),
|
||||||
TPM_BE32(response.code));
|
be32toh(response.code));
|
||||||
error = EIO;
|
error = EIO;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
@ -1084,7 +1084,7 @@ tpmread(dev_t dev, struct uio *uio, int flags)
|
||||||
rv = EIO;
|
rv = EIO;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
len = TPM_BE32(hdr.length);
|
len = be32toh(hdr.length);
|
||||||
if (len > MIN(sizeof(buf), uio->uio_resid) || len < sizeof(hdr)) {
|
if (len > MIN(sizeof(buf), uio->uio_resid) || len < sizeof(hdr)) {
|
||||||
rv = EIO;
|
rv = EIO;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: tpmreg.h,v 1.10 2021/11/14 21:18:30 riastradh Exp $ */
|
/* $NetBSD: tpmreg.h,v 1.11 2022/01/29 12:27:30 riastradh Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2019 The NetBSD Foundation, Inc.
|
* Copyright (c) 2019 The NetBSD Foundation, Inc.
|
||||||
|
@ -37,14 +37,6 @@
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
|
|
||||||
#if (_BYTE_ORDER == _LITTLE_ENDIAN)
|
|
||||||
#define TPM_BE16(a) bswap16(a)
|
|
||||||
#define TPM_BE32(a) bswap32(a)
|
|
||||||
#else
|
|
||||||
#define TPM_BE16(a) (a)
|
|
||||||
#define TPM_BE32(a) (a)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct tpm_header {
|
struct tpm_header {
|
||||||
uint16_t tag;
|
uint16_t tag;
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
|
|
Loading…
Reference in New Issue