diff options
author | Angel Pons <th3fanbus@gmail.com> | 2021-04-16 13:57:07 +0000 |
---|---|---|
committer | Nico Huber <nico.h@gmx.de> | 2021-04-18 11:02:51 +0000 |
commit | df40ca9d41ab1fcab3ddea3ce3c9aa95ab0da2b0 (patch) | |
tree | edd98046ca6a394ad86d1d42f576f84ce1088595 | |
parent | 4b29c4adeb877fe1b32cfa4ecea2cae9816fe3a8 (diff) |
Revert "drivers/spi: Stop using a variable-length array"
This reverts commit 59626b8670da326ab725e67b01dd1025b0a34a86.
Reason for revert: Reported to cause boot-loops. Reason unknown.
Change-Id: Id7f6211aaaf0401017176f63a17763f28d2744c8
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/52424
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r-- | src/drivers/spi/spi_flash.c | 14 | ||||
-rw-r--r-- | src/drivers/spi/spi_flash_internal.h | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 47b4b85b0d..b674749feb 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -88,15 +88,17 @@ int spi_flash_cmd(const struct spi_slave *spi, u8 cmd, void *response, size_t le return ret; } +/* TODO: This code is quite possibly broken and overflowing stacks. Fix ASAP! */ +#pragma GCC diagnostic push +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic ignored "-Wstack-usage=" +#endif +#pragma GCC diagnostic ignored "-Wvla" int spi_flash_cmd_write(const struct spi_slave *spi, const u8 *cmd, size_t cmd_len, const void *data, size_t data_len) { int ret; - u8 buff[4 + MAX_FLASH_CMD_DATA_SIZE]; - - if (ARRAY_SIZE(buff) < cmd_len + data_len) - return -1; - + u8 buff[cmd_len + data_len]; memcpy(buff, cmd, cmd_len); memcpy(buff + cmd_len, data, data_len); @@ -108,6 +110,7 @@ int spi_flash_cmd_write(const struct spi_slave *spi, const u8 *cmd, return ret; } +#pragma GCC diagnostic pop /* Perform the read operation honoring spi controller fifo size, reissuing * the read command until the full request completed. */ @@ -256,7 +259,6 @@ int spi_flash_cmd_write_page_program(const struct spi_flash *flash, u32 offset, byte_addr = offset % page_size; chunk_len = MIN(len - actual, page_size - byte_addr); chunk_len = spi_crop_chunk(&flash->spi, sizeof(cmd), chunk_len); - chunk_len = MIN(MAX_FLASH_CMD_DATA_SIZE, chunk_len); spi_flash_addr(offset, cmd); if (CONFIG(DEBUG_SPI_FLASH)) { diff --git a/src/drivers/spi/spi_flash_internal.h b/src/drivers/spi/spi_flash_internal.h index 7fe3ea6038..b4d39b3d31 100644 --- a/src/drivers/spi/spi_flash_internal.h +++ b/src/drivers/spi/spi_flash_internal.h @@ -24,8 +24,6 @@ /* Common status */ #define STATUS_WIP 0x01 -#define MAX_FLASH_CMD_DATA_SIZE 256 - /* Send a single-byte command to the device and read the response */ int spi_flash_cmd(const struct spi_slave *spi, u8 cmd, void *response, size_t len); |