Commit caf37fa4 authored by Jani Nikula's avatar Jani Nikula

drm/i915/bios: have functions return vbt, not bdb, header pointer

This will simplify further work.
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/d2c5210402fdd8c277e1d50892b0620d10c50ae8.1450089383.git.jani.nikula@intel.com
parent b30581a4
...@@ -1214,7 +1214,14 @@ init_vbt_defaults(struct drm_i915_private *dev_priv) ...@@ -1214,7 +1214,14 @@ init_vbt_defaults(struct drm_i915_private *dev_priv)
} }
} }
static const struct bdb_header *validate_vbt(const void *base, static const struct bdb_header *get_bdb_header(const struct vbt_header *vbt)
{
const void *_vbt = vbt;
return _vbt + vbt->bdb_offset;
}
static const struct vbt_header *validate_vbt(const void *base,
size_t size, size_t size,
const void *_vbt, const void *_vbt,
const char *source) const char *source)
...@@ -1223,6 +1230,9 @@ static const struct bdb_header *validate_vbt(const void *base, ...@@ -1223,6 +1230,9 @@ static const struct bdb_header *validate_vbt(const void *base,
const struct vbt_header *vbt = _vbt; const struct vbt_header *vbt = _vbt;
const struct bdb_header *bdb; const struct bdb_header *bdb;
if (!vbt)
return NULL;
if (offset + sizeof(struct vbt_header) > size) { if (offset + sizeof(struct vbt_header) > size) {
DRM_DEBUG_DRIVER("VBT header incomplete\n"); DRM_DEBUG_DRIVER("VBT header incomplete\n");
return NULL; return NULL;
...@@ -1239,7 +1249,7 @@ static const struct bdb_header *validate_vbt(const void *base, ...@@ -1239,7 +1249,7 @@ static const struct bdb_header *validate_vbt(const void *base,
return NULL; return NULL;
} }
bdb = base + offset; bdb = get_bdb_header(vbt);
if (offset + bdb->bdb_size > size) { if (offset + bdb->bdb_size > size) {
DRM_DEBUG_DRIVER("BDB incomplete\n"); DRM_DEBUG_DRIVER("BDB incomplete\n");
return NULL; return NULL;
...@@ -1247,12 +1257,12 @@ static const struct bdb_header *validate_vbt(const void *base, ...@@ -1247,12 +1257,12 @@ static const struct bdb_header *validate_vbt(const void *base,
DRM_DEBUG_KMS("Using VBT from %s: %20s\n", DRM_DEBUG_KMS("Using VBT from %s: %20s\n",
source, vbt->signature); source, vbt->signature);
return bdb; return vbt;
} }
static const struct bdb_header *find_vbt(void __iomem *bios, size_t size) static const struct vbt_header *find_vbt(void __iomem *bios, size_t size)
{ {
const struct bdb_header *bdb = NULL; const struct vbt_header *vbt = NULL;
size_t i; size_t i;
/* Scour memory looking for the VBT signature. */ /* Scour memory looking for the VBT signature. */
...@@ -1266,12 +1276,12 @@ static const struct bdb_header *find_vbt(void __iomem *bios, size_t size) ...@@ -1266,12 +1276,12 @@ static const struct bdb_header *find_vbt(void __iomem *bios, size_t size)
*/ */
void *_bios = (void __force *) bios; void *_bios = (void __force *) bios;
bdb = validate_vbt(_bios, size, _bios + i, "PCI ROM"); vbt = validate_vbt(_bios, size, _bios + i, "PCI ROM");
break; break;
} }
} }
return bdb; return vbt;
} }
/** /**
...@@ -1288,7 +1298,8 @@ intel_parse_bios(struct drm_device *dev) ...@@ -1288,7 +1298,8 @@ intel_parse_bios(struct drm_device *dev)
{ {
struct drm_i915_private *dev_priv = dev->dev_private; struct drm_i915_private *dev_priv = dev->dev_private;
struct pci_dev *pdev = dev->pdev; struct pci_dev *pdev = dev->pdev;
const struct bdb_header *bdb = NULL; const struct vbt_header *vbt;
const struct bdb_header *bdb;
u8 __iomem *bios = NULL; u8 __iomem *bios = NULL;
if (HAS_PCH_NOP(dev)) if (HAS_PCH_NOP(dev))
...@@ -1297,24 +1308,24 @@ intel_parse_bios(struct drm_device *dev) ...@@ -1297,24 +1308,24 @@ intel_parse_bios(struct drm_device *dev)
init_vbt_defaults(dev_priv); init_vbt_defaults(dev_priv);
/* XXX Should this validation be moved to intel_opregion.c? */ /* XXX Should this validation be moved to intel_opregion.c? */
if (dev_priv->opregion.vbt) vbt = validate_vbt(dev_priv->opregion.header, OPREGION_SIZE,
bdb = validate_vbt(dev_priv->opregion.header, OPREGION_SIZE,
dev_priv->opregion.vbt, "OpRegion"); dev_priv->opregion.vbt, "OpRegion");
if (!vbt) {
if (bdb == NULL) {
size_t size; size_t size;
bios = pci_map_rom(pdev, &size); bios = pci_map_rom(pdev, &size);
if (!bios) if (!bios)
return -1; return -1;
bdb = find_vbt(bios, size); vbt = find_vbt(bios, size);
if (!bdb) { if (!vbt) {
pci_unmap_rom(pdev, bios); pci_unmap_rom(pdev, bios);
return -1; return -1;
} }
} }
bdb = get_bdb_header(vbt);
/* Grab useful general definitions */ /* Grab useful general definitions */
parse_general_features(dev_priv, bdb); parse_general_features(dev_priv, bdb);
parse_general_definitions(dev_priv, bdb); parse_general_definitions(dev_priv, bdb);
......
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