]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/bios: Extract intel_spi_read16()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 23 Sep 2024 15:24:51 +0000 (18:24 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 1 Oct 2024 14:30:52 +0000 (17:30 +0300)
The SPI VBT codepath only knows how to read 4 bytes at a time.
So to read the 2 byte vbt_size it masks out the unwanted msbs.
Hide that little implementation detail inside a new intel_spi_read16()
helper. Alse rename the existing intel_spi_read() to intel_spi_read32()
to make it clear what it does.

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240923152453.11230-5-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/display/intel_bios.c

index d4281234773ca56450883a8de99aa781ad394601..38ea92b4ff13ed8cf3359aa159e5ba4c024d3119 100644 (file)
@@ -3053,13 +3053,18 @@ static struct vbt_header *firmware_get_vbt(struct intel_display *display,
        return vbt;
 }
 
-static u32 intel_spi_read(struct intel_uncore *uncore, u32 offset)
+static u32 intel_spi_read32(struct intel_uncore *uncore, u32 offset)
 {
        intel_uncore_write(uncore, PRIMARY_SPI_ADDRESS, offset);
 
        return intel_uncore_read(uncore, PRIMARY_SPI_TRIGGER);
 }
 
+static u16 intel_spi_read16(struct intel_uncore *uncore, u32 offset)
+{
+       return intel_spi_read32(uncore, offset) & 0xffff;
+}
+
 static struct vbt_header *spi_oprom_get_vbt(struct intel_display *display,
                                            size_t *size)
 {
@@ -3078,7 +3083,7 @@ static struct vbt_header *spi_oprom_get_vbt(struct intel_display *display,
        oprom_offset &= OROM_OFFSET_MASK;
 
        for (count = 0; count < oprom_size; count += 4) {
-               data = intel_spi_read(&i915->uncore, oprom_offset + count);
+               data = intel_spi_read32(&i915->uncore, oprom_offset + count);
                if (data == *((const u32 *)"$VBT")) {
                        found = oprom_offset + count;
                        break;
@@ -3094,9 +3099,8 @@ static struct vbt_header *spi_oprom_get_vbt(struct intel_display *display,
        }
 
        /* Get VBT size and allocate space for the VBT */
-       vbt_size = intel_spi_read(&i915->uncore,
-                                 found + offsetof(struct vbt_header, vbt_size));
-       vbt_size &= 0xffff;
+       vbt_size = intel_spi_read16(&i915->uncore,
+                                   found + offsetof(struct vbt_header, vbt_size));
 
        if (vbt_size > oprom_size - count) {
                drm_dbg_kms(display->drm,
@@ -3109,7 +3113,7 @@ static struct vbt_header *spi_oprom_get_vbt(struct intel_display *display,
                goto err_not_found;
 
        for (count = 0; count < vbt_size; count += 4)
-               *(vbt + store++) = intel_spi_read(&i915->uncore, found + count);
+               *(vbt + store++) = intel_spi_read32(&i915->uncore, found + count);
 
        if (!intel_bios_is_valid_vbt(display, vbt, vbt_size))
                goto err_free_vbt;