It's currently allocating a big buffer but writing it out in
units of sizeof(host's pointer) ... sub-optimal.
Plus fix a couple minor coding style goofs.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
for (wrote = 0; wrote < (count*wordsize); wrote += cur_size)
{
- cur_size = MIN((count*wordsize - wrote), sizeof(chunk));
struct flash_bank *bank;
+
bank = get_flash_bank_by_addr(target, address);
if (bank == NULL)
{
retval = ERROR_FAIL;
goto done;
}
+
+ cur_size = MIN((count * wordsize - wrote), chunksize);
err = flash_driver_write(bank, chunk, address - bank->base + wrote, cur_size);
if (err != ERROR_OK)
{
duration_elapsed(&bench), duration_kbps(&bench, wrote));
}
- done:
+done:
free(readback);
free(chunk);