9
0
Fork 0

image: remove confusing image_check_* functions

The function names do not make it clear what return value
is expected and do not save a single line of code. Put
the code inline and unbreak the wrong checks introduced
with a3c1e5d888.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Eric Bénard <eric@eukrea.com>
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
This commit is contained in:
Sascha Hauer 2010-10-13 13:11:09 +02:00
parent b531c53e74
commit a64c756ad9
7 changed files with 12 additions and 66 deletions

View File

@ -212,7 +212,7 @@ int do_bootm_linux(struct image_data *data)
void (*theKernel)(int zero, int arch, void *params);
image_header_t *os_header = &data->os->header;
if (image_check_type(os_header, IH_TYPE_MULTI)) {
if (image_get_type(os_header) == IH_TYPE_MULTI) {
printf("Multifile images not handled at the moment\n");
return -1;
}

View File

@ -109,7 +109,7 @@ static int do_bootm_linux(struct image_data *data)
const char *commandline = getenv ("bootargs");
uint32_t loadaddr,loadsize;
if (image_check_type(os_header, IH_TYPE_MULTI)) {
if (image_get_type(os_header) == IH_TYPE_MULTI) {
printf("Multifile images not handled at the moment\n");
return -1;
}

View File

@ -45,7 +45,7 @@ static int do_bootm_linux(struct image_data *idata)
printf("entering %s: os_header: %p initrd_header: %p oftree: %s\n",
__FUNCTION__, os_header, initrd_header, idata->oftree);
if (image_check_type(os_header, IH_TYPE_MULTI)) {
if (image_get_type(os_header) == IH_TYPE_MULTI) {
unsigned long *data = (unsigned long *)(idata->os->data);
unsigned long len1 = 0, len2 = 0;

View File

@ -167,7 +167,7 @@ struct image_handle *map_image(const char *filename, int verify)
goto err_out;
}
if (image_check_magic(header)) {
if (image_get_magic(header) != IH_MAGIC) {
puts ("Bad Magic Number\n");
goto err_out;
}
@ -332,7 +332,7 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
os_header = &os_handle->header;
if (image_check_arch(os_header, IH_ARCH)) {
if (image_get_arch(os_header) != IH_ARCH) {
printf("Unsupported Architecture 0x%x\n",
image_get_arch(os_header));
goto err_out;
@ -350,7 +350,7 @@ static int do_bootm(struct command *cmdtp, int argc, char *argv[])
/* loop through the registered handlers */
list_for_each_entry(handler, &handler_list, list) {
if (image_check_os(os_header, handler->image_type)) {
if (image_get_os(os_header) == handler->image_type) {
handler->bootm(&data);
printf("handler returned!\n");
goto err_out;
@ -409,7 +409,7 @@ static int image_info (ulong addr)
/* Copy header so we can blank CRC field for re-calculation */
memmove (&header, (char *)addr, image_get_header_size());
if (image_check_magic(hdr)) {
if (image_get_magic(hdr) != IH_MAGIC) {
puts (" Bad Magic Number\n");
return 1;
}

View File

@ -266,6 +266,7 @@ void image_print_contents(const void *ptr)
{
const image_header_t *hdr = (const image_header_t *)ptr;
const char *p;
int type;
#ifdef __BAREBOX__
p = " ";
@ -285,8 +286,8 @@ void image_print_contents(const void *ptr)
printf ("%sLoad Address: %08x\n", p, image_get_load(hdr));
printf ("%sEntry Point: %08x\n", p, image_get_ep(hdr));
if (image_check_type(hdr, IH_TYPE_MULTI) ||
image_check_type(hdr, IH_TYPE_SCRIPT)) {
type = image_get_type(hdr);
if (type == IH_TYPE_MULTI || type == IH_TYPE_SCRIPT) {
int i;
ulong data, len;
ulong count = image_multi_count(hdr);
@ -298,7 +299,7 @@ void image_print_contents(const void *ptr)
printf("%s Image %d: ", p, i);
image_print_size(len);
if (image_check_type(hdr, IH_TYPE_SCRIPT) && i > 0) {
if (image_get_type(hdr) != IH_TYPE_SCRIPT && i > 0) {
/*
* the user may need to know offsets
* if planning to do something with

View File

@ -320,61 +320,6 @@ static inline void image_set_name(image_header_t *hdr, const char *name)
strncpy(image_get_name(hdr), name, IH_NMLEN);
}
static inline int image_check_magic(const image_header_t *hdr)
{
return (image_get_magic(hdr) == IH_MAGIC);
}
static inline int image_check_type(const image_header_t *hdr, uint8_t type)
{
return (image_get_type(hdr) == type);
}
static inline int image_check_arch(const image_header_t *hdr, uint8_t arch)
{
return (image_get_arch(hdr) == arch);
}
static inline int image_check_os(const image_header_t *hdr, uint8_t os)
{
return (image_get_os(hdr) == os);
}
#ifdef __BAREBOX__
static inline int image_check_target_arch(const image_header_t *hdr)
{
#if defined(__ARM__)
if (!image_check_arch(hdr, IH_ARCH_ARM))
#elif defined(__avr32__)
if (!image_check_arch(hdr, IH_ARCH_AVR32))
#elif defined(__bfin__)
if (!image_check_arch(hdr, IH_ARCH_BLACKFIN))
#elif defined(__I386__)
if (!image_check_arch(hdr, IH_ARCH_I386))
#elif defined(__m68k__)
if (!image_check_arch(hdr, IH_ARCH_M68K))
#elif defined(__microblaze__)
if (!image_check_arch(hdr, IH_ARCH_MICROBLAZE))
#elif defined(__mips__)
if (!image_check_arch(hdr, IH_ARCH_MIPS))
#elif defined(__nios__)
if (!image_check_arch(hdr, IH_ARCH_NIOS))
#elif defined(__nios2__)
if (!image_check_arch(hdr, IH_ARCH_NIOS2))
#elif defined(__PPC__)
if (!image_check_arch(hdr, IH_ARCH_PPC))
#elif defined(__sh__)
if (!image_check_arch(hdr, IH_ARCH_SH))
#elif defined(__sparc__)
if (!image_check_arch(hdr, IH_ARCH_SPARC))
#elif defined(CONFIG_LINUX)
if (!image_check_arch(hdr, IH_ARCH_LINUX))
#else
# error Unknown CPU type
#endif
return 0;
return 1;
}
#endif
ulong image_multi_count(const image_header_t *hdr);
void image_multi_getimg(const image_header_t *hdr, ulong idx,
ulong *data, ulong *len);

View File

@ -224,7 +224,7 @@ NXTARG: ;
*/
memcpy (hdr, ptr, sizeof(image_header_t));
if (image_check_magic(hdr)) {
if (image_get_magic(hdr) != IH_MAGIC) {
fprintf (stderr,
"%s: Bad Magic Number: \"%s\" is no valid image\n",
cmdname, imagefile);