[coreboot-gerrit] Change in coreboot[master]: soc/intel/common: refactor locate_vbt

Patrick Georgi (Code Review) gerrit at coreboot.org
Thu Oct 5 18:20:10 CEST 2017


Patrick Georgi has uploaded this change for review. ( https://review.coreboot.org/21896


Change subject: soc/intel/common: refactor locate_vbt
......................................................................

soc/intel/common: refactor locate_vbt

All callers of locate_vbt just care about the file content and
immediately map the rdev for its content.
Instead of repeating this in all call sites, move that code to
locate_vbt.

Change-Id: I5b518e6c959437bd8f393269db7955358a786719
Signed-off-by: Patrick Georgi <pgeorgi at google.com>
---
M src/drivers/intel/fsp2_0/graphics.c
M src/soc/intel/common/opregion.c
M src/soc/intel/common/vbt.c
M src/soc/intel/common/vbt.h
4 files changed, 9 insertions(+), 22 deletions(-)



  git pull ssh://review.coreboot.org:29418/coreboot refs/changes/96/21896/1

diff --git a/src/drivers/intel/fsp2_0/graphics.c b/src/drivers/intel/fsp2_0/graphics.c
index 84f2d6d..e2ff7cf 100644
--- a/src/drivers/intel/fsp2_0/graphics.c
+++ b/src/drivers/intel/fsp2_0/graphics.c
@@ -99,8 +99,7 @@
 	struct region_device rdev;
 	void *vbt_data = NULL;
 
-	if (locate_vbt(&rdev) != CB_ERR)
-		vbt_data = rdev_mmap_full(&rdev);
+	vbt_data = locate_vbt(&rdev);
 
 	if (vbt_data == NULL)
 		printk(BIOS_NOTICE, "Could not locate a VBT file in CBFS\n");
diff --git a/src/soc/intel/common/opregion.c b/src/soc/intel/common/opregion.c
index 6cb388c..1eb8609 100644
--- a/src/soc/intel/common/opregion.c
+++ b/src/soc/intel/common/opregion.c
@@ -27,12 +27,7 @@
 	optionrom_vbt_t *vbt;
 	optionrom_vbt_t *ext_vbt;
 
-	if (locate_vbt(&vbt_rdev) == CB_ERR) {
-		printk(BIOS_ERR, "VBT not found\n");
-		return CB_ERR;
-	};
-
-	vbt = rdev_mmap_full(&vbt_rdev);
+	vbt = locate_vbt(&vbt_rdev);
 
 	if (!vbt) {
 		printk(BIOS_ERR, "VBT couldn't be read\n");
diff --git a/src/soc/intel/common/vbt.c b/src/soc/intel/common/vbt.c
index 40ff4ce..5b23843 100644
--- a/src/soc/intel/common/vbt.c
+++ b/src/soc/intel/common/vbt.c
@@ -31,7 +31,7 @@
 	return vbt_filename;
 }
 
-enum cb_err locate_vbt(struct region_device *rdev)
+void *locate_vbt(struct region_device *rdev)
 {
 	uint32_t vbtsig = 0;
 	struct cbfsf file_desc;
@@ -40,7 +40,7 @@
 
 	if (cbfs_boot_locate(&file_desc, filename, NULL) < 0) {
 		printk(BIOS_ERR, "Could not locate a VBT file in in CBFS\n");
-		return CB_ERR;
+		return NULL;
 	}
 
 	cbfs_file_data(rdev, &file_desc);
@@ -48,16 +48,14 @@
 
 	if (vbtsig != VBT_SIGNATURE) {
 		printk(BIOS_ERR, "Missing/invalid signature in VBT data file!\n");
-		return CB_ERR;
+		return NULL;
 	}
 
-	return CB_SUCCESS;
+	return rdev_mmap_full(rdev);
 }
 
 void *vbt_get(struct region_device *rdev)
 {
-	void *vbt_data;
-
 	if (!IS_ENABLED(CONFIG_RUN_FSP_GOP))
 		return NULL;
 
@@ -67,10 +65,5 @@
 		return NULL;
 	if (!display_init_required())
 		return NULL;
-	if (locate_vbt(rdev) != CB_ERR) {
-		vbt_data = rdev_mmap_full(rdev);
-		return vbt_data;
-	} else {
-		return NULL;
-	}
+	return locate_vbt(rdev);
 }
diff --git a/src/soc/intel/common/vbt.h b/src/soc/intel/common/vbt.h
index 7b65d74..2d52fea 100644
--- a/src/soc/intel/common/vbt.h
+++ b/src/soc/intel/common/vbt.h
@@ -27,8 +27,8 @@
  */
 const char *mainboard_vbt_filename(void);
 
-/* locate .vbt file */
-enum cb_err locate_vbt(struct region_device *rdev);
+/* locate vbt.bin file. Returns a pointer to its content. */
+void *locate_vbt(struct region_device *rdev);
 /*
  * Returns VBT pointer and mapping after checking prerequisites for Pre OS
  * Graphics initialization

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

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5b518e6c959437bd8f393269db7955358a786719
Gerrit-Change-Number: 21896
Gerrit-PatchSet: 1
Gerrit-Owner: Patrick Georgi <pgeorgi at google.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.coreboot.org/pipermail/coreboot-gerrit/attachments/20171005/66d8ee69/attachment.html>


More information about the coreboot-gerrit mailing list