Commit 4f292c48 authored by Masami Hiramatsu's avatar Masami Hiramatsu Committed by Steven Rostedt (VMware)

bootconfig: Replace u16 and u32 with uint16_t and uint32_t

Replace u16 and u32 with uint16_t and uint32_t so
that the tools/bootconfig only needs <stdint.h>.

Link: https://lkml.kernel.org/r/163187298835.2366983.9838262576854319669.stgit@devnote2Signed-off-by: default avatarMasami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
parent 160321b2
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
* The checksum will be used with the BOOTCONFIG_MAGIC and the size for * The checksum will be used with the BOOTCONFIG_MAGIC and the size for
* embedding the bootconfig in the initrd image. * embedding the bootconfig in the initrd image.
*/ */
static inline __init u32 xbc_calc_checksum(void *data, u32 size) static inline __init uint32_t xbc_calc_checksum(void *data, uint32_t size)
{ {
unsigned char *p = data; unsigned char *p = data;
u32 ret = 0; uint32_t ret = 0;
while (size--) while (size--)
ret += *p++; ret += *p++;
...@@ -38,10 +38,10 @@ static inline __init u32 xbc_calc_checksum(void *data, u32 size) ...@@ -38,10 +38,10 @@ static inline __init u32 xbc_calc_checksum(void *data, u32 size)
/* XBC tree node */ /* XBC tree node */
struct xbc_node { struct xbc_node {
u16 next; uint16_t next;
u16 child; uint16_t child;
u16 parent; uint16_t parent;
u16 data; uint16_t data;
} __attribute__ ((__packed__)); } __attribute__ ((__packed__));
#define XBC_KEY 0 #define XBC_KEY 0
......
...@@ -244,7 +244,7 @@ int __init xbc_node_compose_key_after(struct xbc_node *root, ...@@ -244,7 +244,7 @@ int __init xbc_node_compose_key_after(struct xbc_node *root,
struct xbc_node *node, struct xbc_node *node,
char *buf, size_t size) char *buf, size_t size)
{ {
u16 keys[XBC_DEPTH_MAX]; uint16_t keys[XBC_DEPTH_MAX];
int depth = 0, ret = 0, total = 0; int depth = 0, ret = 0, total = 0;
if (!node || node == root) if (!node || node == root)
...@@ -359,21 +359,21 @@ const char * __init xbc_node_find_next_key_value(struct xbc_node *root, ...@@ -359,21 +359,21 @@ const char * __init xbc_node_find_next_key_value(struct xbc_node *root,
/* XBC parse and tree build */ /* XBC parse and tree build */
static int __init xbc_init_node(struct xbc_node *node, char *data, u32 flag) static int __init xbc_init_node(struct xbc_node *node, char *data, uint32_t flag)
{ {
unsigned long offset = data - xbc_data; unsigned long offset = data - xbc_data;
if (WARN_ON(offset >= XBC_DATA_MAX)) if (WARN_ON(offset >= XBC_DATA_MAX))
return -EINVAL; return -EINVAL;
node->data = (u16)offset | flag; node->data = (uint16_t)offset | flag;
node->child = 0; node->child = 0;
node->next = 0; node->next = 0;
return 0; return 0;
} }
static struct xbc_node * __init xbc_add_node(char *data, u32 flag) static struct xbc_node * __init xbc_add_node(char *data, uint32_t flag)
{ {
struct xbc_node *node; struct xbc_node *node;
...@@ -403,7 +403,7 @@ static inline __init struct xbc_node *xbc_last_child(struct xbc_node *node) ...@@ -403,7 +403,7 @@ static inline __init struct xbc_node *xbc_last_child(struct xbc_node *node)
return node; return node;
} }
static struct xbc_node * __init __xbc_add_sibling(char *data, u32 flag, bool head) static struct xbc_node * __init __xbc_add_sibling(char *data, uint32_t flag, bool head)
{ {
struct xbc_node *sib, *node = xbc_add_node(data, flag); struct xbc_node *sib, *node = xbc_add_node(data, flag);
...@@ -430,17 +430,17 @@ static struct xbc_node * __init __xbc_add_sibling(char *data, u32 flag, bool hea ...@@ -430,17 +430,17 @@ static struct xbc_node * __init __xbc_add_sibling(char *data, u32 flag, bool hea
return node; return node;
} }
static inline struct xbc_node * __init xbc_add_sibling(char *data, u32 flag) static inline struct xbc_node * __init xbc_add_sibling(char *data, uint32_t flag)
{ {
return __xbc_add_sibling(data, flag, false); return __xbc_add_sibling(data, flag, false);
} }
static inline struct xbc_node * __init xbc_add_head_sibling(char *data, u32 flag) static inline struct xbc_node * __init xbc_add_head_sibling(char *data, uint32_t flag)
{ {
return __xbc_add_sibling(data, flag, true); return __xbc_add_sibling(data, flag, true);
} }
static inline __init struct xbc_node *xbc_add_child(char *data, u32 flag) static inline __init struct xbc_node *xbc_add_child(char *data, uint32_t flag)
{ {
struct xbc_node *node = xbc_add_sibling(data, flag); struct xbc_node *node = xbc_add_sibling(data, flag);
......
...@@ -3,11 +3,9 @@ ...@@ -3,11 +3,9 @@
#define _SKC_LINUX_KERNEL_H #define _SKC_LINUX_KERNEL_H
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
typedef unsigned short u16;
typedef unsigned int u32;
#define unlikely(cond) (cond) #define unlikely(cond) (cond)
#define __init #define __init
......
...@@ -178,7 +178,7 @@ static int load_xbc_from_initrd(int fd, char **buf) ...@@ -178,7 +178,7 @@ static int load_xbc_from_initrd(int fd, char **buf)
{ {
struct stat stat; struct stat stat;
int ret; int ret;
u32 size = 0, csum = 0, rcsum; uint32_t size = 0, csum = 0, rcsum;
char magic[BOOTCONFIG_MAGIC_LEN]; char magic[BOOTCONFIG_MAGIC_LEN];
const char *msg; const char *msg;
...@@ -202,11 +202,11 @@ static int load_xbc_from_initrd(int fd, char **buf) ...@@ -202,11 +202,11 @@ static int load_xbc_from_initrd(int fd, char **buf)
if (lseek(fd, -(8 + BOOTCONFIG_MAGIC_LEN), SEEK_END) < 0) if (lseek(fd, -(8 + BOOTCONFIG_MAGIC_LEN), SEEK_END) < 0)
return pr_errno("Failed to lseek for size", -errno); return pr_errno("Failed to lseek for size", -errno);
if (read(fd, &size, sizeof(u32)) < 0) if (read(fd, &size, sizeof(uint32_t)) < 0)
return pr_errno("Failed to read size", -errno); return pr_errno("Failed to read size", -errno);
size = le32toh(size); size = le32toh(size);
if (read(fd, &csum, sizeof(u32)) < 0) if (read(fd, &csum, sizeof(uint32_t)) < 0)
return pr_errno("Failed to read checksum", -errno); return pr_errno("Failed to read checksum", -errno);
csum = le32toh(csum); csum = le32toh(csum);
...@@ -364,7 +364,7 @@ static int apply_xbc(const char *path, const char *xbc_path) ...@@ -364,7 +364,7 @@ static int apply_xbc(const char *path, const char *xbc_path)
size_t total_size; size_t total_size;
struct stat stat; struct stat stat;
const char *msg; const char *msg;
u32 size, csum; uint32_t size, csum;
int pos, pad; int pos, pad;
int ret, fd; int ret, fd;
...@@ -378,7 +378,7 @@ static int apply_xbc(const char *path, const char *xbc_path) ...@@ -378,7 +378,7 @@ static int apply_xbc(const char *path, const char *xbc_path)
/* Backup the bootconfig data */ /* Backup the bootconfig data */
data = calloc(size + BOOTCONFIG_ALIGN + data = calloc(size + BOOTCONFIG_ALIGN +
sizeof(u32) + sizeof(u32) + BOOTCONFIG_MAGIC_LEN, 1); sizeof(uint32_t) + sizeof(uint32_t) + BOOTCONFIG_MAGIC_LEN, 1);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
memcpy(data, buf, size); memcpy(data, buf, size);
...@@ -426,17 +426,17 @@ static int apply_xbc(const char *path, const char *xbc_path) ...@@ -426,17 +426,17 @@ static int apply_xbc(const char *path, const char *xbc_path)
} }
/* To align up the total size to BOOTCONFIG_ALIGN, get padding size */ /* To align up the total size to BOOTCONFIG_ALIGN, get padding size */
total_size = stat.st_size + size + sizeof(u32) * 2 + BOOTCONFIG_MAGIC_LEN; total_size = stat.st_size + size + sizeof(uint32_t) * 2 + BOOTCONFIG_MAGIC_LEN;
pad = ((total_size + BOOTCONFIG_ALIGN - 1) & (~BOOTCONFIG_ALIGN_MASK)) - total_size; pad = ((total_size + BOOTCONFIG_ALIGN - 1) & (~BOOTCONFIG_ALIGN_MASK)) - total_size;
size += pad; size += pad;
/* Add a footer */ /* Add a footer */
p = data + size; p = data + size;
*(u32 *)p = htole32(size); *(uint32_t *)p = htole32(size);
p += sizeof(u32); p += sizeof(uint32_t);
*(u32 *)p = htole32(csum); *(uint32_t *)p = htole32(csum);
p += sizeof(u32); p += sizeof(uint32_t);
memcpy(p, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN); memcpy(p, BOOTCONFIG_MAGIC, BOOTCONFIG_MAGIC_LEN);
p += BOOTCONFIG_MAGIC_LEN; p += BOOTCONFIG_MAGIC_LEN;
......
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