[flashrom] [PATCH] Refactor remaining write wrappers
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Sat Oct 9 23:59:24 CEST 2010
Refactor remaining write wrappers.
Kill duplicated code.
Depends on
Re: [flashrom] [PATCH] Use common function signature for inner write
functions
[flashrom] [PATCH] Simplify calls to inner write functions
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
--- flashrom-partial_write_inner_function_signature_simplify_calls/chipdrivers.h 2010-10-09 02:16:56.000000000 +0200
+++ flashrom-partial_write_inner_function_signature_simplify_calls_simplify/chipdrivers.h 2010-10-09 19:34:40.000000000 +0200
@@ -106,10 +106,11 @@
int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size);
int write_28sf040(struct flashchip *flash, uint8_t *buf);
int write_sector_28sf040(struct flashchip *flash, uint8_t *src, int start, int len);
+int unprotect_28sf040(struct flashchip *flash);
+int protect_28sf040(struct flashchip *flash);
/* sst49lfxxxc.c */
int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigned int sector_size);
-int write_49lfxxxc(struct flashchip *flash, uint8_t *buf);
int unlock_49lfxxxc(struct flashchip *flash);
/* sst_fwhub.c */
--- flashrom-partial_write_inner_function_signature_simplify_calls/flashchips.c 2010-10-08 23:34:41.000000000 +0200
+++ flashrom-partial_write_inner_function_signature_simplify_calls_simplify/flashchips.c 2010-10-09 19:26:17.000000000 +0200
@@ -5107,6 +5107,8 @@
.block_erase = erase_chip_28sf040,
}
},
+ .unlock = unprotect_28sf040,
+ .lock = protect_28sf040,
.write = write_28sf040,
.read = read_memmapped,
},
@@ -5564,7 +5566,7 @@
}
},
.unlock = unlock_49lfxxxc,
- .write = write_49lfxxxc,
+ .write = write_82802ab,
.read = read_memmapped,
},
@@ -5627,7 +5629,7 @@
}
},
.unlock = unlock_49lfxxxc,
- .write = write_49lfxxxc,
+ .write = write_82802ab,
.read = read_memmapped,
},
@@ -5659,7 +5661,7 @@
}
},
.unlock = unlock_49lfxxxc,
- .write = write_49lfxxxc,
+ .write = write_82802ab,
.read = read_memmapped,
},
@@ -5837,7 +5839,7 @@
}
},
.unlock = unlock_49lfxxxc,
- .write = write_49lfxxxc,
+ .write = write_82802ab,
.read = read_memmapped,
},
--- flashrom-partial_write_inner_function_signature_simplify_calls/flash.h 2010-10-08 02:44:28.000000000 +0200
+++ flashrom-partial_write_inner_function_signature_simplify_calls_simplify/flash.h 2010-10-09 18:58:56.000000000 +0200
@@ -135,6 +135,7 @@
int (*printlock) (struct flashchip *flash);
int (*unlock) (struct flashchip *flash);
+ int (*lock) (struct flashchip *flash);
int (*write) (struct flashchip *flash, uint8_t *buf);
int (*read) (struct flashchip *flash, uint8_t *buf, int start, int len);
--- flashrom-partial_write_inner_function_signature_simplify_calls/sst28sf040.c 2010-10-09 02:00:30.000000000 +0200
+++ flashrom-partial_write_inner_function_signature_simplify_calls_simplify/sst28sf040.c 2010-10-09 19:35:09.000000000 +0200
@@ -30,7 +30,7 @@
#define RESET 0xFF
#define READ_ID 0x90
-static void protect_28sf040(struct flashchip *flash)
+int protect_28sf040(struct flashchip *flash)
{
chipaddr bios = flash->virtual_memory;
@@ -41,9 +41,11 @@
chip_readb(bios + 0x041B);
chip_readb(bios + 0x0419);
chip_readb(bios + 0x040A);
+
+ return 0;
}
-static void unprotect_28sf040(struct flashchip *flash)
+int unprotect_28sf040(struct flashchip *flash)
{
chipaddr bios = flash->virtual_memory;
@@ -54,12 +56,15 @@
chip_readb(bios + 0x041B);
chip_readb(bios + 0x0419);
chip_readb(bios + 0x041A);
+
+ return 0;
}
int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned int sector_size)
{
chipaddr bios = flash->virtual_memory;
+ /* This command sequence is very similar to erase_block_82802ab. */
chip_writeb(AUTO_PG_ERASE1, bios);
chip_writeb(AUTO_PG_ERASE2, bios + address);
@@ -118,13 +123,7 @@
int write_28sf040(struct flashchip *flash, uint8_t *buf)
{
- unprotect_28sf040(flash);
-
- write_sector_28sf040(flash, buf, 0, flash->total_size * 1024);
-
- protect_28sf040(flash);
-
- return 0;
+ return write_sector_28sf040(flash, buf, 0, flash->total_size * 1024);
}
int erase_chip_28sf040(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
--- flashrom-partial_write_inner_function_signature_simplify_calls/sst49lfxxxc.c 2010-10-09 02:00:06.000000000 +0200
+++ flashrom-partial_write_inner_function_signature_simplify_calls_simplify/sst49lfxxxc.c 2010-10-09 19:27:34.000000000 +0200
@@ -75,15 +75,3 @@
}
return 0;
}
-
-int write_49lfxxxc(struct flashchip *flash, uint8_t *buf)
-{
- chipaddr bios = flash->virtual_memory;
-
- write_lockbits_49lfxxxc(flash, 0);
- write_page_82802ab(flash, buf, 0, flash->total_size * 1024);
-
- chip_writeb(0xFF, bios);
-
- return 0;
-}
--
http://www.hailfinger.org/
More information about the flashrom
mailing list