diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/dfu.c | 6 | ||||
-rw-r--r-- | common/hash.c | 36 | ||||
-rw-r--r-- | common/main.c | 22 | ||||
-rw-r--r-- | common/xyzModem.c | 2 |
4 files changed, 50 insertions, 16 deletions
diff --git a/common/dfu.c b/common/dfu.c index 2620d3238b1..44d1484d3d2 100644 --- a/common/dfu.c +++ b/common/dfu.c @@ -23,9 +23,9 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget) bool dfu_reset = false; int ret, i = 0; - ret = board_usb_init(usbctrl_index, USB_INIT_DEVICE); + ret = usb_gadget_initialize(usbctrl_index); if (ret) { - pr_err("board usb init failed\n"); + pr_err("usb_gadget_initialize failed\n"); return CMD_RET_FAILURE; } g_dnl_clear_detach(); @@ -84,7 +84,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget) } exit: g_dnl_unregister(); - board_usb_cleanup(usbctrl_index, USB_INIT_DEVICE); + usb_gadget_release(usbctrl_index); if (dfu_reset) do_reset(NULL, 0, 0, NULL); diff --git a/common/hash.c b/common/hash.c index ef146513a07..413a5bfcdae 100644 --- a/common/hash.c +++ b/common/hash.c @@ -85,6 +85,33 @@ static int hash_finish_sha256(struct hash_algo *algo, void *ctx, void } #endif +static int hash_init_crc16_ccitt(struct hash_algo *algo, void **ctxp) +{ + uint16_t *ctx = malloc(sizeof(uint16_t)); + *ctx = 0; + *ctxp = ctx; + return 0; +} + +static int hash_update_crc16_ccitt(struct hash_algo *algo, void *ctx, + const void *buf, unsigned int size, + int is_last) +{ + *((uint16_t *)ctx) = crc16_ccitt(*((uint16_t *)ctx), buf, size); + return 0; +} + +static int hash_finish_crc16_ccitt(struct hash_algo *algo, void *ctx, + void *dest_buf, int size) +{ + if (size < algo->digest_size) + return -1; + + *((uint16_t *)dest_buf) = *((uint16_t *)ctx); + free(ctx); + return 0; +} + static int hash_init_crc32(struct hash_algo *algo, void **ctxp) { uint32_t *ctx = malloc(sizeof(uint32_t)); @@ -160,6 +187,15 @@ static struct hash_algo hash_algo[] = { }, #endif { + .name = "crc16-ccitt", + .digest_size = 2, + .chunk_size = CHUNKSZ, + .hash_func_ws = crc16_ccitt_wd_buf, + .hash_init = hash_init_crc16_ccitt, + .hash_update = hash_update_crc16_ccitt, + .hash_finish = hash_finish_crc16_ccitt, + }, + { .name = "crc32", .digest_size = 4, .chunk_size = CHUNKSZ_CRC32, diff --git a/common/main.c b/common/main.c index 9802bed229c..07b34bf2b05 100644 --- a/common/main.c +++ b/common/main.c @@ -24,15 +24,15 @@ static void run_preboot_environment_command(void) p = env_get("preboot"); if (p != NULL) { -# ifdef CONFIG_AUTOBOOT_KEYED - int prev = disable_ctrlc(1); /* disable Control C checking */ -# endif + int prev = 0; + + if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED)) + prev = disable_ctrlc(1); /* disable Ctrl-C checking */ run_command_list(p, -1, 0); -# ifdef CONFIG_AUTOBOOT_KEYED - disable_ctrlc(prev); /* restore Control C checking */ -# endif + if (IS_ENABLED(CONFIG_AUTOBOOT_KEYED)) + disable_ctrlc(prev); /* restore Ctrl-C checking */ } #endif /* CONFIG_PREBOOT */ } @@ -44,17 +44,15 @@ void main_loop(void) bootstage_mark_name(BOOTSTAGE_ID_MAIN_LOOP, "main_loop"); -#ifdef CONFIG_VERSION_VARIABLE - env_set("ver", version_string); /* set version variable */ -#endif /* CONFIG_VERSION_VARIABLE */ + if (IS_ENABLED(CONFIG_VERSION_VARIABLE)) + env_set("ver", version_string); /* set version variable */ cli_init(); run_preboot_environment_command(); -#if defined(CONFIG_UPDATE_TFTP) - update_tftp(0UL, NULL, NULL); -#endif /* CONFIG_UPDATE_TFTP */ + if (IS_ENABLED(CONFIG_UPDATE_TFTP)) + update_tftp(0UL, NULL, NULL); s = bootdelay_process(); if (cli_process_fdt(&s)) diff --git a/common/xyzModem.c b/common/xyzModem.c index 830fca83875..e5c65b480a2 100644 --- a/common/xyzModem.c +++ b/common/xyzModem.c @@ -24,7 +24,7 @@ #include <common.h> #include <xyzModem.h> #include <stdarg.h> -#include <crc.h> +#include <u-boot/crc.h> /* Assumption - run xyzModem protocol over the console port */ |