1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-29 16:03:47 +02:00

Use spi_nbyte_program in ichspi.c

This shortens the code a lot and makes it more readable.

Corresponding to flashrom svn r600.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Ronald G. Minnich <rminnich@gmail.com>
This commit is contained in:
Carl-Daniel Hailfinger 2009-06-17 10:13:42 +00:00
parent 4e587905ae
commit d168057805

View File

@ -617,31 +617,18 @@ static int ich_spi_write_page(struct flashchip *flash, uint8_t * bytes,
{ {
int page_size = flash->page_size; int page_size = flash->page_size;
uint32_t remaining = page_size; uint32_t remaining = page_size;
int a; int towrite;
printf_debug("ich_spi_write_page: offset=%d, number=%d, buf=%p\n", printf_debug("ich_spi_write_page: offset=%d, number=%d, buf=%p\n",
offset, page_size, bytes); offset, page_size, bytes);
for (a = 0; a < page_size; a += maxdata) { for (; remaining > 0; remaining -= towrite) {
if (remaining < maxdata) { towrite = min(remaining, maxdata);
if (run_opcode if (spi_nbyte_program(offset + (page_size - remaining),
(curopcodes->opcode[0], &bytes[page_size - remaining], towrite)) {
offset + (page_size - remaining), remaining,
&bytes[page_size - remaining]) != 0) {
printf_debug("Error writing"); printf_debug("Error writing");
return 1; return 1;
} }
remaining = 0;
} else {
if (run_opcode
(curopcodes->opcode[0],
offset + (page_size - remaining), maxdata,
&bytes[page_size - remaining]) != 0) {
printf_debug("Error writing");
return 1;
}
remaining -= maxdata;
}
} }
return 0; return 0;