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>
			
			
This commit is contained in:
		
				
					committed by
					
						 Furquan Shaikh
						Furquan Shaikh
					
				
			
			
				
	
			
			
			
						parent
						
							d3d1f13599
						
					
				
				
					commit
					810e2cde30
				
			| @@ -10,6 +10,7 @@ | ||||
| #include <stdlib.h> | ||||
| #include <spi_flash.h> | ||||
| #include <spi-generic.h> | ||||
| #include <string.h> | ||||
|  | ||||
| #include "spi_flash_internal.h" | ||||
|  | ||||
| @@ -96,7 +97,7 @@ static int eon_write(const struct spi_flash *flash, | ||||
| 		chunk_len = min(len - actual, page_size - byte_addr); | ||||
| 		chunk_len = spi_crop_chunk(sizeof(cmd), chunk_len); | ||||
|  | ||||
| 		ret = spi_flash_cmd(flash->spi, CMD_EN25_WREN, NULL, 0); | ||||
| 		ret = spi_flash_cmd(&flash->spi, CMD_EN25_WREN, NULL, 0); | ||||
| 		if (ret < 0) { | ||||
| 			printk(BIOS_WARNING, "SF: Enabling Write failed\n"); | ||||
| 			goto out; | ||||
| @@ -113,7 +114,7 @@ static int eon_write(const struct spi_flash *flash, | ||||
| 		     buf + actual, cmd[0], cmd[1], cmd[2], cmd[3], chunk_len); | ||||
| #endif | ||||
|  | ||||
| 		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: EON Page Program failed\n"); | ||||
| @@ -164,7 +165,7 @@ struct spi_flash *spi_flash_probe_eon(struct spi_slave *spi, u8 *idcode) | ||||
| 	} | ||||
|  | ||||
| 	eon->params = params; | ||||
| 	eon->flash.spi = spi; | ||||
| 	memcpy(&eon->flash.spi, spi, sizeof(*spi)); | ||||
| 	eon->flash.name = params->name; | ||||
|  | ||||
| 	eon->flash.internal_write = eon_write; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user