diff mbox series

[RFC,15/15] drm/i915: Use vbt type to determine its validity

Message ID 20240108230517.1497504-16-radhakrishna.sripada@intel.com (mailing list archive)
State New, archived
Headers show
Series VBT read Cleanup | expand

Commit Message

Sripada, Radhakrishna Jan. 8, 2024, 11:05 p.m. UTC
We depend on a non null vbt field in intel_vbt to determine
if a vbt is read from its source. This may not be foolproof
hence rely on vbt->type to determine if vbt is read from a source.
Note that this does not determine the validity of read vbt.

Signed-off-by: Radhakrishna Sripada <radhakrishna.sripada@intel.com>
---
 drivers/gpu/drm/i915/display/intel_bios.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c
index 135a2d5d50b8..0938c9ec8fbe 100644
--- a/drivers/gpu/drm/i915/display/intel_bios.c
+++ b/drivers/gpu/drm/i915/display/intel_bios.c
@@ -3119,6 +3119,11 @@  static void oprom_get_vbt(struct drm_i915_private *i915,
 	return;
 }
 
+static inline bool is_empty_vbt(struct intel_vbt *vbt)
+{
+	return vbt && vbt->type == I915_VBT_NONE;
+}
+
 /**
  * intel_bios_init - find VBT and initialize settings from the BIOS
  * @i915: i915 device instance
@@ -3154,19 +3159,19 @@  void intel_bios_init(struct drm_i915_private *i915)
 
 	intel_load_vbt_firmware(i915, vbt);
 
-	if (!vbt->vbt && opregion->asls)
+	if (is_empty_vbt(vbt) && opregion->asls)
 		intel_load_opregion_vbt(i915, opregion, vbt);
 	/*
 	 * If the OpRegion does not have VBT, look in SPI flash through MMIO or
 	 * PCI mapping
 	 */
-	if (!vbt->vbt && IS_DGFX(i915))
+	if (is_empty_vbt(vbt) && IS_DGFX(i915))
 		spi_oprom_get_vbt(i915, vbt);
 
-	if (!vbt->vbt)
+	if (is_empty_vbt(vbt))
 		oprom_get_vbt(i915, vbt);
 
-	if (!vbt->vbt)
+	if (is_empty_vbt(vbt))
 		goto out;
 
 	header = (struct vbt_header *)vbt->vbt;