summaryrefslogtreecommitdiffstats
path: root/ichspi.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-06-17 10:13:42 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-06-17 10:13:42 +0000
commitd168057805592ec441d74df3f2e8e454f9a2fde6 (patch)
tree89cc67a9b9f00075f5329f208674b2020b0c1034 /ichspi.c
parent4e587905aeaf544c94e96f508a1b2e1294b31b0d (diff)
downloadast2050-flashrom-d168057805592ec441d74df3f2e8e454f9a2fde6.zip
ast2050-flashrom-d168057805592ec441d74df3f2e8e454f9a2fde6.tar.gz
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>
Diffstat (limited to 'ichspi.c')
-rw-r--r--ichspi.c27
1 files changed, 7 insertions, 20 deletions
diff --git a/ichspi.c b/ichspi.c
index 9091230..3806529 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -617,30 +617,17 @@ static int ich_spi_write_page(struct flashchip *flash, uint8_t * bytes,
{
int page_size = flash->page_size;
uint32_t remaining = page_size;
- int a;
+ int towrite;
printf_debug("ich_spi_write_page: offset=%d, number=%d, buf=%p\n",
offset, page_size, bytes);
- for (a = 0; a < page_size; a += maxdata) {
- if (remaining < maxdata) {
- if (run_opcode
- (curopcodes->opcode[0],
- offset + (page_size - remaining), remaining,
- &bytes[page_size - remaining]) != 0) {
- printf_debug("Error writing");
- 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;
+ for (; remaining > 0; remaining -= towrite) {
+ towrite = min(remaining, maxdata);
+ if (spi_nbyte_program(offset + (page_size - remaining),
+ &bytes[page_size - remaining], towrite)) {
+ printf_debug("Error writing");
+ return 1;
}
}
OpenPOWER on IntegriCloud