[flashrom] [PATCH] Use max_rom_decode for wbsio_spi
Carl-Daniel Hailfinger
c-d.hailfinger.devel.2006 at gmx.net
Sun Jul 11 00:25:52 CEST 2010
Use the max_rom_decode infrastructure for wbsio_spi instead of
open-coding a variant which only aborts after it is too late.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
diff -ur flashrom-partial_write_spi_intermediate/flash.h flashrom-wbsio_max_decode/flash.h
--- flashrom-partial_write_spi_intermediate/flash.h 2010-07-11 00:05:36.000000000 +0200
+++ flashrom-wbsio_max_decode/flash.h 2010-07-11 00:15:31.000000000 +0200
@@ -716,7 +716,6 @@
int wbsio_spi_send_command(unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len);
-int wbsio_spi_write_1(struct flashchip *flash, uint8_t *buf, int start, int len);
/* serprog.c */
int serprog_init(void);
diff -ur flashrom-partial_write_spi_intermediate/spi.c flashrom-wbsio_max_decode/spi.c
--- flashrom-partial_write_spi_intermediate/spi.c 2010-07-11 00:09:26.000000000 +0200
+++ flashrom-wbsio_max_decode/spi.c 2010-07-11 00:16:22.000000000 +0200
@@ -80,7 +80,7 @@
.command = wbsio_spi_send_command,
.multicommand = default_spi_send_multicommand,
.read = wbsio_spi_read,
- .write_256 = wbsio_spi_write_1,
+ .write_256 = spi_chip_write_1_new,
},
#endif
#endif
diff -ur flashrom-partial_write_spi_intermediate/wbsio_spi.c flashrom-wbsio_max_decode/wbsio_spi.c
--- flashrom-partial_write_spi_intermediate/wbsio_spi.c 2010-07-09 19:09:49.000000000 +0200
+++ flashrom-wbsio_max_decode/wbsio_spi.c 2010-07-11 00:18:38.000000000 +0200
@@ -69,6 +69,9 @@
buses_supported |= CHIP_BUSTYPE_SPI;
spi_controller = SPI_CONTROLLER_WBSIO;
+ msg_pdbg("%s: Winbond saved on 4 register bits so max chip size is "
+ "1024 KB!\n", __func__);
+ max_rom_decode.spi = 1024 * 1024;
return 0;
}
@@ -179,24 +182,7 @@
int wbsio_spi_read(struct flashchip *flash, uint8_t *buf, int start, int len)
{
- int size = flash->total_size * 1024;
-
- if (size > 1024 * 1024) {
- msg_perr("%s: Winbond saved on 4 register bits so max chip size is 1024 KB!\n", __func__);
- return 1;
- }
-
return read_memmapped(flash, buf, start, len);
}
-int wbsio_spi_write_1(struct flashchip *flash, uint8_t *buf, int start, int len)
-{
- if (flash->total_size * 1024 > 1024 * 1024) {
- msg_perr("%s: Winbond saved on 4 register bits so max chip size is 1024 KB!\n", __func__);
- return 1;
- }
-
- return spi_chip_write_1_new(flash, buf, start, len);
-}
-
#endif
--
http://www.hailfinger.org/
More information about the flashrom
mailing list