forked from auracaster/openocd
Fix usage of timeval_ms()
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 <afaerber@suse.de> Reviewed-on: http://openocd.zylin.com/3499 Tested-by: jenkins Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
This commit is contained in:
committed by
Andreas Fritiofson
parent
f4496b25e3
commit
f19ac83152
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user