diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/bootm.c | 11 | ||||
-rw-r--r-- | common/ddr_spd.c | 2 | ||||
-rw-r--r-- | common/hush.c | 58 | ||||
-rw-r--r-- | common/image-fit.c | 8 | ||||
-rw-r--r-- | common/memory_display.c | 70 | ||||
-rw-r--r-- | common/misc.c | 2 | ||||
-rw-r--r-- | common/parser.c | 4 | ||||
-rw-r--r-- | common/ubiformat.c | 12 |
8 files changed, 103 insertions, 64 deletions
diff --git a/common/bootm.c b/common/bootm.c index 169000cccb..36f6c41bbd 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -562,18 +562,15 @@ int bootm_boot(struct bootm_data *bootm_data) data->os_entry = bootm_data->os_entry; ret = read_file_2(data->os_file, &size, &data->os_header, PAGE_SIZE); - if (ret < 0 && ret != -EFBIG) + if (ret < 0 && ret != -EFBIG) { + printf("could not open %s: %s\n", data->os_file, + strerror(-ret)); goto err_out; + } if (size < PAGE_SIZE) goto err_out; os_type = file_detect_type(data->os_header, PAGE_SIZE); - if ((int)os_type < 0) { - printf("could not open %s: %s\n", data->os_file, - strerror(-os_type)); - ret = (int)os_type; - goto err_out; - } if (!data->force && os_type == filetype_unknown) { printf("Unknown OS filetype (try -f)\n"); diff --git a/common/ddr_spd.c b/common/ddr_spd.c index ec343ef5a5..7e2945ed96 100644 --- a/common/ddr_spd.c +++ b/common/ddr_spd.c @@ -166,7 +166,6 @@ static int ddr2_sdram_ctime(uint8_t byte) void ddr_spd_print(uint8_t *record) { int highestCAS = 0; - int cas[256]; int i, i_i, k, x, y; int ddrclk, tbits, pcclk; int trcd, trp, tras; @@ -199,7 +198,6 @@ void ddr_spd_print(uint8_t *record) for (i_i = 2; i_i < 7; i_i++) { if (s->cas_lat & 1 << i_i) { highestCAS = i_i; - cas[highestCAS]++; } } diff --git a/common/hush.c b/common/hush.c index 792b61ac9a..d2f9cc70f5 100644 --- a/common/hush.c +++ b/common/hush.c @@ -106,6 +106,9 @@ * General Public License for more details. * */ + +#define pr_fmt(fmt) "hush: " fmt + #include <malloc.h> /* malloc, free, realloc*/ #include <xfuncs.h> #include <linux/ctype.h> /* isalpha, isdigit */ @@ -263,8 +266,13 @@ struct in_str { #define b_getch(input) ((input)->get(input)) #define b_peek(input) ((input)->peek(input)) +#ifdef HUSH_DEBUG +#define hush_debug(fmt, arg...) debug(fmt, ##arg) +#else +#define hush_debug(fmt, arg...) +#endif -#define final_printf debug +#define final_printf hush_debug static void syntax(void) { @@ -349,7 +357,7 @@ static int b_check_space(o_string *o, int len) static int b_addchr(o_string *o, int ch) { - debug("%s: %c %d %p\n", __func__, ch, o->length, o); + hush_debug("%s: %c %d %p\n", __func__, ch, o->length, o); if (b_check_space(o, 1)) return B_NOSPAC; @@ -504,7 +512,7 @@ static int file_get(struct in_str *i) if (i->p && *i->p) ch = *i->p++; - debug("%s: got a %d\n", __func__, ch); + hush_debug("%s: got a %d\n", __func__, ch); return ch; } @@ -756,7 +764,7 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi) child = &pi->progs[0]; if (child->group) { - debug("non-subshell grouping\n"); + hush_debug("non-subshell grouping\n"); rcode = run_list_real(ctx, child->group); return rcode; @@ -782,7 +790,7 @@ static int run_pipe_real(struct p_context *ctx, struct pipe *pi) char *name, *value; name = xstrdup(child->argv[i]); - debug("Local environment set: %s\n", name); + hush_debug("Local environment set: %s\n", name); value = strchr(name, '='); if (value) @@ -888,7 +896,7 @@ static int run_list_real(struct p_context *ctx, struct pipe *pi) } } rmode = pi->r_mode; - debug("rmode=%d if_code=%d next_if_code=%d skip_more=%d\n", + hush_debug("rmode=%d if_code=%d next_if_code=%d skip_more=%d\n", rmode, if_code, next_if_code, skip_more_in_this_rmode); if (rmode == skip_more_in_this_rmode && flag_skip) { if (pi->followup == PIPE_SEQ) @@ -959,7 +967,7 @@ static int run_list_real(struct p_context *ctx, struct pipe *pi) continue; rcode = run_pipe_real(ctx, pi); - debug("run_pipe_real returned %d\n",rcode); + hush_debug("run_pipe_real returned %d\n",rcode); if (rcode < -1) { last_return_code = -rcode - 2; @@ -1050,16 +1058,16 @@ static int xglob(o_string *dest, int flags, glob_t *pglob, int glob_needed) if (dest->nonnull) { /* bash man page calls this an "explicit" null */ gr = fake_glob(dest->data, flags, NULL, pglob); - debug("globhack returned %d\n",gr); + hush_debug("globhack returned %d\n",gr); } else { return 0; } } else if (glob_needed) { gr = do_glob(dest->data, flags, NULL, pglob); - debug("glob returned %d\n",gr); + hush_debug("glob returned %d\n",gr); } else { gr = fake_glob(dest->data, flags, NULL, pglob); - debug("globhack returned %d\n",gr); + hush_debug("globhack returned %d\n",gr); } if (gr != 0) { /* GLOB_ABORTED ? */ error_msg("glob(3) error %d",gr); @@ -1210,12 +1218,12 @@ static int reserved_word(o_string *dest, struct p_context *ctx) if (strcmp(dest->data, r->literal)) continue; - debug("found reserved word %s, code %d\n",r->literal,r->code); + hush_debug("found reserved word %s, code %d\n",r->literal,r->code); if (r->flag & FLAG_START) { struct p_context *new = xmalloc(sizeof(struct p_context)); - debug("push stack\n"); + hush_debug("push stack\n"); if (ctx->w == RES_IN || ctx->w == RES_FOR) { syntax(); @@ -1241,7 +1249,7 @@ static int reserved_word(o_string *dest, struct p_context *ctx) if (ctx->old_flag & FLAG_END) { struct p_context *old; - debug("pop stack\n"); + hush_debug("pop stack\n"); done_pipe(ctx,PIPE_SEQ); old = ctx->stack; @@ -1266,9 +1274,9 @@ static int done_word(o_string *dest, struct p_context *ctx) glob_t *glob_target; int gr, flags = GLOB_NOCHECK; - debug("%s: %s %p\n", __func__, dest->data, child); + hush_debug("%s: %s %p\n", __func__, dest->data, child); if (dest->length == 0 && !dest->nonnull) { - debug(" true null, ignored\n"); + hush_debug(" true null, ignored\n"); return 0; } if (child->group) { @@ -1276,7 +1284,7 @@ static int done_word(o_string *dest, struct p_context *ctx) return 1; /* syntax error, groups and arglists don't mix */ } if (!child->argv && (ctx->type & FLAG_PARSE_SEMICOLON)) { - debug("checking %s for reserved-ness\n",dest->data); + hush_debug("checking %s for reserved-ness\n",dest->data); if (reserved_word(dest,ctx)) return ctx->w == RES_SNTX; } @@ -1315,13 +1323,13 @@ static int done_command(struct p_context *ctx) struct child_prog *prog = ctx->child; if (prog && prog->group == NULL && prog->argv == NULL) { - debug("%s: skipping null command\n", __func__); + hush_debug("%s: skipping null command\n", __func__); return 0; } else if (prog) { pi->num_progs++; - debug("%s: num_progs incremented to %d\n", __func__, pi->num_progs); + hush_debug("%s: num_progs incremented to %d\n", __func__, pi->num_progs); } else { - debug("%s: initializing\n", __func__); + hush_debug("%s: initializing\n", __func__); } pi->progs = xrealloc(pi->progs, sizeof(*pi->progs) * (pi->num_progs + 1)); @@ -1344,7 +1352,7 @@ static int done_pipe(struct p_context *ctx, pipe_style type) done_command(ctx); /* implicit closure of previous command */ - debug("%s: type %d\n", __func__, type); + hush_debug("%s: type %d\n", __func__, type); ctx->pipe->followup = type; ctx->pipe->r_mode = ctx->w; @@ -1405,7 +1413,7 @@ static int handle_dollar(o_string *dest, struct p_context *ctx, struct in_str *i int advance = 0, i; int ch = input->peek(input); /* first character after the $ */ - debug("%s: ch=%c\n", __func__, ch); + hush_debug("%s: ch=%c\n", __func__, ch); if (isalpha(ch)) { b_addchr(dest, SPECIAL_VAR_SYMBOL); @@ -1490,7 +1498,7 @@ static int parse_stream(o_string *dest, struct p_context *ctx, * A single-quote triggers a bypass of the main loop until its mate is * found. When recursing, quote state is passed in via dest->quote. */ - debug("%s: end_trigger=%d\n", __func__, end_trigger); + hush_debug("%s: end_trigger=%d\n", __func__, end_trigger); while ((ch = b_getch(input)) != EOF) { m = map[ch]; @@ -1498,7 +1506,7 @@ static int parse_stream(o_string *dest, struct p_context *ctx, return 1; next = (ch == '\n') ? 0 : b_peek(input); - debug("%s: ch=%c (%d) m=%d quote=%d - %c\n", + hush_debug("%s: ch=%c (%d) m=%d quote=%d - %c\n", __func__, ch >= ' ' ? ch : '.', ch, m, dest->quote, ctx->stack == NULL ? '*' : '.'); @@ -1519,7 +1527,7 @@ static int parse_stream(o_string *dest, struct p_context *ctx, } if (ch == end_trigger && !dest->quote && ctx->w==RES_NONE) { - debug("%s: leaving (triggered)\n", __func__); + hush_debug("%s: leaving (triggered)\n", __func__); return 0; } @@ -1608,7 +1616,7 @@ static int parse_stream(o_string *dest, struct p_context *ctx, * that is, we were really supposed to get end_trigger, and never got * one before the EOF. Can't use the standard "syntax error" return code, * so that parse_stream_outer can distinguish the EOF and exit smoothly. */ - debug("%s: leaving (EOF)\n", __func__); + hush_debug("%s: leaving (EOF)\n", __func__); if (end_trigger != '\0') return -1; diff --git a/common/image-fit.c b/common/image-fit.c index dfd1fa02c9..87a55b7e27 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -392,7 +392,9 @@ static int fit_verify_hash(struct fit_handle *handle, struct device_node *image, ret = -EINVAL; } - hash = of_get_child_by_name(image, "hash@1"); + hash = of_get_child_by_name(image, "hash-1"); + if (!hash) + hash = of_get_child_by_name(image, "hash@1"); if (!hash) { if (ret) pr_err("image %s does not have hashes\n", @@ -468,7 +470,9 @@ static int fit_image_verify_signature(struct fit_handle *handle, ret = -EINVAL; } - sig_node = of_get_child_by_name(image, "signature@1"); + sig_node = of_get_child_by_name(image, "signature-1"); + if (!sig_node) + sig_node = of_get_child_by_name(image, "signature@1"); if (!sig_node) { pr_err("Image %s has no signature\n", image->full_name); return ret; diff --git a/common/memory_display.c b/common/memory_display.c index ea91985e5d..cd0eadf88d 100644 --- a/common/memory_display.c +++ b/common/memory_display.c @@ -4,10 +4,21 @@ #define DISP_LINE_LEN 16 -int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int swab) + +int __pr_memory_display(int level, const void *addr, loff_t offs, unsigned nbytes, + int size, int swab, const char *fmt, ...) { unsigned long linebytes, i; unsigned char *cp; + unsigned char line[sizeof("00000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................")]; + struct va_format vaf; + int ret; + va_list args; + + va_start(args, fmt); + + vaf.fmt = fmt; + vaf.va = &args; /* Print the lines. * @@ -20,9 +31,9 @@ int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int uint32_t *uip = (uint32_t *)linebuf; uint16_t *usp = (uint16_t *)linebuf; uint8_t *ucp = (uint8_t *)linebuf; - unsigned count = 52; + unsigned char *pos = line; - printf("%08llx:", offs); + pos += sprintf(pos, "%08llx:", offs); linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes; for (i = 0; i < linebytes; i += size) { @@ -34,9 +45,9 @@ int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int res = __swab64(res); if (data_abort_unmask()) { res = 0xffffffffffffffffULL; - count -= printf(" xxxxxxxxxxxxxxxx"); + pos += sprintf(pos, " xxxxxxxxxxxxxxxx"); } else { - count -= printf(" %016llx", res); + pos += sprintf(pos, " %016llx", res); } *ullp++ = res; } else if (size == 4) { @@ -47,9 +58,9 @@ int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int res = __swab32(res); if (data_abort_unmask()) { res = 0xffffffff; - count -= printf(" xxxxxxxx"); + pos += sprintf(pos, " xxxxxxxx"); } else { - count -= printf(" %08x", res); + pos += sprintf(pos, " %08x", res); } *uip++ = res; } else if (size == 2) { @@ -58,22 +69,26 @@ int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int res = *((uint16_t *)addr); if (swab) res = __swab16(res); + if (i > 1 && i % 8 == 0) + pos += sprintf(pos, " "); if (data_abort_unmask()) { res = 0xffff; - count -= printf(" xxxx"); + pos += sprintf(pos, " xxxx"); } else { - count -= printf(" %04x", res); + pos += sprintf(pos, " %04x", res); } *usp++ = res; } else { uint8_t res; data_abort_mask(); res = *((uint8_t *)addr); + if (i > 1 && i % 8 == 0) + pos += sprintf(pos, " "); if (data_abort_unmask()) { res = 0xff; - count -= printf(" xx"); + pos += sprintf(pos, " xx"); } else { - count -= printf(" %02x", res); + pos += sprintf(pos, " %02x", res); } *ucp++ = res; } @@ -81,23 +96,40 @@ int memory_display(const void *addr, loff_t offs, unsigned nbytes, int size, int offs += size; } - while (count--) - putchar(' '); + pos += sprintf(pos, "%*s", 61 - (pos - line), ""); cp = linebuf; for (i = 0; i < linebytes; i++) { if ((*cp < 0x20) || (*cp > 0x7e)) - putchar('.'); + sprintf(pos, "."); else - printf("%c", *cp); + sprintf(pos, "%c", *cp); + pos++; cp++; } - putchar('\n'); + if (level >= MSG_EMERG) + pr_print(level, "%pV%s\n", &vaf, line); + else + printf("%s\n", line); + nbytes -= linebytes; - if (ctrlc()) - return -EINTR; + if (ctrlc()) { + ret = -EINTR; + goto out; + } + } while (nbytes > 0); - return 0; + va_end(args); + ret = 0; +out: + + return ret; } + +int memory_display(const void *addr, loff_t offs, unsigned nbytes, + int size, int swab) +{ + return pr_memory_display(-1, addr, offs, nbytes, size, swab); +}
\ No newline at end of file diff --git a/common/misc.c b/common/misc.c index 665f72be7e..66aba534fc 100644 --- a/common/misc.c +++ b/common/misc.c @@ -67,11 +67,11 @@ const char *strerror(int errnum) case ETIMEDOUT : str = "Connection timed out"; break; case EPROBE_DEFER : str = "Requested probe deferral"; break; case ELOOP : str = "Too many symbolic links encountered"; break; + case ENODATA : str = "No data available"; break; #if 0 /* These are probably not needed */ case ENOTBLK : str = "Block device required"; break; case EFBIG : str = "File too large"; break; case EBADSLT : str = "Invalid slot"; break; - case ENODATA : str = "No data available"; break; case ETIME : str = "Timer expired"; break; case ENONET : str = "Machine is not on the network"; break; case EADV : str = "Advertise error"; break; diff --git a/common/parser.c b/common/parser.c index 6136dbf36f..397d268da1 100644 --- a/common/parser.c +++ b/common/parser.c @@ -70,7 +70,7 @@ static void process_macros (const char *input, char *output) /* 3 = waiting for ''' */ char __maybe_unused *output_start = output; - pr_debug("[PROCESS_MACROS] INPUT len %d: \"%s\"\n", strlen (input), + pr_debug("[PROCESS_MACROS] INPUT len %zu: \"%s\"\n", strlen (input), input); prev = '\0'; /* previous character */ @@ -158,7 +158,7 @@ static void process_macros (const char *input, char *output) if (outputcnt) *output = 0; - pr_debug("[PROCESS_MACROS] OUTPUT len %d: \"%s\"\n", + pr_debug("[PROCESS_MACROS] OUTPUT len %zu: \"%s\"\n", strlen (output_start), output_start); } diff --git a/common/ubiformat.c b/common/ubiformat.c index 9fe1c7c501..0811525bd2 100644 --- a/common/ubiformat.c +++ b/common/ubiformat.c @@ -235,6 +235,9 @@ static int flash_image(struct ubiformat_args *args, struct mtd_info *mtd, int err, new_len; long long ec; + if (si->ec[eb] == EB_BAD) + continue; + if (!args->quiet && !args->verbose) { if (is_timeout(lastprint, 300 * MSECOND) || eb == eb_cnt - 1) { @@ -244,9 +247,6 @@ static int flash_image(struct ubiformat_args *args, struct mtd_info *mtd, } } - if (si->ec[eb] == EB_BAD) - continue; - if (args->verbose) { normsg_cont("eraseblock %d: erase", eb); } @@ -357,6 +357,9 @@ static int format(struct ubiformat_args *args, struct mtd_info *mtd, for (eb = start_eb; eb < eb_cnt; eb++) { long long ec; + if (si->ec[eb] == EB_BAD) + continue; + if (!args->quiet && !args->verbose) { if (is_timeout(lastprint, 300 * MSECOND) || eb == eb_cnt - 1) { @@ -366,9 +369,6 @@ static int format(struct ubiformat_args *args, struct mtd_info *mtd, } } - if (si->ec[eb] == EB_BAD) - continue; - if (args->override_ec) ec = args->ec; else if (si->ec[eb] <= EC_MAX) |