From ca812d40d461e70a70df6079978e96642775e7b2 Mon Sep 17 00:00:00 2001 From: Carl-Daniel Hailfinger Date: Wed, 14 Jul 2010 19:57:52 +0000 Subject: Use the max_rom_decode infrastructure for wbsio_spi Use this instead of the open-coding variant that only aborts after it is too late. Corresponding to flashrom svn r1081. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Michael Karcher --- flash.h | 1 - spi.c | 2 +- wbsio_spi.c | 20 +++----------------- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/flash.h b/flash.h index 1b82d42..2065109 100644 --- a/flash.h +++ b/flash.h @@ -716,7 +716,6 @@ int wbsio_check_for_spi(void); 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 --git a/spi.c b/spi.c index 94dbe9e..9a31abf 100644 --- a/spi.c +++ b/spi.c @@ -80,7 +80,7 @@ const struct spi_programmer spi_programmer[] = { .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 --git a/wbsio_spi.c b/wbsio_spi.c index 8db6524..b8f8b38 100644 --- a/wbsio_spi.c +++ b/wbsio_spi.c @@ -69,6 +69,9 @@ int wbsio_check_for_spi(void) 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_send_command(unsigned int writecnt, unsigned int readcnt, 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 -- cgit v1.1