Commit b9804e5b authored by Miquel Raynal's avatar Miquel Raynal Committed by Tom Rini

tpm: substitute deprecated uint<x>_t types with their u<x> equivalent

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: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Tom Rini's avatarTom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
parent fd0bc263
......@@ -24,7 +24,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;
......@@ -51,7 +51,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;
......@@ -71,7 +71,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)
......@@ -145,7 +145,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;
......@@ -170,10 +170,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);
......@@ -207,11 +207,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) {
......@@ -261,7 +261,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;
......@@ -275,7 +275,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)
......@@ -296,7 +296,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;
......@@ -318,8 +318,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;
......@@ -341,7 +341,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)
......@@ -362,11 +362,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));
}
......@@ -374,7 +374,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)
......@@ -394,11 +394,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));
}
......@@ -406,7 +406,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;
......@@ -480,9 +480,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) {
......@@ -507,7 +507,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;
......@@ -525,7 +525,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)
......@@ -554,7 +554,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)
......@@ -584,7 +584,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);
......@@ -595,10 +595,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)
......@@ -633,8 +633,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)
......@@ -658,9 +658,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)
......@@ -720,9 +720,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;
......@@ -738,7 +738,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]);
......@@ -756,9 +756,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;
......
......@@ -308,8 +308,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
......@@ -322,7 +321,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
......@@ -351,8 +350,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))
......@@ -406,8 +405,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.
......@@ -422,21 +421,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
......@@ -448,7 +447,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
......@@ -460,7 +459,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
......@@ -472,7 +471,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.
......@@ -484,7 +483,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.
......@@ -494,7 +493,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
......@@ -503,7 +502,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.
......@@ -512,28 +511,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.
......@@ -541,7 +540,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
......@@ -554,8 +553,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.
......@@ -563,7 +561,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
......@@ -575,14 +573,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
......@@ -595,10 +593,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
......@@ -613,8 +609,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
......@@ -622,7 +618,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
......@@ -630,7 +626,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
......@@ -639,7 +635,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
/**
......@@ -650,8 +646,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 */
/**
......@@ -663,6 +659,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 */
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment