summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2018-01-29 20:37:04 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2018-01-30 08:33:54 +0100
commitb5526c403c41ffa70a917df3841cd5e77b23d1f3 (patch)
tree608cba584e6b0fa4292fbb0bb98c91145581d2f2 /include
parent83ff71fcee4daabfd74ff31e5612f74c4996ec5c (diff)
downloadbarebox-b5526c403c41ffa70a917df3841cd5e77b23d1f3.tar.gz
barebox-b5526c403c41ffa70a917df3841cd5e77b23d1f3.tar.xz
imd: Make all pointers into image const
The IMD code should be readonly and never modify any pointers. Make all pointers const so that const pointers can be passed in to IMD. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include')
-rw-r--r--include/bbu.h2
-rw-r--r--include/image-metadata.h21
2 files changed, 12 insertions, 11 deletions
diff --git a/include/bbu.h b/include/bbu.h
index 54434b03e0..a3824e11cf 100644
--- a/include/bbu.h
+++ b/include/bbu.h
@@ -16,7 +16,7 @@ struct bbu_data {
const char *devicefile;
size_t len;
const char *handler_name;
- struct imd_header *imd_data;
+ const struct imd_header *imd_data;
};
struct bbu_handler {
diff --git a/include/image-metadata.h b/include/image-metadata.h
index 0ba92469a4..8739bffb92 100644
--- a/include/image-metadata.h
+++ b/include/image-metadata.h
@@ -56,35 +56,36 @@ static inline int imd_type_valid(uint32_t type)
return (type & 0xffff0000) == 0x640c0000;
}
-struct imd_header *imd_next(struct imd_header *imd);
+const struct imd_header *imd_next(const struct imd_header *imd);
#define imd_for_each(start, imd) \
for (imd = imd_next(start); imd_read_type(imd) != IMD_TYPE_END; imd = imd_next(imd))
-static inline uint32_t imd_read_le32(void *_ptr)
+static inline uint32_t imd_read_le32(const void *_ptr)
{
- uint8_t *ptr = _ptr;
+ const uint8_t *ptr = _ptr;
return ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24);
}
-static inline uint32_t imd_read_type(struct imd_header *imd)
+static inline uint32_t imd_read_type(const struct imd_header *imd)
{
return imd_read_le32(&imd->type);
}
-static inline uint32_t imd_read_length(struct imd_header *imd)
+static inline uint32_t imd_read_length(const struct imd_header *imd)
{
return imd_read_le32(&imd->datalength);
}
-struct imd_header *imd_find_type(struct imd_header *imd, uint32_t type);
+const struct imd_header *imd_find_type(const struct imd_header *imd,
+ uint32_t type);
-struct imd_header *imd_get(void *buf, int size);
-const char *imd_string_data(struct imd_header *imd, int index);
+const struct imd_header *imd_get(const void *buf, int size);
+const char *imd_string_data(const struct imd_header *imd, int index);
const char *imd_type_to_name(uint32_t type);
-char *imd_concat_strings(struct imd_header *imd);
-const char *imd_get_param(struct imd_header *imd, const char *name);
+char *imd_concat_strings(const struct imd_header *imd);
+const char *imd_get_param(const struct imd_header *imd, const char *name);
extern int imd_command_verbose;
int imd_command_setenv(const char *variable_name, const char *value);