]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/vga: Extract intel_gmch_ctrl_reg()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 8 Dec 2025 18:26:22 +0000 (20:26 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 23 Jan 2026 02:36:54 +0000 (04:36 +0200)
Extract the GMCH_CTLR register offset determination into a helper
rather than using a local varaible. I'll be needing this in another
function soon.

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

index 39c68aec647b8e7ff71f3cc7b0b974c31a827644..84fd5475d3369d8400554e6462a3109cd9dc8d2a 100644 (file)
 #include "intel_vga.h"
 #include "intel_vga_regs.h"
 
+static unsigned int intel_gmch_ctrl_reg(struct intel_display *display)
+{
+       return DISPLAY_VER(display) >= 6 ? SNB_GMCH_CTRL : INTEL_GMCH_CTRL;
+}
+
 static i915_reg_t intel_vga_cntrl_reg(struct intel_display *display)
 {
        if (display->platform.valleyview || display->platform.cherryview)
@@ -98,10 +103,10 @@ void intel_vga_disable(struct intel_display *display)
 static int intel_gmch_vga_set_state(struct intel_display *display, bool enable_decode)
 {
        struct pci_dev *pdev = to_pci_dev(display->drm->dev);
-       unsigned int reg = DISPLAY_VER(display) >= 6 ? SNB_GMCH_CTRL : INTEL_GMCH_CTRL;
        u16 gmch_ctrl;
 
-       if (pci_bus_read_config_word(pdev->bus, PCI_DEVFN(0, 0), reg, &gmch_ctrl)) {
+       if (pci_bus_read_config_word(pdev->bus, PCI_DEVFN(0, 0),
+                                    intel_gmch_ctrl_reg(display), &gmch_ctrl)) {
                drm_err(display->drm, "failed to read control word\n");
                return -EIO;
        }
@@ -114,7 +119,8 @@ static int intel_gmch_vga_set_state(struct intel_display *display, bool enable_d
        else
                gmch_ctrl |= INTEL_GMCH_VGA_DISABLE;
 
-       if (pci_bus_write_config_word(pdev->bus, PCI_DEVFN(0, 0), reg, gmch_ctrl)) {
+       if (pci_bus_write_config_word(pdev->bus, PCI_DEVFN(0, 0),
+                                     intel_gmch_ctrl_reg(display), gmch_ctrl)) {
                drm_err(display->drm, "failed to write control word\n");
                return -EIO;
        }