summaryrefslogtreecommitdiff
path: root/src/drivers/spi/atmel.c
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2016-12-05 20:32:24 -0800
committerFurquan Shaikh <furquan@google.com>2016-12-06 07:17:28 +0100
commit810e2cde30035d0de691805041ffeeff57f68027 (patch)
tree99706a026be4551118b334773ccb61a6f5772005 /src/drivers/spi/atmel.c
parentd3d1f13599a042bfd7ecb5f11f5a8a76853b7f88 (diff)
downloadcoreboot-810e2cde30035d0de691805041ffeeff57f68027.tar.xz
spi_flash: Make a deep copy of spi_slave structure
Commit 36b81af (spi: Pass pointer to spi_slave structure in spi_setup_slave) changes the way spi_setup_slave handles the spi_slave structure. Instead of expecting spi controller drivers to maintain spi_slave structure in CAR_GLOBAL/data section, caller is expected to manage the spi_slave structure. This requires that spi_flash drivers maintain spi_slave structure and flash probe function needs to make a copy of the passed in spi_slave structure. This change fixes the regression on Lenovo X230 and other mainboards. Change-Id: I0ad971eecaf3bfe301e9f95badc043193cc27cab Signed-off-by: Furquan Shaikh <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/17728 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org> Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Iru Cai <mytbk920423@gmail.com>
Diffstat (limited to 'src/drivers/spi/atmel.c')
-rw-r--r--src/drivers/spi/atmel.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/drivers/spi/atmel.c b/src/drivers/spi/atmel.c
index e53889205d..feb1a6d1fd 100644
--- a/src/drivers/spi/atmel.c
+++ b/src/drivers/spi/atmel.c
@@ -10,6 +10,8 @@
#include <stdlib.h>
#include <spi_flash.h>
#include <spi-generic.h>
+#include <string.h>
+
#include "spi_flash_internal.h"
/* M25Pxx-specific commands */
@@ -135,13 +137,13 @@ static int atmel_write(const struct spi_flash *flash, u32 offset, size_t len,
cmd[0], cmd[1], cmd[2], cmd[3], chunk_len);
#endif
- ret = spi_flash_cmd(flash->spi, CMD_AT25_WREN, NULL, 0);
+ ret = spi_flash_cmd(&flash->spi, CMD_AT25_WREN, NULL, 0);
if (ret < 0) {
printk(BIOS_WARNING, "SF: Enabling Write failed\n");
goto out;
}
- ret = spi_flash_cmd_write(flash->spi, cmd, sizeof(cmd),
+ ret = spi_flash_cmd_write(&flash->spi, cmd, sizeof(cmd),
buf + actual, chunk_len);
if (ret < 0) {
printk(BIOS_WARNING, "SF: Atmel Page Program failed\n");
@@ -192,7 +194,7 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode)
}
stm->params = params;
- stm->flash.spi = spi;
+ memcpy(&stm->flash.spi, spi, sizeof(*spi));
stm->flash.name = params->name;
/* Assuming power-of-two page size initially. */