[coreboot-gerrit] Change in coreboot[master]: drivers/spi/spi_flash: Use boot_device_spi_flash to obtain s...

Furquan Shaikh (Code Review) gerrit at coreboot.org
Fri May 19 21:21:00 CEST 2017


Furquan Shaikh has submitted this change and it was merged. ( https://review.coreboot.org/19703 )

Change subject: drivers/spi/spi_flash: Use boot_device_spi_flash to obtain spi_flash structure
......................................................................


drivers/spi/spi_flash: Use boot_device_spi_flash to obtain spi_flash structure

Instead of storing spi flash device structure in spi flash driver, use
boot_device_spi_flash callback to obtain pointer to boot device spi
flash structure.

BUG=b:38330715

Change-Id: Idd50b7644d1a4be8b62d38cc9239feae2215103c
Signed-off-by: Furquan Shaikh <furquan at chromium.org>
Reviewed-on: https://review.coreboot.org/19703
Tested-by: build bot (Jenkins) <no-reply at coreboot.org>
Reviewed-by: Aaron Durbin <adurbin at chromium.org>
---
M src/drivers/spi/spi_flash.c
1 file changed, 2 insertions(+), 13 deletions(-)

Approvals:
  Aaron Durbin: Looks good to me, approved
  build bot (Jenkins): Verified



diff --git a/src/drivers/spi/spi_flash.c b/src/drivers/spi/spi_flash.c
index 95362f2..e84df73 100644
--- a/src/drivers/spi/spi_flash.c
+++ b/src/drivers/spi/spi_flash.c
@@ -22,8 +22,6 @@
 #include "spi_flash_internal.h"
 #include <timer.h>
 
-static struct spi_flash *spi_flash_dev = NULL;
-
 static void spi_flash_addr(u32 addr, u8 *cmd)
 {
 	/* cmd[0] is actual command */
@@ -357,14 +355,6 @@
 	printk(BIOS_INFO, "SF: Detected %s with sector size 0x%x, total 0x%x\n",
 			flash->name, flash->sector_size, flash->size);
 
-	/*
-	 * Only set the global spi_flash_dev if this is the boot
-	 * device's bus and it's previously unset while in ramstage.
-	 */
-	if (ENV_RAMSTAGE && IS_ENABLED(CONFIG_BOOT_DEVICE_SPI_FLASH) &&
-		CONFIG_BOOT_DEVICE_SPI_FLASH_BUS == bus && !spi_flash_dev)
-		spi_flash_dev = flash;
-
 	return flash;
 }
 
@@ -451,6 +441,7 @@
 void lb_spi_flash(struct lb_header *header)
 {
 	struct lb_spi_flash *flash;
+	const struct spi_flash *spi_flash_dev;
 
 	if (!IS_ENABLED(CONFIG_BOOT_DEVICE_SPI_FLASH))
 		return;
@@ -460,9 +451,7 @@
 	flash->tag = LB_TAG_SPI_FLASH;
 	flash->size = sizeof(*flash);
 
-	/* Try to get the flash device if not loaded yet */
-	if (!spi_flash_dev)
-		boot_device_init();
+	spi_flash_dev = boot_device_spi_flash();
 
 	if (spi_flash_dev) {
 		flash->flash_size = spi_flash_dev->size;

-- 
To view, visit https://review.coreboot.org/19703
To unsubscribe, visit https://review.coreboot.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idd50b7644d1a4be8b62d38cc9239feae2215103c
Gerrit-PatchSet: 9
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Owner: Furquan Shaikh <furquan at google.com>
Gerrit-Reviewer: Aaron Durbin <adurbin at chromium.org>
Gerrit-Reviewer: Duncan Laurie <dlaurie at chromium.org>
Gerrit-Reviewer: Furquan Shaikh <furquan at google.com>
Gerrit-Reviewer: Paul Menzel <paulepanter at users.sourceforge.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply at coreboot.org>



More information about the coreboot-gerrit mailing list