Commit b34a991a authored by Jani Nikula's avatar Jani Nikula Committed by Daniel Vetter

drm/i915/bios: abstract finding VBT in BIOS to a separate function

Improve clarity. No functional changes.
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 4d70f38a
...@@ -1235,6 +1235,22 @@ static const struct bdb_header *validate_vbt(const void *base, size_t size, ...@@ -1235,6 +1235,22 @@ static const struct bdb_header *validate_vbt(const void *base, size_t size,
return bdb; return bdb;
} }
static const struct bdb_header *find_vbt(void *bios, size_t size)
{
const struct bdb_header *bdb = NULL;
size_t i;
/* Scour memory looking for the VBT signature. */
for (i = 0; i + 4 < size; i++) {
if (memcmp(bios + i, "$VBT", 4) == 0) {
bdb = validate_vbt(bios, size, bios + i, "PCI ROM");
break;
}
}
return bdb;
}
/** /**
* intel_parse_bios - find VBT and initialize settings from the BIOS * intel_parse_bios - find VBT and initialize settings from the BIOS
* @dev: DRM device * @dev: DRM device
...@@ -1263,22 +1279,13 @@ intel_parse_bios(struct drm_device *dev) ...@@ -1263,22 +1279,13 @@ intel_parse_bios(struct drm_device *dev)
dev_priv->opregion.vbt, "OpRegion"); dev_priv->opregion.vbt, "OpRegion");
if (bdb == NULL) { if (bdb == NULL) {
size_t i, size; size_t size;
bios = pci_map_rom(pdev, &size); bios = pci_map_rom(pdev, &size);
if (!bios) if (!bios)
return -1; return -1;
/* Scour memory looking for the VBT signature */ bdb = find_vbt(bios, size);
for (i = 0; i + 4 < size; i++) {
if (memcmp(bios + i, "$VBT", 4) == 0) {
bdb = validate_vbt(bios, size,
bios + i,
"PCI ROM");
break;
}
}
if (!bdb) { if (!bdb) {
pci_unmap_rom(pdev, bios); pci_unmap_rom(pdev, bios);
return -1; return -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment