From: Ville Syrjälä <[email protected]>

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ä <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_vga.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_vga.c 
b/drivers/gpu/drm/i915/display/intel_vga.c
index 39c68aec647b..84fd5475d336 100644
--- a/drivers/gpu/drm/i915/display/intel_vga.c
+++ b/drivers/gpu/drm/i915/display/intel_vga.c
@@ -18,6 +18,11 @@
 #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;
        }
-- 
2.51.2

Reply via email to