[flashrom] [PATCH] Simplify calls to inner write functions
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Sat Oct 9 23:56:13 CEST 2010
Simplify calls to inner write functions. No behavioural changes, just
equivalence transformations.
Depends on
Re: [flashrom] [PATCH] Use common function signature for inner write
functions
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
--- flashrom-partial_write_inner_function_signature/82802ab.c 2010-10-09 02:26:24.000000000 +0200
+++ flashrom-partial_write_inner_function_signature_simplify_calls/82802ab.c 2010-10-09 02:16:44.000000000 +0200
@@ -162,13 +162,7 @@
int write_82802ab(struct flashchip *flash, uint8_t *buf)
{
- int i;
-
- for (i = 0; i < flash->total_size; i++) {
- write_page_82802ab(flash, buf + i * 1024, i * 1024, 1024);
- }
-
- return 0;
+ return write_page_82802ab(flash, buf, 0, flash->total_size * 1024);
}
int unlock_28f004s5(struct flashchip *flash)
--- flashrom-partial_write_inner_function_signature/jedec.c 2010-10-09 02:26:24.000000000 +0200
+++ flashrom-partial_write_inner_function_signature_simplify_calls/jedec.c 2010-10-09 01:54:26.000000000 +0200
@@ -411,16 +411,11 @@
int write_jedec_1(struct flashchip *flash, uint8_t * buf)
{
- int i;
int mask;
mask = getaddrmask(flash);
- for (i = 0; i < flash->total_size; i++) {
- write_sector_jedec_common(flash, buf + i * 1024, i * 1024, 1024, mask);
- }
-
- return 0;
+ return write_sector_jedec_common(flash, buf, 0, flash->total_size * 1024, mask);
}
/* erase chip with block_erase() prototype */
--- flashrom-partial_write_inner_function_signature/m29f400bt.c 2010-10-09 02:26:24.000000000 +0200
+++ flashrom-partial_write_inner_function_signature_simplify_calls/m29f400bt.c 2010-10-09 02:15:53.000000000 +0200
@@ -142,18 +142,5 @@
int write_m29f400bt(struct flashchip *flash, uint8_t *buf)
{
- int i;
- int total_size = flash->total_size * 1024;
- int page_size = flash->page_size;
-
- for (i = 0; i < (total_size / page_size) - 1; i++) {
- write_page_m29f400bt(flash, buf + i * page_size, i * page_size, page_size);
- }
-
- write_page_m29f400bt(flash, buf + 0x70000, 0x70000, 32 * 1024);
- write_page_m29f400bt(flash, buf + 0x78000, 0x78000, 8 * 1024);
- write_page_m29f400bt(flash, buf + 0x7a000, 0x7a000, 8 * 1024);
- write_page_m29f400bt(flash, buf + 0x7c000, 0x7c000, 16 * 1024);
-
- return 0;
+ return write_page_m29f400bt(flash, buf, 0, flash->total_size * 1024);
}
--- flashrom-partial_write_inner_function_signature/sharplhf00l04.c 2010-10-08 23:37:52.000000000 +0200
+++ flashrom-partial_write_inner_function_signature_simplify_calls/sharplhf00l04.c 2010-10-09 03:48:21.000000000 +0200
@@ -56,16 +56,3 @@
}
return 0;
}
-
-int write_lhf00l04(struct flashchip *flash, uint8_t *buf)
-{
- int i;
- int total_size = flash->total_size * 1024;
- int page_size = flash->page_size;
-
- for (i = 0; i < total_size / page_size; i++) {
- write_page_82802ab(flash, buf + i * page_size, i * page_size, page_size);
- }
-
- return 0;
-}
--- flashrom-partial_write_inner_function_signature/sst28sf040.c 2010-10-09 02:26:24.000000000 +0200
+++ flashrom-partial_write_inner_function_signature_simplify_calls/sst28sf040.c 2010-10-09 02:00:30.000000000 +0200
@@ -118,15 +118,9 @@
int write_28sf040(struct flashchip *flash, uint8_t *buf)
{
- int i;
- int total_size = flash->total_size * 1024;
- int page_size = flash->page_size;
-
unprotect_28sf040(flash);
- for (i = 0; i < total_size / page_size; i++) {
- write_sector_28sf040(flash, buf + i * page_size, i * page_size, page_size);
- }
+ write_sector_28sf040(flash, buf, 0, flash->total_size * 1024);
protect_28sf040(flash);
--- flashrom-partial_write_inner_function_signature/sst49lfxxxc.c 2010-10-09 00:18:55.000000000 +0200
+++ flashrom-partial_write_inner_function_signature_simplify_calls/sst49lfxxxc.c 2010-10-09 02:00:06.000000000 +0200
@@ -78,15 +78,10 @@
int write_49lfxxxc(struct flashchip *flash, uint8_t *buf)
{
- int i;
- int total_size = flash->total_size * 1024;
- int page_size = flash->page_size;
chipaddr bios = flash->virtual_memory;
write_lockbits_49lfxxxc(flash, 0);
- for (i = 0; i < total_size / page_size; i++) {
- write_page_82802ab(flash, buf + i * page_size, i * page_size, page_size);
- }
+ write_page_82802ab(flash, buf, 0, flash->total_size * 1024);
chip_writeb(0xFF, bios);
--
http://www.hailfinger.org/
More information about the flashrom
mailing list