[U-Boot] [PATCH v4 03/32] tpm: substitute deprecated uint<x>_t types with their u<x> equivalent

Miquel Raynal miquel.raynal at bootlin.com
Tue May 15 09:56:59 UTC 2018


Fix following checkpatch.pl issues in TPM-related code:

    CHECK: Prefer kernel type 'u8' over 'uint8_t'
    CHECK: Prefer kernel type 'u16' over 'uint16_t'
    CHECK: Prefer kernel type 'u32' over 'uint32_t'

Signed-off-by: Miquel Raynal <miquel.raynal at bootlin.com>
---
 cmd/tpm.c     |  86 ++++++++---------
 include/tpm.h |  72 +++++++--------
 lib/tpm.c     | 290 +++++++++++++++++++++++++++++-----------------------------
 3 files changed, 220 insertions(+), 228 deletions(-)

diff --git a/cmd/tpm.c b/cmd/tpm.c
index d9b433582c..4109ace362 100644
--- a/cmd/tpm.c
+++ b/cmd/tpm.c
@@ -25,7 +25,7 @@ enum {
  * @param data		byte string to be printed
  * @param count		number of bytes to be printed
  */
-static void print_byte_string(uint8_t *data, size_t count)
+static void print_byte_string(u8 *data, size_t count)
 {
 	int i, print_newline = 0;
 
@@ -52,7 +52,7 @@ static void print_byte_string(uint8_t *data, size_t count)
  * @param count_ptr	output variable for the length of byte string
  * @return pointer to output buffer
  */
-static void *parse_byte_string(char *bytes, uint8_t *data, size_t *count_ptr)
+static void *parse_byte_string(char *bytes, u8 *data, size_t *count_ptr)
 {
 	char byte[3];
 	size_t count, length;
@@ -72,7 +72,7 @@ static void *parse_byte_string(char *bytes, uint8_t *data, size_t *count_ptr)
 	for (i = 0; i < length; i += 2) {
 		byte[0] = bytes[i];
 		byte[1] = bytes[i + 1];
-		data[i / 2] = (uint8_t)simple_strtoul(byte, NULL, 16);
+		data[i / 2] = (u8)simple_strtoul(byte, NULL, 16);
 	}
 
 	if (count_ptr)
@@ -146,7 +146,7 @@ static size_t type_string_get_space_size(const char *type_str)
  * @param count		pointer for storing size of buffer
  * @return pointer to buffer or NULL on error
  */
-static void *type_string_alloc(const char *type_str, uint32_t *count)
+static void *type_string_alloc(const char *type_str, u32 *count)
 {
 	void *data;
 	size_t size;
@@ -171,10 +171,10 @@ static void *type_string_alloc(const char *type_str, uint32_t *count)
  * @return 0 on success, non-0 on error
  */
 static int type_string_pack(const char *type_str, char * const values[],
-		uint8_t *data)
+			    u8 *data)
 {
 	size_t offset;
-	uint32_t value;
+	u32 value;
 
 	for (offset = 0; *type_str; type_str++, values++) {
 		value = simple_strtoul(values[0], NULL, 0);
@@ -208,11 +208,11 @@ static int type_string_pack(const char *type_str, char * const values[],
  * @param vars		names of environment variables
  * @return 0 on success, non-0 on error
  */
-static int type_string_write_vars(const char *type_str, uint8_t *data,
-		char * const vars[])
+static int type_string_write_vars(const char *type_str, u8 *data,
+				  char * const vars[])
 {
 	size_t offset;
-	uint32_t value;
+	u32 value;
 
 	for (offset = 0; *type_str; type_str++, vars++) {
 		switch (*type_str) {
@@ -262,7 +262,7 @@ static int do_tpm_startup(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_nv_define_space(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t index, perm, size;
+	u32 index, perm, size;
 
 	if (argc != 4)
 		return CMD_RET_USAGE;
@@ -276,7 +276,7 @@ static int do_tpm_nv_define_space(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_nv_read_value(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t index, count, rc;
+	u32 index, count, rc;
 	void *data;
 
 	if (argc != 4)
@@ -297,7 +297,7 @@ static int do_tpm_nv_read_value(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_nv_write_value(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t index, rc;
+	u32 index, rc;
 	size_t count;
 	void *data;
 
@@ -319,8 +319,8 @@ static int do_tpm_nv_write_value(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_extend(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t index, rc;
-	uint8_t in_digest[20], out_digest[20];
+	u32 index, rc;
+	u8 in_digest[20], out_digest[20];
 
 	if (argc != 3)
 		return CMD_RET_USAGE;
@@ -342,7 +342,7 @@ static int do_tpm_extend(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_pcr_read(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t index, count, rc;
+	u32 index, count, rc;
 	void *data;
 
 	if (argc != 4)
@@ -363,11 +363,11 @@ static int do_tpm_pcr_read(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_tsc_physical_presence(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint16_t presence;
+	u16 presence;
 
 	if (argc != 2)
 		return CMD_RET_USAGE;
-	presence = (uint16_t)simple_strtoul(argv[1], NULL, 0);
+	presence = (u16)simple_strtoul(argv[1], NULL, 0);
 
 	return report_return_code(tpm_tsc_physical_presence(presence));
 }
@@ -375,7 +375,7 @@ static int do_tpm_tsc_physical_presence(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_read_pubek(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t count, rc;
+	u32 count, rc;
 	void *data;
 
 	if (argc != 3)
@@ -395,11 +395,11 @@ static int do_tpm_read_pubek(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_physical_set_deactivated(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint8_t state;
+	u8 state;
 
 	if (argc != 2)
 		return CMD_RET_USAGE;
-	state = (uint8_t)simple_strtoul(argv[1], NULL, 0);
+	state = (u8)simple_strtoul(argv[1], NULL, 0);
 
 	return report_return_code(tpm_physical_set_deactivated(state));
 }
@@ -407,7 +407,7 @@ static int do_tpm_physical_set_deactivated(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_get_capability(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t cap_area, sub_cap, rc;
+	u32 cap_area, sub_cap, rc;
 	void *cap;
 	size_t count;
 
@@ -481,9 +481,9 @@ static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag,
 {
 	struct udevice *dev;
 	void *command;
-	uint8_t response[1024];
+	u8 response[1024];
 	size_t count, response_length = sizeof(response);
-	uint32_t rc;
+	u32 rc;
 
 	command = parse_byte_string(argv[1], NULL, &count);
 	if (!command) {
@@ -508,7 +508,7 @@ static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_nv_define(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t index, perm, size;
+	u32 index, perm, size;
 
 	if (argc != 4)
 		return CMD_RET_USAGE;
@@ -526,7 +526,7 @@ static int do_tpm_nv_define(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_nv_read(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t index, count, err;
+	u32 index, count, err;
 	void *data;
 
 	if (argc < 3)
@@ -555,7 +555,7 @@ static int do_tpm_nv_read(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_nv_write(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t index, count, err;
+	u32 index, count, err;
 	void *data;
 
 	if (argc < 3)
@@ -585,7 +585,7 @@ static int do_tpm_nv_write(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_oiap(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t auth_handle, err;
+	u32 auth_handle, err;
 
 	err = tpm_oiap(&auth_handle);
 
@@ -596,10 +596,10 @@ static int do_tpm_oiap(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_load_key_by_sha1(cmd_tbl_t *cmdtp, int flag, int argc, char *
 				   const argv[])
 {
-	uint32_t parent_handle = 0;
-	uint32_t key_len, key_handle, err;
-	uint8_t usage_auth[DIGEST_LENGTH];
-	uint8_t parent_hash[DIGEST_LENGTH];
+	u32 parent_handle = 0;
+	u32 key_len, key_handle, err;
+	u8 usage_auth[DIGEST_LENGTH];
+	u8 parent_hash[DIGEST_LENGTH];
 	void *key;
 
 	if (argc < 5)
@@ -634,8 +634,8 @@ static int do_tpm_load_key_by_sha1(cmd_tbl_t *cmdtp, int flag, int argc, char *
 static int do_tpm_load_key2_oiap(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t parent_handle, key_len, key_handle, err;
-	uint8_t usage_auth[DIGEST_LENGTH];
+	u32 parent_handle, key_len, key_handle, err;
+	u8 usage_auth[DIGEST_LENGTH];
 	void *key;
 
 	if (argc < 5)
@@ -659,9 +659,9 @@ static int do_tpm_load_key2_oiap(cmd_tbl_t *cmdtp, int flag,
 static int do_tpm_get_pub_key_oiap(cmd_tbl_t *cmdtp, int flag,
 		int argc, char * const argv[])
 {
-	uint32_t key_handle, err;
-	uint8_t usage_auth[DIGEST_LENGTH];
-	uint8_t pub_key_buffer[TPM_PUBKEY_MAX_LENGTH];
+	u32 key_handle, err;
+	u8 usage_auth[DIGEST_LENGTH];
+	u8 pub_key_buffer[TPM_PUBKEY_MAX_LENGTH];
 	size_t pub_key_len = sizeof(pub_key_buffer);
 
 	if (argc < 3)
@@ -721,9 +721,9 @@ static int do_tpm_flush(cmd_tbl_t *cmdtp, int flag, int argc,
 	}
 
 	if (!strcasecmp(argv[2], "all")) {
-		uint16_t res_count;
-		uint8_t buf[288];
-		uint8_t *ptr;
+		u16 res_count;
+		u8 buf[288];
+		u8 *ptr;
 		int err;
 		uint i;
 
@@ -739,7 +739,7 @@ static int do_tpm_flush(cmd_tbl_t *cmdtp, int flag, int argc,
 		for (i = 0; i < res_count; ++i, ptr += 4)
 			tpm_flush_specific(get_unaligned_be32(ptr), type);
 	} else {
-		uint32_t handle = simple_strtoul(argv[2], NULL, 0);
+		u32 handle = simple_strtoul(argv[2], NULL, 0);
 
 		if (!handle) {
 			printf("Illegal resource handle %s\n", argv[2]);
@@ -757,9 +757,9 @@ static int do_tpm_list(cmd_tbl_t *cmdtp, int flag, int argc,
 		       char * const argv[])
 {
 	int type = 0;
-	uint16_t res_count;
-	uint8_t buf[288];
-	uint8_t *ptr;
+	u16 res_count;
+	u8 buf[288];
+	u8 *ptr;
 	int err;
 	uint i;
 
diff --git a/include/tpm.h b/include/tpm.h
index 760d94865c..62117f6cc2 100644
--- a/include/tpm.h
+++ b/include/tpm.h
@@ -309,8 +309,7 @@ struct tpm_ops {
 	 *
 	 * Returns 0 on success or -ve on failure.
 	 */
-	int (*send)(struct udevice *dev, const uint8_t *sendbuf,
-		    size_t send_size);
+	int (*send)(struct udevice *dev, const u8 *sendbuf, size_t send_size);
 
 	/**
 	 * recv() - receive a response from the TPM
@@ -323,7 +322,7 @@ struct tpm_ops {
 	 * response is not ready, -EINTR if cancelled, or other -ve value on
 	 * failure.
 	 */
-	int (*recv)(struct udevice *dev, uint8_t *recvbuf, size_t max_size);
+	int (*recv)(struct udevice *dev, u8 *recvbuf, size_t max_size);
 
 	/**
 	 * cleanup() - clean up after an operation in progress
@@ -352,8 +351,8 @@ struct tpm_ops {
 	 * Returns 0 on success (and places the number of response bytes at
 	 * recv_size) or -ve on failure.
 	 */
-	int (*xfer)(struct udevice *dev, const uint8_t *sendbuf,
-		    size_t send_size, uint8_t *recvbuf, size_t *recv_size);
+	int (*xfer)(struct udevice *dev, const u8 *sendbuf, size_t send_size,
+		    u8 *recvbuf, size_t *recv_size);
 };
 
 #define tpm_get_ops(dev)        ((struct tpm_ops *)device_get_ops(dev))
@@ -407,8 +406,8 @@ int tpm_get_desc(struct udevice *dev, char *buf, int size);
  * Returns 0 on success (and places the number of response bytes at
  * recv_len) or -ve on failure.
  */
-int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size,
-	     uint8_t *recvbuf, size_t *recv_size);
+int tpm_xfer(struct udevice *dev, const u8 *sendbuf, size_t send_size,
+	     u8 *recvbuf, size_t *recv_size);
 
 /**
  * Initialize TPM device.  It must be called before any TPM commands.
@@ -423,21 +422,21 @@ int tpm_init(void);
  * @param mode		TPM startup mode
  * @return return code of the operation
  */
-uint32_t tpm_startup(enum tpm_startup_type mode);
+u32 tpm_startup(enum tpm_startup_type mode);
 
 /**
  * Issue a TPM_SelfTestFull command.
  *
  * @return return code of the operation
  */
-uint32_t tpm_self_test_full(void);
+u32 tpm_self_test_full(void);
 
 /**
  * Issue a TPM_ContinueSelfTest command.
  *
  * @return return code of the operation
  */
-uint32_t tpm_continue_self_test(void);
+u32 tpm_continue_self_test(void);
 
 /**
  * Issue a TPM_NV_DefineSpace command.  The implementation is limited
@@ -449,7 +448,7 @@ uint32_t tpm_continue_self_test(void);
  * @param size		size of the area
  * @return return code of the operation
  */
-uint32_t tpm_nv_define_space(uint32_t index, uint32_t perm, uint32_t size);
+u32 tpm_nv_define_space(u32 index, u32 perm, u32 size);
 
 /**
  * Issue a TPM_NV_ReadValue command.  This implementation is limited
@@ -461,7 +460,7 @@ uint32_t tpm_nv_define_space(uint32_t index, uint32_t perm, uint32_t size);
  * @param count		size of output buffer
  * @return return code of the operation
  */
-uint32_t tpm_nv_read_value(uint32_t index, void *data, uint32_t count);
+u32 tpm_nv_read_value(u32 index, void *data, u32 count);
 
 /**
  * Issue a TPM_NV_WriteValue command.  This implementation is limited
@@ -473,7 +472,7 @@ uint32_t tpm_nv_read_value(uint32_t index, void *data, uint32_t count);
  * @param length	length of data bytes of input buffer
  * @return return code of the operation
  */
-uint32_t tpm_nv_write_value(uint32_t index, const void *data, uint32_t length);
+u32 tpm_nv_write_value(u32 index, const void *data, u32 length);
 
 /**
  * Issue a TPM_Extend command.
@@ -485,7 +484,7 @@ uint32_t tpm_nv_write_value(uint32_t index, const void *data, uint32_t length);
  *			command
  * @return return code of the operation
  */
-uint32_t tpm_extend(uint32_t index, const void *in_digest, void *out_digest);
+u32 tpm_extend(u32 index, const void *in_digest, void *out_digest);
 
 /**
  * Issue a TPM_PCRRead command.
@@ -495,7 +494,7 @@ uint32_t tpm_extend(uint32_t index, const void *in_digest, void *out_digest);
  * @param count		size of output buffer
  * @return return code of the operation
  */
-uint32_t tpm_pcr_read(uint32_t index, void *data, size_t count);
+u32 tpm_pcr_read(u32 index, void *data, size_t count);
 
 /**
  * Issue a TSC_PhysicalPresence command.  TPM physical presence flag
@@ -504,7 +503,7 @@ uint32_t tpm_pcr_read(uint32_t index, void *data, size_t count);
  * @param presence	TPM physical presence flag
  * @return return code of the operation
  */
-uint32_t tpm_tsc_physical_presence(uint16_t presence);
+u32 tpm_tsc_physical_presence(u16 presence);
 
 /**
  * Issue a TPM_ReadPubek command.
@@ -513,28 +512,28 @@ uint32_t tpm_tsc_physical_presence(uint16_t presence);
  * @param count		size of ouput buffer
  * @return return code of the operation
  */
-uint32_t tpm_read_pubek(void *data, size_t count);
+u32 tpm_read_pubek(void *data, size_t count);
 
 /**
  * Issue a TPM_ForceClear command.
  *
  * @return return code of the operation
  */
-uint32_t tpm_force_clear(void);
+u32 tpm_force_clear(void);
 
 /**
  * Issue a TPM_PhysicalEnable command.
  *
  * @return return code of the operation
  */
-uint32_t tpm_physical_enable(void);
+u32 tpm_physical_enable(void);
 
 /**
  * Issue a TPM_PhysicalDisable command.
  *
  * @return return code of the operation
  */
-uint32_t tpm_physical_disable(void);
+u32 tpm_physical_disable(void);
 
 /**
  * Issue a TPM_PhysicalSetDeactivated command.
@@ -542,7 +541,7 @@ uint32_t tpm_physical_disable(void);
  * @param state		boolean state of the deactivated flag
  * @return return code of the operation
  */
-uint32_t tpm_physical_set_deactivated(uint8_t state);
+u32 tpm_physical_set_deactivated(u8 state);
 
 /**
  * Issue a TPM_GetCapability command.  This implementation is limited
@@ -555,8 +554,7 @@ uint32_t tpm_physical_set_deactivated(uint8_t state);
  * @param count		size of ouput buffer
  * @return return code of the operation
  */
-uint32_t tpm_get_capability(uint32_t cap_area, uint32_t sub_cap,
-		void *cap, size_t count);
+u32 tpm_get_capability(u32 cap_area, u32 sub_cap, void *cap, size_t count);
 
 /**
  * Issue a TPM_FlushSpecific command for a AUTH ressource.
@@ -564,7 +562,7 @@ uint32_t tpm_get_capability(uint32_t cap_area, uint32_t sub_cap,
  * @param auth_handle	handle of the auth session
  * @return return code of the operation
  */
-uint32_t tpm_terminate_auth_session(uint32_t auth_handle);
+u32 tpm_terminate_auth_session(u32 auth_handle);
 
 /**
  * Issue a TPM_OIAP command to setup an object independant authorization
@@ -576,14 +574,14 @@ uint32_t tpm_terminate_auth_session(uint32_t auth_handle);
  * @param auth_handle	pointer to the (new) auth handle or NULL.
  * @return return code of the operation
  */
-uint32_t tpm_oiap(uint32_t *auth_handle);
+u32 tpm_oiap(u32 *auth_handle);
 
 /**
  * Ends an active OIAP session.
  *
  * @return return code of the operation
  */
-uint32_t tpm_end_oiap(void);
+u32 tpm_end_oiap(void);
 
 /**
  * Issue a TPM_LoadKey2 (Auth1) command using an OIAP session for authenticating
@@ -596,10 +594,8 @@ uint32_t tpm_end_oiap(void);
  * @param key_handle	pointer to the key handle
  * @return return code of the operation
  */
-uint32_t tpm_load_key2_oiap(uint32_t parent_handle,
-		const void *key, size_t key_length,
-		const void *parent_key_usage_auth,
-		uint32_t *key_handle);
+u32 tpm_load_key2_oiap(u32 parent_handle, const void *key, size_t key_length,
+		       const void *parent_key_usage_auth, u32 *key_handle);
 
 /**
  * Issue a TPM_GetPubKey (Auth1) command using an OIAP session for
@@ -614,8 +610,8 @@ uint32_t tpm_load_key2_oiap(uint32_t parent_handle,
  *			of the stored TPM_PUBKEY structure (iff pubkey != NULL).
  * @return return code of the operation
  */
-uint32_t tpm_get_pub_key_oiap(uint32_t key_handle, const void *usage_auth,
-		void *pubkey, size_t *pubkey_len);
+u32 tpm_get_pub_key_oiap(u32 key_handle, const void *usage_auth, void *pubkey,
+			 size_t *pubkey_len);
 
 /**
  * Get the TPM permanent flags value
@@ -623,7 +619,7 @@ uint32_t tpm_get_pub_key_oiap(uint32_t key_handle, const void *usage_auth,
  * @param pflags	Place to put permanent flags
  * @return return code of the operation
  */
-uint32_t tpm_get_permanent_flags(struct tpm_permanent_flags *pflags);
+u32 tpm_get_permanent_flags(struct tpm_permanent_flags *pflags);
 
 /**
  * Get the TPM permissions
@@ -631,7 +627,7 @@ uint32_t tpm_get_permanent_flags(struct tpm_permanent_flags *pflags);
  * @param perm		Returns permissions value
  * @return return code of the operation
  */
-uint32_t tpm_get_permissions(uint32_t index, uint32_t *perm);
+u32 tpm_get_permissions(u32 index, u32 *perm);
 
 /**
  * Flush a resource with a given handle and type from the TPM
@@ -640,7 +636,7 @@ uint32_t tpm_get_permissions(uint32_t index, uint32_t *perm);
  * @param resource_type                type of the resource
  * @return return code of the operation
  */
-uint32_t tpm_flush_specific(uint32_t key_handle, uint32_t resource_type);
+u32 tpm_flush_specific(u32 key_handle, u32 resource_type);
 
 #ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
 /**
@@ -651,8 +647,8 @@ uint32_t tpm_flush_specific(uint32_t key_handle, uint32_t resource_type);
  * @param[out] handle	The handle of the key (Non-null iff found)
  * @return 0 if key was found in TPM; != 0 if not.
  */
-uint32_t tpm_find_key_sha1(const uint8_t auth[20], const uint8_t
-			   pubkey_digest[20], uint32_t *handle);
+u32 tpm_find_key_sha1(const u8 auth[20], const u8 pubkey_digest[20],
+		      u32 *handle);
 #endif /* CONFIG_TPM_LOAD_KEY_BY_SHA1 */
 
 /**
@@ -664,6 +660,6 @@ uint32_t tpm_find_key_sha1(const uint8_t auth[20], const uint8_t
  * @param count		size of output buffer
  * @return return code of the operation
  */
-uint32_t tpm_get_random(void *data, uint32_t count);
+u32 tpm_get_random(void *data, u32 count);
 
 #endif /* __TPM_H */
diff --git a/lib/tpm.c b/lib/tpm.c
index 58b0a76b97..1c4ce2e71d 100644
--- a/lib/tpm.c
+++ b/lib/tpm.c
@@ -12,7 +12,7 @@
 #include <u-boot/sha1.h>
 
 /* Internal error of TPM command library */
-#define TPM_LIB_ERROR	((uint32_t)~0u)
+#define TPM_LIB_ERROR	((u32)~0u)
 
 /* Useful constants */
 enum {
@@ -36,9 +36,9 @@ enum {
 
 struct session_data {
 	int		valid;
-	uint32_t	handle;
-	uint8_t		nonce_even[DIGEST_LENGTH];
-	uint8_t		nonce_odd[DIGEST_LENGTH];
+	u32	handle;
+	u8		nonce_even[DIGEST_LENGTH];
+	u8		nonce_odd[DIGEST_LENGTH];
 };
 
 static struct session_data oiap_session = {0, };
@@ -60,12 +60,12 @@ static struct session_data oiap_session = {0, };
  * @param ...		data points
  * @return 0 on success, non-0 on error
  */
-int pack_byte_string(uint8_t *str, size_t size, const char *format, ...)
+int pack_byte_string(u8 *str, size_t size, const char *format, ...)
 {
 	va_list args;
 	size_t offset = 0, length = 0;
-	uint8_t *data = NULL;
-	uint32_t value = 0;
+	u8 *data = NULL;
+	u32 value = 0;
 
 	va_start(args, format);
 	for (; *format; format++) {
@@ -82,13 +82,13 @@ int pack_byte_string(uint8_t *str, size_t size, const char *format, ...)
 			break;
 		case 'd':
 			offset = va_arg(args, size_t);
-			value = va_arg(args, uint32_t);
+			value = va_arg(args, u32);
 			length = 4;
 			break;
 		case 's':
 			offset = va_arg(args, size_t);
-			data = va_arg(args, uint8_t *);
-			length = va_arg(args, uint32_t);
+			data = va_arg(args, u8 *);
+			length = va_arg(args, u32);
 			break;
 		default:
 			debug("Couldn't recognize format string\n");
@@ -134,36 +134,36 @@ int pack_byte_string(uint8_t *str, size_t size, const char *format, ...)
  * @param ...		data points
  * @return 0 on success, non-0 on error
  */
-int unpack_byte_string(const uint8_t *str, size_t size, const char *format, ...)
+int unpack_byte_string(const u8 *str, size_t size, const char *format, ...)
 {
 	va_list args;
 	size_t offset = 0, length = 0;
-	uint8_t *ptr8 = NULL;
-	uint16_t *ptr16 = NULL;
-	uint32_t *ptr32 = NULL;
+	u8 *ptr8 = NULL;
+	u16 *ptr16 = NULL;
+	u32 *ptr32 = NULL;
 
 	va_start(args, format);
 	for (; *format; format++) {
 		switch (*format) {
 		case 'b':
 			offset = va_arg(args, size_t);
-			ptr8 = va_arg(args, uint8_t *);
+			ptr8 = va_arg(args, u8 *);
 			length = 1;
 			break;
 		case 'w':
 			offset = va_arg(args, size_t);
-			ptr16 = va_arg(args, uint16_t *);
+			ptr16 = va_arg(args, u16 *);
 			length = 2;
 			break;
 		case 'd':
 			offset = va_arg(args, size_t);
-			ptr32 = va_arg(args, uint32_t *);
+			ptr32 = va_arg(args, u32 *);
 			length = 4;
 			break;
 		case 's':
 			offset = va_arg(args, size_t);
-			ptr8 = va_arg(args, uint8_t *);
-			length = va_arg(args, uint32_t);
+			ptr8 = va_arg(args, u8 *);
+			length = va_arg(args, u32);
 			break;
 		default:
 			va_end(args);
@@ -202,7 +202,7 @@ int unpack_byte_string(const uint8_t *str, size_t size, const char *format, ...)
  * @param command	byte string of TPM command
  * @return command size of the TPM command
  */
-static uint32_t tpm_command_size(const void *command)
+static u32 tpm_command_size(const void *command)
 {
 	const size_t command_size_offset = 2;
 	return get_unaligned_be32(command + command_size_offset);
@@ -214,7 +214,7 @@ static uint32_t tpm_command_size(const void *command)
  * @param response	byte string of TPM response
  * @return return code of the TPM response
  */
-static uint32_t tpm_return_code(const void *response)
+static u32 tpm_return_code(const void *response)
 {
 	const size_t return_code_offset = 6;
 	return get_unaligned_be32(response + return_code_offset);
@@ -232,12 +232,12 @@ static uint32_t tpm_return_code(const void *response)
  *			is a bidirectional
  * @return return code of the TPM response
  */
-static uint32_t tpm_sendrecv_command(const void *command,
-		void *response, size_t *size_ptr)
+static u32 tpm_sendrecv_command(const void *command, void *response,
+				size_t *size_ptr)
 {
 	struct udevice *dev;
 	int err, ret;
-	uint8_t response_buffer[COMMAND_BUFFER_SIZE];
+	u8 response_buffer[COMMAND_BUFFER_SIZE];
 	size_t response_length;
 
 	if (response) {
@@ -272,13 +272,13 @@ int tpm_init(void)
 	return tpm_open(dev);
 }
 
-uint32_t tpm_startup(enum tpm_startup_type mode)
+u32 tpm_startup(enum tpm_startup_type mode)
 {
-	const uint8_t command[12] = {
+	const u8 command[12] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x99, 0x0, 0x0,
 	};
 	const size_t mode_offset = 10;
-	uint8_t buf[COMMAND_BUFFER_SIZE];
+	u8 buf[COMMAND_BUFFER_SIZE];
 
 	if (pack_byte_string(buf, sizeof(buf), "sw",
 				0, command, sizeof(command),
@@ -288,25 +288,25 @@ uint32_t tpm_startup(enum tpm_startup_type mode)
 	return tpm_sendrecv_command(buf, NULL, NULL);
 }
 
-uint32_t tpm_self_test_full(void)
+u32 tpm_self_test_full(void)
 {
-	const uint8_t command[10] = {
+	const u8 command[10] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x50,
 	};
 	return tpm_sendrecv_command(command, NULL, NULL);
 }
 
-uint32_t tpm_continue_self_test(void)
+u32 tpm_continue_self_test(void)
 {
-	const uint8_t command[10] = {
+	const u8 command[10] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x53,
 	};
 	return tpm_sendrecv_command(command, NULL, NULL);
 }
 
-uint32_t tpm_nv_define_space(uint32_t index, uint32_t perm, uint32_t size)
+u32 tpm_nv_define_space(u32 index, u32 perm, u32 size)
 {
-	const uint8_t command[101] = {
+	const u8 command[101] = {
 		0x0, 0xc1,		/* TPM_TAG */
 		0x0, 0x0, 0x0, 0x65,	/* parameter size */
 		0x0, 0x0, 0x0, 0xcc,	/* TPM_COMMAND_CODE */
@@ -335,7 +335,7 @@ uint32_t tpm_nv_define_space(uint32_t index, uint32_t perm, uint32_t size)
 	const size_t index_offset = 12;
 	const size_t perm_offset = 70;
 	const size_t size_offset = 77;
-	uint8_t buf[COMMAND_BUFFER_SIZE];
+	u8 buf[COMMAND_BUFFER_SIZE];
 
 	if (pack_byte_string(buf, sizeof(buf), "sddd",
 				0, command, sizeof(command),
@@ -347,19 +347,19 @@ uint32_t tpm_nv_define_space(uint32_t index, uint32_t perm, uint32_t size)
 	return tpm_sendrecv_command(buf, NULL, NULL);
 }
 
-uint32_t tpm_nv_read_value(uint32_t index, void *data, uint32_t count)
+u32 tpm_nv_read_value(u32 index, void *data, u32 count)
 {
-	const uint8_t command[22] = {
+	const u8 command[22] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0x16, 0x0, 0x0, 0x0, 0xcf,
 	};
 	const size_t index_offset = 10;
 	const size_t length_offset = 18;
 	const size_t data_size_offset = 10;
 	const size_t data_offset = 14;
-	uint8_t buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
+	u8 buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
 	size_t response_length = sizeof(response);
-	uint32_t data_size;
-	uint32_t err;
+	u32 data_size;
+	u32 err;
 
 	if (pack_byte_string(buf, sizeof(buf), "sdd",
 				0, command, sizeof(command),
@@ -381,9 +381,9 @@ uint32_t tpm_nv_read_value(uint32_t index, void *data, uint32_t count)
 	return 0;
 }
 
-uint32_t tpm_nv_write_value(uint32_t index, const void *data, uint32_t length)
+u32 tpm_nv_write_value(u32 index, const void *data, u32 length)
 {
-	const uint8_t command[256] = {
+	const u8 command[256] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xcd,
 	};
 	const size_t command_size_offset = 2;
@@ -391,11 +391,11 @@ uint32_t tpm_nv_write_value(uint32_t index, const void *data, uint32_t length)
 	const size_t length_offset = 18;
 	const size_t data_offset = 22;
 	const size_t write_info_size = 12;
-	const uint32_t total_length =
+	const u32 total_length =
 		TPM_REQUEST_HEADER_LENGTH + write_info_size + length;
-	uint8_t buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
+	u8 buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
 	size_t response_length = sizeof(response);
-	uint32_t err;
+	u32 err;
 
 	if (pack_byte_string(buf, sizeof(buf), "sddds",
 				0, command, sizeof(command),
@@ -411,18 +411,18 @@ uint32_t tpm_nv_write_value(uint32_t index, const void *data, uint32_t length)
 	return 0;
 }
 
-uint32_t tpm_extend(uint32_t index, const void *in_digest, void *out_digest)
+u32 tpm_extend(u32 index, const void *in_digest, void *out_digest)
 {
-	const uint8_t command[34] = {
+	const u8 command[34] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0x22, 0x0, 0x0, 0x0, 0x14,
 	};
 	const size_t index_offset = 10;
 	const size_t in_digest_offset = 14;
 	const size_t out_digest_offset = 10;
-	uint8_t buf[COMMAND_BUFFER_SIZE];
-	uint8_t response[TPM_RESPONSE_HEADER_LENGTH + PCR_DIGEST_LENGTH];
+	u8 buf[COMMAND_BUFFER_SIZE];
+	u8 response[TPM_RESPONSE_HEADER_LENGTH + PCR_DIGEST_LENGTH];
 	size_t response_length = sizeof(response);
-	uint32_t err;
+	u32 err;
 
 	if (pack_byte_string(buf, sizeof(buf), "sds",
 				0, command, sizeof(command),
@@ -442,16 +442,16 @@ uint32_t tpm_extend(uint32_t index, const void *in_digest, void *out_digest)
 	return 0;
 }
 
-uint32_t tpm_pcr_read(uint32_t index, void *data, size_t count)
+u32 tpm_pcr_read(u32 index, void *data, size_t count)
 {
-	const uint8_t command[14] = {
+	const u8 command[14] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0xe, 0x0, 0x0, 0x0, 0x15,
 	};
 	const size_t index_offset = 10;
 	const size_t out_digest_offset = 10;
-	uint8_t buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
+	u8 buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
 	size_t response_length = sizeof(response);
-	uint32_t err;
+	u32 err;
 
 	if (count < PCR_DIGEST_LENGTH)
 		return TPM_LIB_ERROR;
@@ -470,13 +470,13 @@ uint32_t tpm_pcr_read(uint32_t index, void *data, size_t count)
 	return 0;
 }
 
-uint32_t tpm_tsc_physical_presence(uint16_t presence)
+u32 tpm_tsc_physical_presence(u16 presence)
 {
-	const uint8_t command[12] = {
+	const u8 command[12] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0xc, 0x40, 0x0, 0x0, 0xa, 0x0, 0x0,
 	};
 	const size_t presence_offset = 10;
-	uint8_t buf[COMMAND_BUFFER_SIZE];
+	u8 buf[COMMAND_BUFFER_SIZE];
 
 	if (pack_byte_string(buf, sizeof(buf), "sw",
 				0, command, sizeof(command),
@@ -486,18 +486,18 @@ uint32_t tpm_tsc_physical_presence(uint16_t presence)
 	return tpm_sendrecv_command(buf, NULL, NULL);
 }
 
-uint32_t tpm_read_pubek(void *data, size_t count)
+u32 tpm_read_pubek(void *data, size_t count)
 {
-	const uint8_t command[30] = {
+	const u8 command[30] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0x1e, 0x0, 0x0, 0x0, 0x7c,
 	};
 	const size_t response_size_offset = 2;
 	const size_t data_offset = 10;
 	const size_t header_and_checksum_size = TPM_RESPONSE_HEADER_LENGTH + 20;
-	uint8_t response[COMMAND_BUFFER_SIZE + TPM_PUBEK_SIZE];
+	u8 response[COMMAND_BUFFER_SIZE + TPM_PUBEK_SIZE];
 	size_t response_length = sizeof(response);
-	uint32_t data_size;
-	uint32_t err;
+	u32 data_size;
+	u32 err;
 
 	err = tpm_sendrecv_command(command, response, &response_length);
 	if (err)
@@ -517,40 +517,40 @@ uint32_t tpm_read_pubek(void *data, size_t count)
 	return 0;
 }
 
-uint32_t tpm_force_clear(void)
+u32 tpm_force_clear(void)
 {
-	const uint8_t command[10] = {
+	const u8 command[10] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x5d,
 	};
 
 	return tpm_sendrecv_command(command, NULL, NULL);
 }
 
-uint32_t tpm_physical_enable(void)
+u32 tpm_physical_enable(void)
 {
-	const uint8_t command[10] = {
+	const u8 command[10] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x6f,
 	};
 
 	return tpm_sendrecv_command(command, NULL, NULL);
 }
 
-uint32_t tpm_physical_disable(void)
+u32 tpm_physical_disable(void)
 {
-	const uint8_t command[10] = {
+	const u8 command[10] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0x70,
 	};
 
 	return tpm_sendrecv_command(command, NULL, NULL);
 }
 
-uint32_t tpm_physical_set_deactivated(uint8_t state)
+u32 tpm_physical_set_deactivated(u8 state)
 {
-	const uint8_t command[11] = {
+	const u8 command[11] = {
 		0x0, 0xc1, 0x0, 0x0, 0x0, 0xb, 0x0, 0x0, 0x0, 0x72,
 	};
 	const size_t state_offset = 10;
-	uint8_t buf[COMMAND_BUFFER_SIZE];
+	u8 buf[COMMAND_BUFFER_SIZE];
 
 	if (pack_byte_string(buf, sizeof(buf), "sb",
 				0, command, sizeof(command),
@@ -560,10 +560,9 @@ uint32_t tpm_physical_set_deactivated(uint8_t state)
 	return tpm_sendrecv_command(buf, NULL, NULL);
 }
 
-uint32_t tpm_get_capability(uint32_t cap_area, uint32_t sub_cap,
-		void *cap, size_t count)
+u32 tpm_get_capability(u32 cap_area, u32 sub_cap, void *cap, size_t count)
 {
-	const uint8_t command[22] = {
+	const u8 command[22] = {
 		0x0, 0xc1,		/* TPM_TAG */
 		0x0, 0x0, 0x0, 0x16,	/* parameter size */
 		0x0, 0x0, 0x0, 0x65,	/* TPM_COMMAND_CODE */
@@ -575,10 +574,10 @@ uint32_t tpm_get_capability(uint32_t cap_area, uint32_t sub_cap,
 	const size_t sub_cap_offset = 18;
 	const size_t cap_offset = 14;
 	const size_t cap_size_offset = 10;
-	uint8_t buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
+	u8 buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
 	size_t response_length = sizeof(response);
-	uint32_t cap_size;
-	uint32_t err;
+	u32 cap_size;
+	u32 err;
 
 	if (pack_byte_string(buf, sizeof(buf), "sdd",
 				0, command, sizeof(command),
@@ -600,9 +599,9 @@ uint32_t tpm_get_capability(uint32_t cap_area, uint32_t sub_cap,
 	return 0;
 }
 
-uint32_t tpm_get_permanent_flags(struct tpm_permanent_flags *pflags)
+u32 tpm_get_permanent_flags(struct tpm_permanent_flags *pflags)
 {
-	const uint8_t command[22] = {
+	const u8 command[22] = {
 		0x0, 0xc1,		/* TPM_TAG */
 		0x0, 0x0, 0x0, 0x16,	/* parameter size */
 		0x0, 0x0, 0x0, 0x65,	/* TPM_COMMAND_CODE */
@@ -611,11 +610,11 @@ uint32_t tpm_get_permanent_flags(struct tpm_permanent_flags *pflags)
 		0x0, 0x0, 0x1, 0x8,	/* subcap value */
 	};
 	const size_t data_size_offset = TPM_HEADER_SIZE;
-	const size_t data_offset = TPM_HEADER_SIZE + sizeof(uint32_t);
-	uint8_t response[COMMAND_BUFFER_SIZE];
+	const size_t data_offset = TPM_HEADER_SIZE + sizeof(u32);
+	u8 response[COMMAND_BUFFER_SIZE];
 	size_t response_length = sizeof(response);
-	uint32_t err;
-	uint32_t data_size;
+	u32 err;
+	u32 data_size;
 
 	err = tpm_sendrecv_command(command, response, &response_length);
 	if (err)
@@ -632,9 +631,9 @@ uint32_t tpm_get_permanent_flags(struct tpm_permanent_flags *pflags)
 	return 0;
 }
 
-uint32_t tpm_get_permissions(uint32_t index, uint32_t *perm)
+u32 tpm_get_permissions(u32 index, u32 *perm)
 {
-	const uint8_t command[22] = {
+	const u8 command[22] = {
 		0x0, 0xc1,		/* TPM_TAG */
 		0x0, 0x0, 0x0, 0x16,	/* parameter size */
 		0x0, 0x0, 0x0, 0x65,	/* TPM_COMMAND_CODE */
@@ -643,9 +642,9 @@ uint32_t tpm_get_permissions(uint32_t index, uint32_t *perm)
 	};
 	const size_t index_offset = 18;
 	const size_t perm_offset = 60;
-	uint8_t buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
+	u8 buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
 	size_t response_length = sizeof(response);
-	uint32_t err;
+	u32 err;
 
 	if (pack_byte_string(buf, sizeof(buf), "d", 0, command, sizeof(command),
 			     index_offset, index))
@@ -661,9 +660,9 @@ uint32_t tpm_get_permissions(uint32_t index, uint32_t *perm)
 }
 
 #ifdef CONFIG_TPM_FLUSH_RESOURCES
-uint32_t tpm_flush_specific(uint32_t key_handle, uint32_t resource_type)
+u32 tpm_flush_specific(u32 key_handle, u32 resource_type)
 {
-	const uint8_t command[18] = {
+	const u8 command[18] = {
 		0x00, 0xc1,             /* TPM_TAG */
 		0x00, 0x00, 0x00, 0x12, /* parameter size */
 		0x00, 0x00, 0x00, 0xba, /* TPM_COMMAND_CODE */
@@ -672,9 +671,9 @@ uint32_t tpm_flush_specific(uint32_t key_handle, uint32_t resource_type)
 	};
 	const size_t key_handle_offset = 10;
 	const size_t resource_type_offset = 14;
-	uint8_t buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
+	u8 buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
 	size_t response_length = sizeof(response);
-	uint32_t err;
+	u32 err;
 
 	if (pack_byte_string(buf, sizeof(buf), "sdd",
 			     0, command, sizeof(command),
@@ -703,12 +702,12 @@ uint32_t tpm_flush_specific(uint32_t key_handle, uint32_t resource_type)
  * @param request_auth	pointer to the auth block of the request to be filled
  * @param auth		authentication data (HMAC key)
  */
-static uint32_t create_request_auth(const void *request, size_t request_len0,
-	size_t handles_len,
-	struct session_data *auth_session,
-	void *request_auth, const void *auth)
+static u32 create_request_auth(const void *request, size_t request_len0,
+			       size_t handles_len,
+			       struct session_data *auth_session,
+			       void *request_auth, const void *auth)
 {
-	uint8_t hmac_data[DIGEST_LENGTH * 3 + 1];
+	u8 hmac_data[DIGEST_LENGTH * 3 + 1];
 	sha1_context hash_ctx;
 	const size_t command_code_offset = 6;
 	const size_t auth_nonce_odd_offset = 4;
@@ -766,19 +765,18 @@ static uint32_t create_request_auth(const void *request, size_t request_len0,
  * @param response_auth	pointer to the auth block of the response to be verified
  * @param auth		authentication data (HMAC key)
  */
-static uint32_t verify_response_auth(uint32_t command_code,
-	const void *response, size_t response_len0,
-	size_t handles_len,
-	struct session_data *auth_session,
-	const void *response_auth, const void *auth)
+static u32 verify_response_auth(u32 command_code, const void *response,
+				size_t response_len0, size_t handles_len,
+				struct session_data *auth_session,
+				const void *response_auth, const void *auth)
 {
-	uint8_t hmac_data[DIGEST_LENGTH * 3 + 1];
-	uint8_t computed_auth[DIGEST_LENGTH];
+	u8 hmac_data[DIGEST_LENGTH * 3 + 1];
+	u8 computed_auth[DIGEST_LENGTH];
 	sha1_context hash_ctx;
 	const size_t return_code_offset = 6;
 	const size_t auth_continue_offset = 20;
 	const size_t auth_auth_offset = 21;
-	uint8_t auth_continue;
+	u8 auth_continue;
 
 	if (!auth_session || !auth_session->valid)
 		return TPM_AUTHFAIL;
@@ -799,7 +797,7 @@ static uint32_t verify_response_auth(uint32_t command_code,
 	sha1_finish(&hash_ctx, hmac_data);
 
 	memcpy(auth_session->nonce_even, response_auth, DIGEST_LENGTH);
-	auth_continue = ((uint8_t *)response_auth)[auth_continue_offset];
+	auth_continue = ((u8 *)response_auth)[auth_continue_offset];
 	if (pack_byte_string(hmac_data, sizeof(hmac_data), "ssb",
 			     DIGEST_LENGTH,
 			     response_auth,
@@ -821,9 +819,9 @@ static uint32_t verify_response_auth(uint32_t command_code,
 	return TPM_SUCCESS;
 }
 
-uint32_t tpm_terminate_auth_session(uint32_t auth_handle)
+u32 tpm_terminate_auth_session(u32 auth_handle)
 {
-	const uint8_t command[18] = {
+	const u8 command[18] = {
 		0x00, 0xc1,		/* TPM_TAG */
 		0x00, 0x00, 0x00, 0x00,	/* parameter size */
 		0x00, 0x00, 0x00, 0xba,	/* TPM_COMMAND_CODE */
@@ -831,7 +829,7 @@ uint32_t tpm_terminate_auth_session(uint32_t auth_handle)
 		0x00, 0x00, 0x00, 0x02,	/* TPM_RESSOURCE_TYPE */
 	};
 	const size_t req_handle_offset = TPM_REQUEST_HEADER_LENGTH;
-	uint8_t request[COMMAND_BUFFER_SIZE];
+	u8 request[COMMAND_BUFFER_SIZE];
 
 	if (pack_byte_string(request, sizeof(request), "sd",
 			     0, command, sizeof(command),
@@ -843,26 +841,26 @@ uint32_t tpm_terminate_auth_session(uint32_t auth_handle)
 	return tpm_sendrecv_command(request, NULL, NULL);
 }
 
-uint32_t tpm_end_oiap(void)
+u32 tpm_end_oiap(void)
 {
-	uint32_t err = TPM_SUCCESS;
+	u32 err = TPM_SUCCESS;
 	if (oiap_session.valid)
 		err = tpm_terminate_auth_session(oiap_session.handle);
 	return err;
 }
 
-uint32_t tpm_oiap(uint32_t *auth_handle)
+u32 tpm_oiap(u32 *auth_handle)
 {
-	const uint8_t command[10] = {
+	const u8 command[10] = {
 		0x00, 0xc1,		/* TPM_TAG */
 		0x00, 0x00, 0x00, 0x0a,	/* parameter size */
 		0x00, 0x00, 0x00, 0x0a,	/* TPM_COMMAND_CODE */
 	};
 	const size_t res_auth_handle_offset = TPM_RESPONSE_HEADER_LENGTH;
 	const size_t res_nonce_even_offset = TPM_RESPONSE_HEADER_LENGTH + 4;
-	uint8_t response[COMMAND_BUFFER_SIZE];
+	u8 response[COMMAND_BUFFER_SIZE];
 	size_t response_length = sizeof(response);
-	uint32_t err;
+	u32 err;
 
 	if (oiap_session.valid)
 		tpm_terminate_auth_session(oiap_session.handle);
@@ -873,7 +871,7 @@ uint32_t tpm_oiap(uint32_t *auth_handle)
 	if (unpack_byte_string(response, response_length, "ds",
 			       res_auth_handle_offset, &oiap_session.handle,
 			       res_nonce_even_offset, &oiap_session.nonce_even,
-			       (uint32_t)DIGEST_LENGTH))
+			       (u32)DIGEST_LENGTH))
 		return TPM_LIB_ERROR;
 	oiap_session.valid = 1;
 	if (auth_handle)
@@ -881,12 +879,10 @@ uint32_t tpm_oiap(uint32_t *auth_handle)
 	return 0;
 }
 
-uint32_t tpm_load_key2_oiap(uint32_t parent_handle,
-		const void *key, size_t key_length,
-		const void *parent_key_usage_auth,
-		uint32_t *key_handle)
+u32 tpm_load_key2_oiap(u32 parent_handle, const void *key, size_t key_length,
+		       const void *parent_key_usage_auth, u32 *key_handle)
 {
-	const uint8_t command[14] = {
+	const u8 command[14] = {
 		0x00, 0xc2,		/* TPM_TAG */
 		0x00, 0x00, 0x00, 0x00,	/* parameter size */
 		0x00, 0x00, 0x00, 0x41,	/* TPM_COMMAND_CODE */
@@ -896,11 +892,11 @@ uint32_t tpm_load_key2_oiap(uint32_t parent_handle,
 	const size_t req_parent_handle_offset = TPM_REQUEST_HEADER_LENGTH;
 	const size_t req_key_offset = TPM_REQUEST_HEADER_LENGTH + 4;
 	const size_t res_handle_offset = TPM_RESPONSE_HEADER_LENGTH;
-	uint8_t request[sizeof(command) + TPM_KEY12_MAX_LENGTH
-			+ TPM_REQUEST_AUTH_LENGTH];
-	uint8_t response[COMMAND_BUFFER_SIZE];
+	u8 request[sizeof(command) + TPM_KEY12_MAX_LENGTH +
+		   TPM_REQUEST_AUTH_LENGTH];
+	u8 response[COMMAND_BUFFER_SIZE];
 	size_t response_length = sizeof(response);
-	uint32_t err;
+	u32 err;
 
 	if (!oiap_session.valid) {
 		err = tpm_oiap(NULL);
@@ -947,10 +943,10 @@ uint32_t tpm_load_key2_oiap(uint32_t parent_handle,
 	return 0;
 }
 
-uint32_t tpm_get_pub_key_oiap(uint32_t key_handle, const void *usage_auth,
-			void *pubkey, size_t *pubkey_len)
+u32 tpm_get_pub_key_oiap(u32 key_handle, const void *usage_auth, void *pubkey,
+			 size_t *pubkey_len)
 {
-	const uint8_t command[14] = {
+	const u8 command[14] = {
 		0x00, 0xc2,		/* TPM_TAG */
 		0x00, 0x00, 0x00, 0x00,	/* parameter size */
 		0x00, 0x00, 0x00, 0x21,	/* TPM_COMMAND_CODE */
@@ -959,11 +955,11 @@ uint32_t tpm_get_pub_key_oiap(uint32_t key_handle, const void *usage_auth,
 	const size_t req_size_offset = 2;
 	const size_t req_key_handle_offset = TPM_REQUEST_HEADER_LENGTH;
 	const size_t res_pubkey_offset = TPM_RESPONSE_HEADER_LENGTH;
-	uint8_t request[sizeof(command) + TPM_REQUEST_AUTH_LENGTH];
-	uint8_t response[TPM_RESPONSE_HEADER_LENGTH + TPM_PUBKEY_MAX_LENGTH
-			+ TPM_RESPONSE_AUTH_LENGTH];
+	u8 request[sizeof(command) + TPM_REQUEST_AUTH_LENGTH];
+	u8 response[TPM_RESPONSE_HEADER_LENGTH + TPM_PUBKEY_MAX_LENGTH +
+		    TPM_RESPONSE_AUTH_LENGTH];
 	size_t response_length = sizeof(response);
-	uint32_t err;
+	u32 err;
 
 	if (!oiap_session.valid) {
 		err = tpm_oiap(NULL);
@@ -973,7 +969,7 @@ uint32_t tpm_get_pub_key_oiap(uint32_t key_handle, const void *usage_auth,
 	if (pack_byte_string(request, sizeof(request), "sdd",
 			     0, command, sizeof(command),
 			     req_size_offset,
-			     (uint32_t)(sizeof(command)
+			     (u32)(sizeof(command)
 			     + TPM_REQUEST_AUTH_LENGTH),
 			     req_key_handle_offset, key_handle
 		))
@@ -1011,15 +1007,15 @@ uint32_t tpm_get_pub_key_oiap(uint32_t key_handle, const void *usage_auth,
 }
 
 #ifdef CONFIG_TPM_LOAD_KEY_BY_SHA1
-uint32_t tpm_find_key_sha1(const uint8_t auth[20], const uint8_t
-			   pubkey_digest[20], uint32_t *handle)
+u32 tpm_find_key_sha1(const u8 auth[20], const u8 pubkey_digest[20],
+		      u32 *handle)
 {
-	uint16_t key_count;
-	uint32_t key_handles[10];
-	uint8_t buf[288];
-	uint8_t *ptr;
-	uint32_t err;
-	uint8_t digest[20];
+	u16 key_count;
+	u32 key_handles[10];
+	u8 buf[288];
+	u8 *ptr;
+	u32 err;
+	u8 digest[20];
 	size_t buf_len;
 	unsigned int i;
 
@@ -1052,9 +1048,9 @@ uint32_t tpm_find_key_sha1(const uint8_t auth[20], const uint8_t
 
 #endif /* CONFIG_TPM_AUTH_SESSIONS */
 
-uint32_t tpm_get_random(void *data, uint32_t count)
+u32 tpm_get_random(void *data, u32 count)
 {
-	const uint8_t command[14] = {
+	const u8 command[14] = {
 		0x0, 0xc1,		/* TPM_TAG */
 		0x0, 0x0, 0x0, 0xe,	/* parameter size */
 		0x0, 0x0, 0x0, 0x46,	/* TPM_COMMAND_CODE */
@@ -1062,15 +1058,15 @@ uint32_t tpm_get_random(void *data, uint32_t count)
 	const size_t length_offset = 10;
 	const size_t data_size_offset = 10;
 	const size_t data_offset = 14;
-	uint8_t buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
+	u8 buf[COMMAND_BUFFER_SIZE], response[COMMAND_BUFFER_SIZE];
 	size_t response_length = sizeof(response);
-	uint32_t data_size;
-	uint8_t *out = data;
+	u32 data_size;
+	u8 *out = data;
 
 	while (count > 0) {
-		uint32_t this_bytes = min((size_t)count,
-					  sizeof(response) - data_offset);
-		uint32_t err;
+		u32 this_bytes = min((size_t)count,
+				     sizeof(response) - data_offset);
+		u32 err;
 
 		if (pack_byte_string(buf, sizeof(buf), "sd",
 				     0, command, sizeof(command),
-- 
2.14.1



More information about the U-Boot mailing list