target/renesas: flash read write return bool

This commit is contained in:
Rafael Silva 2022-08-25 15:10:49 +01:00 committed by Rachel Mant
parent 6cafdeaa73
commit a23ba218a7
1 changed files with 7 additions and 10 deletions

View File

@ -503,7 +503,7 @@ static bool renesas_rv40_done(target_flash_s *f)
} }
/* !TODO: implement blank check */ /* !TODO: implement blank check */
static int renesas_rv40_flash_erase(target_flash_s *f, target_addr_t addr, size_t len) static bool renesas_rv40_flash_erase(target_flash_s *f, target_addr_t addr, size_t len)
{ {
target *t = f->t; target *t = f->t;
@ -541,17 +541,17 @@ static int renesas_rv40_flash_erase(target_flash_s *f, target_addr_t addr, size_
/* Read FRDY bit until it has been set to 1 indicating that the current operation is complete.*/ /* Read FRDY bit until it has been set to 1 indicating that the current operation is complete.*/
while (!(target_mem_read32(t, RV40_FSTATR) & RV40_FSTATR_RDY)) { while (!(target_mem_read32(t, RV40_FSTATR) & RV40_FSTATR_RDY)) {
if (target_check_error(t) || platform_timeout_is_expired(&timeout)) if (target_check_error(t) || platform_timeout_is_expired(&timeout))
return -1; return false;
} }
if (renesas_rv40_error_check(t, RV40_FSTATR_ERSERR | RV40_FSTATR_ILGLERR)) if (renesas_rv40_error_check(t, RV40_FSTATR_ERSERR | RV40_FSTATR_ILGLERR))
return -1; return false;
} }
return 0; return true;
} }
static int renesas_rv40_flash_write(target_flash_s *f, target_addr_t dest, const void *src, size_t len) static bool renesas_rv40_flash_write(target_flash_s *f, target_addr_t dest, const void *src, size_t len)
{ {
target *t = f->t; target *t = f->t;
@ -596,14 +596,11 @@ static int renesas_rv40_flash_write(target_flash_s *f, target_addr_t dest, const
/* read FRDY bit until it has been set to 1 indicating that the current operation is complete.*/ /* read FRDY bit until it has been set to 1 indicating that the current operation is complete.*/
while (!(target_mem_read32(t, RV40_FSTATR) & RV40_FSTATR_RDY)) { while (!(target_mem_read32(t, RV40_FSTATR) & RV40_FSTATR_RDY)) {
if (target_check_error(t) || platform_timeout_is_expired(&timeout)) if (target_check_error(t) || platform_timeout_is_expired(&timeout))
return -1; return false;
} }
} }
if (renesas_rv40_error_check(t, RV40_FSTATR_PRGERR | RV40_FSTATR_ILGLERR)) return !renesas_rv40_error_check(t, RV40_FSTATR_PRGERR | RV40_FSTATR_ILGLERR);
return -1;
return 0;
} }
static void renesas_add_rv40_flash(target *t, target_addr_t addr, size_t length) static void renesas_add_rv40_flash(target *t, target_addr_t addr, size_t length)