From f19ac83152b54a204b8148815a538d868973e1e1 Mon Sep 17 00:00:00 2001 From: Andreas Färber Date: Sun, 22 May 2016 04:34:04 +0200 Subject: Fix usage of timeval_ms() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First, fix the timeval_ms() implementation to not have K&R but ANSI argument semantics by adding a missing void. timeval_ms() returns an int64_t, not uint64_t or long long. Consistently use int64_t for variables and PRI*64 as format string. While at it, change a few related variables to bool for clarity. Note that timeval_ms() may return a negative error code, but not a single caller checks for that. Change-Id: I27cf83e75b3e9a8913f6c43e98a281bea77aac13 Signed-off-by: Andreas Färber Reviewed-on: http://openocd.zylin.com/3499 Tested-by: jenkins Reviewed-by: Andreas Fritiofson Reviewed-by: Tomas Vanek --- src/flash/nor/aduc702x.c | 2 +- src/flash/nor/aducm360.c | 2 +- src/flash/nor/at91sam3.c | 2 +- src/flash/nor/at91sam4.c | 2 +- src/flash/nor/atsamv.c | 2 +- src/flash/nor/jtagspi.c | 14 +++++++------- src/flash/nor/lpcspifi.c | 4 ++-- src/flash/nor/stmsmi.c | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src/flash') diff --git a/src/flash/nor/aduc702x.c b/src/flash/nor/aduc702x.c index fa1aeb47..34cc362e 100644 --- a/src/flash/nor/aduc702x.c +++ b/src/flash/nor/aduc702x.c @@ -371,7 +371,7 @@ static int aduc702x_check_flash_completion(struct target *target, unsigned int t { uint8_t v = 4; - long long endtime = timeval_ms() + timeout_ms; + int64_t endtime = timeval_ms() + timeout_ms; while (1) { target_read_u8(target, ADUC702x_FLASH + ADUC702x_FLASH_FEESTA, &v); if ((v & 4) == 0) diff --git a/src/flash/nor/aducm360.c b/src/flash/nor/aducm360.c index 0f85254a..8681a25a 100644 --- a/src/flash/nor/aducm360.c +++ b/src/flash/nor/aducm360.c @@ -551,7 +551,7 @@ static int aducm360_check_flash_completion(struct target *target, unsigned int t { uint32_t v = 1; - long long endtime = timeval_ms() + timeout_ms; + int64_t endtime = timeval_ms() + timeout_ms; while (1) { target_read_u32(target, ADUCM360_FLASH_BASE+ADUCM360_FLASH_FEESTA, &v); if ((v & 0x00000001) == 0) diff --git a/src/flash/nor/at91sam3.c b/src/flash/nor/at91sam3.c index 69b8e3de..1536378d 100644 --- a/src/flash/nor/at91sam3.c +++ b/src/flash/nor/at91sam3.c @@ -2175,7 +2175,7 @@ static int EFC_PerformCommand(struct sam3_bank_private *pPrivate, int r; uint32_t v; - long long ms_now, ms_end; + int64_t ms_now, ms_end; /* default */ if (status) diff --git a/src/flash/nor/at91sam4.c b/src/flash/nor/at91sam4.c index 8431729e..50aa98b8 100644 --- a/src/flash/nor/at91sam4.c +++ b/src/flash/nor/at91sam4.c @@ -1053,7 +1053,7 @@ static int EFC_PerformCommand(struct sam4_bank_private *pPrivate, int r; uint32_t v; - long long ms_now, ms_end; + int64_t ms_now, ms_end; /* default */ if (status) diff --git a/src/flash/nor/atsamv.c b/src/flash/nor/atsamv.c index 0658c590..d21419d0 100644 --- a/src/flash/nor/atsamv.c +++ b/src/flash/nor/atsamv.c @@ -147,7 +147,7 @@ static int samv_efc_perform_command(struct target *target, { int r; uint32_t v; - long long ms_now, ms_end; + int64_t ms_now, ms_end; if (status) *status = 0; diff --git a/src/flash/nor/jtagspi.c b/src/flash/nor/jtagspi.c index 0ba4dc21..a995fc75 100644 --- a/src/flash/nor/jtagspi.c +++ b/src/flash/nor/jtagspi.c @@ -210,14 +210,14 @@ static void jtagspi_read_status(struct flash_bank *bank, uint32_t *status) static int jtagspi_wait(struct flash_bank *bank, int timeout_ms) { uint32_t status; - long long t0 = timeval_ms(); - long long dt; + int64_t t0 = timeval_ms(); + int64_t dt; do { dt = timeval_ms() - t0; jtagspi_read_status(bank, &status); if ((status & SPIFLASH_BSY_BIT) == 0) { - LOG_DEBUG("waited %lld ms", dt); + LOG_DEBUG("waited %" PRId64 " ms", dt); return ERROR_OK; } alive_sleep(1); @@ -244,14 +244,14 @@ static int jtagspi_bulk_erase(struct flash_bank *bank) { struct jtagspi_flash_bank *info = bank->driver_priv; int retval; - long long t0 = timeval_ms(); + int64_t t0 = timeval_ms(); retval = jtagspi_write_enable(bank); if (retval != ERROR_OK) return retval; jtagspi_cmd(bank, info->dev->chip_erase_cmd, NULL, NULL, 0); retval = jtagspi_wait(bank, bank->num_sectors*JTAGSPI_MAX_TIMEOUT); - LOG_INFO("took %lld ms", timeval_ms() - t0); + LOG_INFO("took %" PRId64 " ms", timeval_ms() - t0); return retval; } @@ -259,14 +259,14 @@ static int jtagspi_sector_erase(struct flash_bank *bank, int sector) { struct jtagspi_flash_bank *info = bank->driver_priv; int retval; - long long t0 = timeval_ms(); + int64_t t0 = timeval_ms(); retval = jtagspi_write_enable(bank); if (retval != ERROR_OK) return retval; jtagspi_cmd(bank, info->dev->erase_cmd, &bank->sectors[sector].offset, NULL, 0); retval = jtagspi_wait(bank, JTAGSPI_MAX_TIMEOUT); - LOG_INFO("sector %d took %lld ms", sector, timeval_ms() - t0); + LOG_INFO("sector %d took %" PRId64 " ms", sector, timeval_ms() - t0); return retval; } diff --git a/src/flash/nor/lpcspifi.c b/src/flash/nor/lpcspifi.c index 94a8ccf4..4eb6cc38 100644 --- a/src/flash/nor/lpcspifi.c +++ b/src/flash/nor/lpcspifi.c @@ -106,7 +106,7 @@ static int ssp_setcs(struct target *target, uint32_t io_base, unsigned int value * and the controller is idle. */ static int poll_ssp_busy(struct target *target, uint32_t ssp_base, int timeout) { - long long endtime; + int64_t endtime; uint32_t value; int retval; @@ -325,7 +325,7 @@ static int wait_till_ready(struct flash_bank *bank, int timeout) { uint32_t status; int retval; - long long endtime; + int64_t endtime; endtime = timeval_ms() + timeout; do { diff --git a/src/flash/nor/stmsmi.c b/src/flash/nor/stmsmi.c index e4d59fe3..781ea3b5 100644 --- a/src/flash/nor/stmsmi.c +++ b/src/flash/nor/stmsmi.c @@ -160,7 +160,7 @@ FLASH_BANK_COMMAND_HANDLER(stmsmi_flash_bank_command) /* timeout in ms */ static int poll_tff(struct target *target, uint32_t io_base, int timeout) { - long long endtime; + int64_t endtime; if (SMI_READ_REG(SMI_SR) & SMI_TFF) return ERROR_OK; @@ -211,7 +211,7 @@ static int wait_till_ready(struct flash_bank *bank, int timeout) { uint32_t status; int retval; - long long endtime; + int64_t endtime; endtime = timeval_ms() + timeout; do { -- cgit v1.2.3-18-g5258