diff options
author | Patrick Georgi <pgeorgi@google.com> | 2018-08-24 22:45:50 +0000 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2018-08-25 03:16:04 +0000 |
commit | 24151963f36a4d1dac41d367bf1178e9de567a1b (patch) | |
tree | 9d49fde1c55196fd7cae887845855abf68e2f30a /src/drivers/spi | |
parent | 16ebc9831f156a03bd5ecd21e9365c09bfc43554 (diff) |
Revert "drivers/spi/spi_flash: don't allocate unbounded stack memory"
This reverts commit c5ee35ff861fe4447fd80119f645fba7bfd3a184.
Reason for revert: breaks boards, uncertain if it _really_ works.
Change-Id: I9ba2ba877b9a391306f89295c0c1d0e2d011c5ea
Signed-off-by: Patrick Georgi <pgeorgi@google.com>
Reviewed-on: https://review.coreboot.org/28338
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Jean Lucas <jean@4ray.co>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/drivers/spi')
-rw-r--r-- | src/drivers/spi/spi_flash.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c index 82333e9b0f..f2714791db 100644 --- a/src/drivers/spi/spi_flash.c +++ b/src/drivers/spi/spi_flash.c @@ -82,29 +82,24 @@ static int spi_flash_cmd_read(const struct spi_slave *spi, const u8 *cmd, 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 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 = 1; - struct spi_op vectors[] = { - [0] = { .dout = cmd, .bytesout = cmd_len, - .din = NULL, .bytesin = 0, }, - [1] = { .dout = data, .bytesout = data_len, - .din = NULL, .bytesin = 0, } - }; - size_t count = ARRAY_SIZE(vectors); - - if (spi_claim_bus(spi)) - return ret; - - if (spi_xfer_vector(spi, vectors, count) == 0) - ret = 0; + int ret; + u8 buff[cmd_len + data_len]; + memcpy(buff, cmd, cmd_len); + memcpy(buff + cmd_len, data, data_len); + ret = do_spi_flash_cmd(spi, buff, cmd_len + data_len, NULL, 0); if (ret) { printk(BIOS_WARNING, "SF: Failed to send write command (%zu bytes): %d\n", data_len, ret); } - spi_release_bus(spi); return ret; } |