[openchrome-devel] drm-openchrome: Branch 'drm-next-5.14' - 5 commits - drivers/gpu/drm

Kevin Brace kevinbrace at kemper.freedesktop.org
Wed Jul 14 20:11:12 UTC 2021


 drivers/gpu/drm/openchrome/openchrome_analog.c  |    3 -
 drivers/gpu/drm/openchrome/openchrome_clocks.c  |   16 +++--
 drivers/gpu/drm/openchrome/openchrome_crtc.c    |   71 +++++++++++++-----------
 drivers/gpu/drm/openchrome/openchrome_cursor.c  |   22 ++++---
 drivers/gpu/drm/openchrome/openchrome_display.c |   51 +++++++++--------
 drivers/gpu/drm/openchrome/openchrome_drv.c     |    3 -
 drivers/gpu/drm/openchrome/openchrome_drv.h     |    1 
 drivers/gpu/drm/openchrome/openchrome_fb.c      |    6 +-
 drivers/gpu/drm/openchrome/openchrome_fp.c      |   27 ++++++---
 drivers/gpu/drm/openchrome/openchrome_hdmi.c    |   10 ++-
 drivers/gpu/drm/openchrome/openchrome_init.c    |   38 +++++++-----
 drivers/gpu/drm/openchrome/openchrome_ioctl.c   |    4 -
 drivers/gpu/drm/openchrome/openchrome_object.c  |   34 ++++-------
 drivers/gpu/drm/openchrome/openchrome_pm.c      |   12 ++--
 drivers/gpu/drm/openchrome/openchrome_tmds.c    |    6 +-
 drivers/gpu/drm/openchrome/openchrome_ttm.c     |   16 +----
 16 files changed, 168 insertions(+), 152 deletions(-)

New commits:
commit fe8374744fb966a4371ad903c2a3b0cb6e5728c6
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Wed Jul 14 15:09:58 2021 -0500

    drm/ttm: flip over the range manager to self allocated nodes
    
    Based on commit 3eb7d96 (drm/ttm: flip over the range manager
    to self allocated nodes).
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_object.c b/drivers/gpu/drm/openchrome/openchrome_object.c
index 8c1ddc9b3512..5afc472382c8 100644
--- a/drivers/gpu/drm/openchrome/openchrome_object.c
+++ b/drivers/gpu/drm/openchrome/openchrome_object.c
@@ -40,6 +40,7 @@
 
 #include <drm/ttm/ttm_bo_api.h>
 #include <drm/ttm/ttm_bo_driver.h>
+#include <drm/ttm/ttm_range_manager.h>
 
 #include "openchrome_drv.h"
 
commit 07d8b21a019f955cc36802ac13787a2f515fb1d9
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Wed Jul 14 15:09:41 2021 -0500

    drm/ttm: rename bo->mem and make it a pointer
    
    Based on commit d311675 (drm/ttm: rename bo->mem and make it a
    pointer).
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c b/drivers/gpu/drm/openchrome/openchrome_crtc.c
index 4fcd395f0f7c..a2efbe6239c7 100644
--- a/drivers/gpu/drm/openchrome/openchrome_crtc.c
+++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c
@@ -1921,7 +1921,7 @@ void openchrome_primary_atomic_update(struct drm_plane *plane,
 		via_iga1_set_color_depth(dev_private, fb->format->depth);
 
 		/* Set the framebuffer offset */
-		addr = round_up((bo->ttm_bo.mem.start << PAGE_SHIFT) +
+		addr = round_up((bo->ttm_bo.resource->start << PAGE_SHIFT) +
 				pitch, 16) >> 1;
 
 		vga_wcrt(VGABASE, 0x0D, addr & 0xFF);
@@ -1944,7 +1944,7 @@ void openchrome_primary_atomic_update(struct drm_plane *plane,
 		via_iga2_set_color_depth(dev_private, fb->format->depth);
 
 		/* Set the framebuffer offset */
-		addr = round_up((bo->ttm_bo.mem.start << PAGE_SHIFT) +
+		addr = round_up((bo->ttm_bo.resource->start << PAGE_SHIFT) +
 				pitch, 16);
 		/* Bits 9 to 3 of the frame buffer go into bits 7 to 1
 		 * of the register. Bit 0 is for setting tile mode or
diff --git a/drivers/gpu/drm/openchrome/openchrome_cursor.c b/drivers/gpu/drm/openchrome/openchrome_cursor.c
index 7d08533d0ad1..b5ec6c44b1c0 100644
--- a/drivers/gpu/drm/openchrome/openchrome_cursor.c
+++ b/drivers/gpu/drm/openchrome/openchrome_cursor.c
@@ -181,10 +181,10 @@ static void openchrome_cursor_address(struct drm_crtc *crtc,
 		 */
 		if (iga->index) {
 			VIA_WRITE(HI_FBOFFSET,
-			ttm_bo->kmap.bo->mem.start << PAGE_SHIFT);
+			ttm_bo->kmap.bo->resource->start << PAGE_SHIFT);
 		} else {
 			VIA_WRITE(PRIM_HI_FBOFFSET,
-			ttm_bo->kmap.bo->mem.start << PAGE_SHIFT);
+			ttm_bo->kmap.bo->resource->start << PAGE_SHIFT);
 		}
 		break;
 	default:
@@ -192,7 +192,7 @@ static void openchrome_cursor_address(struct drm_crtc *crtc,
 		 * Program Hardware Icon (HI) offset.
 		 */
 		VIA_WRITE(HI_FBOFFSET,
-			ttm_bo->kmap.bo->mem.start << PAGE_SHIFT);
+			ttm_bo->kmap.bo->resource->start << PAGE_SHIFT);
 		break;
 	}
 
@@ -283,7 +283,7 @@ static int openchrome_cursor_prepare_fb(struct drm_plane *plane,
 	ret = openchrome_bo_pin(bo, TTM_PL_VRAM);
 	ttm_bo_unreserve(&bo->ttm_bo);
 	ret = ttm_bo_kmap(&bo->ttm_bo, 0,
-				bo->ttm_bo.mem.num_pages,
+				bo->ttm_bo.resource->num_pages,
 				&bo->kmap);
 	if (ret) {
 		goto exit;
diff --git a/drivers/gpu/drm/openchrome/openchrome_fb.c b/drivers/gpu/drm/openchrome/openchrome_fb.c
index a9fd14a4c345..5ce7b99e2275 100644
--- a/drivers/gpu/drm/openchrome/openchrome_fb.c
+++ b/drivers/gpu/drm/openchrome/openchrome_fb.c
@@ -206,12 +206,12 @@ openchrome_fb_probe(struct drm_fb_helper *helper,
 	info->fbops = &via_fb_ops;
 
 	info->fix.smem_start = openchrome_fb->bo->
-				ttm_bo.mem.bus.offset;
-	info->fix.smem_len = openchrome_fb->bo->ttm_bo.mem.num_pages <<
+				ttm_bo.resource->bus.offset;
+	info->fix.smem_len = openchrome_fb->bo->ttm_bo.resource->num_pages <<
 							PAGE_SHIFT;
 	info->screen_base = ttm_kmap_obj_virtual(
 				&openchrome_fb->bo->kmap, &is_iomem);
-	info->screen_size = openchrome_fb->bo->ttm_bo.mem.num_pages <<
+	info->screen_size = openchrome_fb->bo->ttm_bo.resource->num_pages <<
 							PAGE_SHIFT;
 
 	info->apertures->ranges[0].base = dev_private->vram_start;
diff --git a/drivers/gpu/drm/openchrome/openchrome_ioctl.c b/drivers/gpu/drm/openchrome/openchrome_ioctl.c
index 36453b40e775..dae01d3b30e3 100644
--- a/drivers/gpu/drm/openchrome/openchrome_ioctl.c
+++ b/drivers/gpu/drm/openchrome/openchrome_ioctl.c
@@ -66,9 +66,9 @@ static int openchrome_gem_create_ioctl(struct drm_device *dev,
 	}
 
 	args->size		= bo->ttm_bo.base.size;
-	args->domain		= bo->ttm_bo.mem.placement;
+	args->domain		= bo->ttm_bo.resource->placement;
 	args->handle		= handle;
-	args->offset		= bo->ttm_bo.mem.start << PAGE_SHIFT;
+	args->offset		= bo->ttm_bo.resource->start << PAGE_SHIFT;
 exit:
 	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 	return ret;
diff --git a/drivers/gpu/drm/openchrome/openchrome_object.c b/drivers/gpu/drm/openchrome/openchrome_object.c
index 4063b8d42155..8c1ddc9b3512 100644
--- a/drivers/gpu/drm/openchrome/openchrome_object.c
+++ b/drivers/gpu/drm/openchrome/openchrome_object.c
@@ -224,7 +224,7 @@ int openchrome_bo_create(struct drm_device *dev,
 		}
 
 		ret = ttm_bo_kmap(&bo->ttm_bo, 0,
-					bo->ttm_bo.mem.num_pages,
+					bo->ttm_bo.resource->num_pages,
 					&bo->kmap);
 		if (ret) {
 			ttm_bo_put(&bo->ttm_bo);
diff --git a/drivers/gpu/drm/openchrome/openchrome_ttm.c b/drivers/gpu/drm/openchrome/openchrome_ttm.c
index 81a413d90e89..004244530b6e 100644
--- a/drivers/gpu/drm/openchrome/openchrome_ttm.c
+++ b/drivers/gpu/drm/openchrome/openchrome_ttm.c
@@ -95,7 +95,7 @@ static void openchrome_bo_evict_flags(struct ttm_buffer_object *bo,
 		goto exit;
 	}
 
-	switch (bo->mem.mem_type) {
+	switch (bo->resource->mem_type) {
 	case TTM_PL_VRAM:
 		openchrome_ttm_domain_to_placement(driver_bo,
 						TTM_PL_VRAM);
@@ -124,9 +124,9 @@ static int openchrome_bo_move(struct ttm_buffer_object *bo,
 	openchrome_bo_move_notify(bo, evict, new_mem);
 	ret = ttm_bo_move_memcpy(bo, ctx, new_mem);
 	if (ret) {
-		swap(*new_mem, bo->mem);
+		swap(*new_mem, *bo->resource);
 		openchrome_bo_move_notify(bo, false, new_mem);
-		swap(*new_mem, bo->mem);
+		swap(*new_mem, *bo->resource);
 	}
 
 	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
commit 0cfe185739de2d7232c51fdd4dd22186379b3691
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Wed Jul 14 15:09:25 2021 -0500

    drm/openchrome: Implement mmap as GEM object function
    
    Based on commit 265ec0d (drm/nouveau: Implement mmap as GEM object
    function).
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.c b/drivers/gpu/drm/openchrome/openchrome_drv.c
index e4c707384334..9b2c568abf2a 100644
--- a/drivers/gpu/drm/openchrome/openchrome_drv.c
+++ b/drivers/gpu/drm/openchrome/openchrome_drv.c
@@ -154,7 +154,7 @@ static const struct file_operations openchrome_driver_fops = {
 	.open		= drm_open,
 	.release	= drm_release,
 	.unlocked_ioctl = drm_ioctl,
-	.mmap		= openchrome_ttm_mmap,
+	.mmap		= drm_gem_mmap,
 	.poll		= drm_poll,
 	.llseek		= noop_llseek,
 };
diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h
index f618d625c17b..e2bd242a351c 100644
--- a/drivers/gpu/drm/openchrome/openchrome_drv.h
+++ b/drivers/gpu/drm/openchrome/openchrome_drv.h
@@ -388,7 +388,6 @@ void openchrome_drm_fini(struct drm_device *dev);
 int openchrome_dev_pm_ops_suspend(struct device *dev);
 int openchrome_dev_pm_ops_resume(struct device *dev);
 
-int openchrome_ttm_mmap(struct file *filp, struct vm_area_struct *vma);
 void openchrome_ttm_domain_to_placement(struct openchrome_bo *bo,
 					uint32_t ttm_domain);
 void openchrome_ttm_bo_destroy(struct ttm_buffer_object *tbo);
diff --git a/drivers/gpu/drm/openchrome/openchrome_object.c b/drivers/gpu/drm/openchrome/openchrome_object.c
index d404a39c7a95..4063b8d42155 100644
--- a/drivers/gpu/drm/openchrome/openchrome_object.c
+++ b/drivers/gpu/drm/openchrome/openchrome_object.c
@@ -36,6 +36,7 @@
  */
 
 #include <drm/drm_file.h>
+#include <drm/drm_gem_ttm_helper.h>
 
 #include <drm/ttm/ttm_bo_api.h>
 #include <drm/ttm/ttm_bo_driver.h>
@@ -55,31 +56,19 @@ static void openchrome_gem_free(struct drm_gem_object *obj)
 	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
 }
 
+static const struct vm_operations_struct openchrome_ttm_bo_vm_ops = {
+	.fault = ttm_bo_vm_fault,
+	.open = ttm_bo_vm_open,
+	.close = ttm_bo_vm_close,
+	.access = ttm_bo_vm_access
+};
+
 static const struct drm_gem_object_funcs openchrome_gem_object_funcs = {
 	.free = openchrome_gem_free,
+	.mmap = drm_gem_ttm_mmap,
+	.vm_ops = &openchrome_ttm_bo_vm_ops,
 };
 
-int openchrome_ttm_mmap(struct file *filp, struct vm_area_struct *vma)
-{
-	struct drm_file *file_priv = filp->private_data;
-	struct openchrome_drm_private *dev_private =
-				file_priv->minor->dev->dev_private;
-	int ret = -EINVAL;
-
-	DRM_DEBUG_KMS("Entered %s.\n", __func__);
-
-	if (!dev_private) {
-		DRM_DEBUG_KMS("No device private data.\n");
-		ret = -EINVAL;
-		goto exit;
-	}
-
-	ret = ttm_bo_mmap(filp, vma, &dev_private->bdev);
-exit:
-	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
-	return ret;
-}
-
 void openchrome_ttm_domain_to_placement(struct openchrome_bo *bo,
 					uint32_t ttm_domain)
 {
diff --git a/drivers/gpu/drm/openchrome/openchrome_ttm.c b/drivers/gpu/drm/openchrome/openchrome_ttm.c
index 3f457cc7df6f..81a413d90e89 100644
--- a/drivers/gpu/drm/openchrome/openchrome_ttm.c
+++ b/drivers/gpu/drm/openchrome/openchrome_ttm.c
@@ -133,15 +133,6 @@ static int openchrome_bo_move(struct ttm_buffer_object *bo,
 	return ret;
 }
 
-static int openchrome_bo_verify_access(struct ttm_buffer_object *bo,
-					struct file *filp)
-{
-	DRM_DEBUG_KMS("Entered %s.\n", __func__);
-
-	DRM_DEBUG_KMS("Exiting %s.\n", __func__);
-	return 0;
-}
-
 static void openchrome_bo_delete_mem_notify(struct ttm_buffer_object *bo)
 {
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
@@ -184,7 +175,6 @@ struct ttm_device_funcs openchrome_bo_driver = {
 	.eviction_valuable = ttm_bo_eviction_valuable,
 	.evict_flags = openchrome_bo_evict_flags,
 	.move = openchrome_bo_move,
-	.verify_access = openchrome_bo_verify_access,
 	.delete_mem_notify = openchrome_bo_delete_mem_notify,
 	.io_mem_reserve = openchrome_bo_io_mem_reserve,
 };
commit 7060bf0a10ba93fe4c36f385caa4061e22d595df
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Wed Jul 14 15:09:15 2021 -0500

    drm/openchrome: Don't assign to struct drm_device.pdev
    
    Based on commit 9d7a045 (drm/i915: Don't assign to struct
    drm_device.pdev).
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.c b/drivers/gpu/drm/openchrome/openchrome_drv.c
index fab48ffc071e..e4c707384334 100644
--- a/drivers/gpu/drm/openchrome/openchrome_drv.c
+++ b/drivers/gpu/drm/openchrome/openchrome_drv.c
@@ -210,7 +210,6 @@ static int openchrome_pci_probe(struct pci_dev *pdev,
 		goto error_disable_pci;
 	}
 
-	dev->pdev = pdev;
 	pci_set_drvdata(pdev, dev);
 
 	ret = openchrome_drm_init(dev);
commit 96889c7284a727515147891f753325b074e785b3
Author: Kevin Brace <kevinbrace at gmx.com>
Date:   Wed Jul 14 15:00:49 2021 -0500

    drm/openchrome: Remove references to drm_device.pdev
    
    Based on commit 9a31b38 (drm/via: Remove references to
    drm_device.pdev).
    
    Signed-off-by: Kevin Brace <kevinbrace at gmx.com>

diff --git a/drivers/gpu/drm/openchrome/openchrome_analog.c b/drivers/gpu/drm/openchrome/openchrome_analog.c
index f5e16382a0ed..159687d256b8 100644
--- a/drivers/gpu/drm/openchrome/openchrome_analog.c
+++ b/drivers/gpu/drm/openchrome/openchrome_analog.c
@@ -352,7 +352,8 @@ void via_analog_probe(struct drm_device *dev)
 {
 	struct openchrome_drm_private *dev_private =
 						dev->dev_private;
-	u16 chipset = dev->pdev->device;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
+	u16 chipset = pdev->device;
 	u8 sr13, sr5a;
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
diff --git a/drivers/gpu/drm/openchrome/openchrome_clocks.c b/drivers/gpu/drm/openchrome/openchrome_clocks.c
index 12e6be079fce..8e5ed4ca378e 100644
--- a/drivers/gpu/drm/openchrome/openchrome_clocks.c
+++ b/drivers/gpu/drm/openchrome/openchrome_clocks.c
@@ -57,6 +57,7 @@ struct pll_mrn_value {
 u32
 via_get_clk_value(struct drm_device *dev, u32 freq)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	u32 best_pll_n = 2, best_pll_r = 0, best_pll_m = 2, best_clk_diff = freq;
 	u32 pll_fout, pll_fvco, pll_mrn = 0;
 	u32 pll_n, pll_r, pll_m, clk_diff;
@@ -68,8 +69,8 @@ via_get_clk_value(struct drm_device *dev, u32 freq)
 		{ 0, 0, 0, 0, 0 } };
 	int count;
 
-    if ((dev->pdev->device != PCI_DEVICE_ID_VIA_CLE266) 
-        && (dev->pdev->device != PCI_DEVICE_ID_VIA_KM400)) {
+    if ((pdev->device != PCI_DEVICE_ID_VIA_CLE266)
+        && (pdev->device != PCI_DEVICE_ID_VIA_KM400)) {
 		/* DN[6:0] */
 		for (pll_n = 2; pll_n < 6; pll_n++) {
 			/* DR[2:0] */
@@ -150,7 +151,7 @@ via_get_clk_value(struct drm_device *dev, u32 freq)
 		}
 	}
 
-	switch (dev->pdev->device) {
+	switch (pdev->device) {
 	case PCI_DEVICE_ID_VIA_CLE266:
 	case PCI_DEVICE_ID_VIA_KM400:
 		/* Clock Synthesizer Value 0[7:6]: DR[1:0]
@@ -201,6 +202,7 @@ via_set_vclock(struct drm_crtc *crtc, u32 clk)
 	struct openchrome_drm_private *dev_private =
 						crtc->dev->dev_private;
 	struct drm_device *dev = crtc->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	unsigned long max_loop = 50, i = 0;
 
 	if (!iga->index) {
@@ -208,8 +210,8 @@ via_set_vclock(struct drm_crtc *crtc, u32 clk)
 		svga_wcrt_mask(VGABASE, 0x17, 0x00, BIT(7));
 
 		/* set clk */
-		if ((dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
-		    (dev->pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
+		if ((pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
+		    (pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
 			vga_wseq(VGABASE, 0x46, (clk & 0xFF00) >> 8);	/* rshift + divisor */
 			vga_wseq(VGABASE, 0x47, (clk & 0x00FF));	/* multiplier */
 		} else {
@@ -235,8 +237,8 @@ via_set_vclock(struct drm_crtc *crtc, u32 clk)
 		svga_wcrt_mask(VGABASE, 0x6A, 0x00, BIT(6));
 
 		/* set clk */
-		if ((dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
-		    (dev->pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
+		if ((pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
+		    (pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
 			vga_wseq(VGABASE, 0x44, (clk & 0xFF00) >> 8);
 			vga_wseq(VGABASE, 0x45, (clk & 0x00FF));
 		} else {
diff --git a/drivers/gpu/drm/openchrome/openchrome_crtc.c b/drivers/gpu/drm/openchrome/openchrome_crtc.c
index 0ce9af620d01..4fcd395f0f7c 100644
--- a/drivers/gpu/drm/openchrome/openchrome_crtc.c
+++ b/drivers/gpu/drm/openchrome/openchrome_crtc.c
@@ -172,6 +172,8 @@ static int openchrome_gamma_set(struct drm_crtc *crtc,
 				uint32_t size,
 				struct drm_modeset_acquire_ctx *ctx)
 {
+	struct drm_device *dev = crtc->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct openchrome_drm_private *dev_private =
 						crtc->dev->dev_private;
 	struct via_crtc *iga = container_of(crtc,
@@ -274,7 +276,7 @@ static int openchrome_gamma_set(struct drm_crtc *crtc,
 
 			/* Old platforms LUT are 6 bits in size.
 			 * Newer it is 8 bits. */
-			switch (crtc->dev->pdev->device) {
+			switch (pdev->device) {
 			case PCI_DEVICE_ID_VIA_CLE266:
 			case PCI_DEVICE_ID_VIA_KM400:
 			case PCI_DEVICE_ID_VIA_K8M800:
@@ -379,6 +381,7 @@ static int via_iga1_display_fifo_regs(
 			struct drm_display_mode *mode,
 			struct drm_framebuffer *fb)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	u32 reg_value;
 	unsigned int fifo_max_depth = 0;
 	unsigned int fifo_threshold = 0;
@@ -389,7 +392,7 @@ static int via_iga1_display_fifo_regs(
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
-	switch (dev->pdev->device) {
+	switch (pdev->device) {
 	case PCI_DEVICE_ID_VIA_CLE266:
 		if (dev_private->revision == CLE266_REVISION_AX) {
 			if (mode->hdisplay > 1024) {
@@ -715,20 +718,20 @@ static int via_iga1_display_fifo_regs(
 		goto exit;
 	}
 
-	if ((dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
-		(dev->pdev->device == PCI_DEVICE_ID_VIA_KM400) ||
-		(dev->pdev->device == PCI_DEVICE_ID_VIA_K8M800) ||
-		(dev->pdev->device == PCI_DEVICE_ID_VIA_PM800) ||
-		(dev->pdev->device == PCI_DEVICE_ID_VIA_CN700) ||
-		(dev->pdev->device == PCI_DEVICE_ID_VIA_VT3157)) {
+	if ((pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
+		(pdev->device == PCI_DEVICE_ID_VIA_KM400) ||
+		(pdev->device == PCI_DEVICE_ID_VIA_K8M800) ||
+		(pdev->device == PCI_DEVICE_ID_VIA_PM800) ||
+		(pdev->device == PCI_DEVICE_ID_VIA_CN700) ||
+		(pdev->device == PCI_DEVICE_ID_VIA_VT3157)) {
 		/* Force PREQ to be always higher than TREQ. */
 		svga_wseq_mask(VGABASE, 0x18, BIT(6), BIT(6));
 	} else {
 		svga_wseq_mask(VGABASE, 0x18, 0x00, BIT(6));
 	}
 
-	if ((dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
-		(dev->pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
+	if ((pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
+		(pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
 		if (enable_extended_display_fifo) {
 			reg_value = VIA_READ(0x0298);
 			VIA_WRITE(0x0298, reg_value | 0x20000000);
@@ -781,6 +784,7 @@ static int via_iga2_display_fifo_regs(
 			struct drm_display_mode *mode,
 			struct drm_framebuffer *fb)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	u32 reg_value;
 	unsigned int fifo_max_depth = 0;
 	unsigned int fifo_threshold = 0;
@@ -791,7 +795,7 @@ static int via_iga2_display_fifo_regs(
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
-	switch (dev->pdev->device) {
+	switch (pdev->device) {
 	case PCI_DEVICE_ID_VIA_CLE266:
 		if (dev_private->revision == CLE266_REVISION_AX) {
 			if (((dev_private->vram_type <= VIA_MEM_DDR_200) &&
@@ -1045,8 +1049,8 @@ static int via_iga2_display_fifo_regs(
 		goto exit;
 	}
 
-	if ((dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
-		(dev->pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
+	if ((pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
+		(pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
 		if (enable_extended_display_fifo) {
 			/* Enable IGA2 extended display FIFO. */
 			svga_wcrt_mask(VGABASE, 0x6a, BIT(5), BIT(5));
@@ -1056,8 +1060,8 @@ static int via_iga2_display_fifo_regs(
 		}
 	}
 
-	if ((dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
-		(dev->pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
+	if ((pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
+		(pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
 		/* Set IGA2 Display FIFO Depth Select */
 		reg_value = IGA2_FIFO_DEPTH_SELECT_FORMULA(fifo_max_depth);
 		load_value_to_registers(VGABASE, &iga->fifo_depth, reg_value);
@@ -1172,10 +1176,11 @@ via_load_crtc_timing(struct via_crtc *iga, struct drm_display_mode *mode)
 	struct openchrome_drm_private *dev_private =
 					iga->base.dev->dev_private;
 	struct drm_device *dev = iga->base.dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	u32 reg_value = 0;
 
 	if (!iga->index) {
-		if (dev->pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA) {
+		if (pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA) {
 			/* Disable IGA1 shadow timing */
 			svga_wcrt_mask(VGABASE, 0x45, 0x00, BIT(0));
 
@@ -1271,6 +1276,7 @@ via_set_scale_path(struct drm_crtc *crtc, u32 scale_type)
 						crtc->dev->dev_private;
 	u8 reg_cr_fd = vga_rcrt(VGABASE, 0xFD);
 	struct drm_device *dev = crtc->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 
 	if (!iga->index)
 		/* register reuse: select IGA1 path */
@@ -1280,7 +1286,7 @@ via_set_scale_path(struct drm_crtc *crtc, u32 scale_type)
 		reg_cr_fd &= ~BIT(7);
 
 	/* only IGA1 up scaling need to clear this bit CRFD.5. */
-	if (dev->pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA) {
+	if (pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA) {
 		if (!iga->index
 			&& ((VIA_HOR_EXPAND & scale_type)
 			|| (VIA_VER_EXPAND & scale_type)))
@@ -1580,6 +1586,7 @@ void openchrome_mode_set_nofb(struct drm_crtc *crtc)
 	struct openchrome_drm_private *dev_private =
 						crtc->dev->dev_private;
 	struct drm_device *dev = crtc->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	u8 reg_value = 0;
 	int ret;
 
@@ -1590,7 +1597,7 @@ void openchrome_mode_set_nofb(struct drm_crtc *crtc)
 		via_load_vpit_regs(dev_private);
 
 		/* Unlock */
-		via_unlock_crtc(VGABASE, dev->pdev->device);
+		via_unlock_crtc(VGABASE, pdev->device);
 
 		/* IGA1 reset */
 		vga_wcrt(VGABASE, 0x09, 0x00); /* initial CR09=0 */
@@ -1662,7 +1669,7 @@ void openchrome_mode_set_nofb(struct drm_crtc *crtc)
 		via_load_vpit_regs(dev_private);
 
 		/* Unlock */
-		via_unlock_crtc(VGABASE, dev->pdev->device);
+		via_unlock_crtc(VGABASE, pdev->device);
 
 		/* disable IGA scales first */
 		via_disable_iga_scaling(crtc);
@@ -1916,6 +1923,7 @@ void openchrome_primary_atomic_update(struct drm_plane *plane,
 		/* Set the framebuffer offset */
 		addr = round_up((bo->ttm_bo.mem.start << PAGE_SHIFT) +
 				pitch, 16) >> 1;
+
 		vga_wcrt(VGABASE, 0x0D, addr & 0xFF);
 		vga_wcrt(VGABASE, 0x0C, (addr >> 8) & 0xFF);
 		/* Yes order of setting these registers matters on some hardware */
@@ -2040,6 +2048,7 @@ static void openchrome_crtc_param_init(
 		uint32_t index)
 {
 	struct drm_device *dev = dev_private->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct via_crtc *iga = container_of(crtc,
 						struct via_crtc, base);
 	u16 *gamma;
@@ -2051,12 +2060,12 @@ static void openchrome_crtc_param_init(
 
 		iga->timings.hdisplay.count = ARRAY_SIZE(iga2_hor_addr);
 		iga->timings.hdisplay.regs = iga2_hor_addr;
-		if (dev->pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA)
+		if (pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA)
 			iga->timings.hdisplay.count--;
 
 		iga->timings.hblank_start.count = ARRAY_SIZE(iga2_hor_blank_start);
 		iga->timings.hblank_start.regs = iga2_hor_blank_start;
-		if (dev->pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA)
+		if (pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA)
 			iga->timings.hblank_start.count--;
 
 		iga->timings.hblank_end.count = ARRAY_SIZE(iga2_hor_blank_end);
@@ -2064,8 +2073,8 @@ static void openchrome_crtc_param_init(
 
 		iga->timings.hsync_start.count = ARRAY_SIZE(iga2_hor_sync_start);
 		iga->timings.hsync_start.regs = iga2_hor_sync_start;
-		if (dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266
-			|| dev->pdev->device == PCI_DEVICE_ID_VIA_KM400)
+		if (pdev->device == PCI_DEVICE_ID_VIA_CLE266
+			|| pdev->device == PCI_DEVICE_ID_VIA_KM400)
 			iga->timings.hsync_start.count--;
 
 		iga->timings.hsync_end.count = ARRAY_SIZE(iga2_hor_sync_end);
@@ -2090,8 +2099,8 @@ static void openchrome_crtc_param_init(
 		iga->timings.vsync_end.regs = iga2_ver_sync_end;
 
 		/* Secondary FIFO setup */
-		if ((dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
-			(dev->pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
+		if ((pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
+			(pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
 			iga->fifo_depth.count =
 				ARRAY_SIZE(iga2_cle266_fifo_depth_select);
 			iga->fifo_depth.regs = iga2_cle266_fifo_depth_select;
@@ -2125,12 +2134,12 @@ static void openchrome_crtc_param_init(
 
 		iga->timings.hdisplay.count = ARRAY_SIZE(iga1_hor_addr);
 		iga->timings.hdisplay.regs = iga1_hor_addr;
-		if (dev->pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA)
+		if (pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA)
 			iga->timings.hdisplay.count--;
 
 		iga->timings.hblank_start.count = ARRAY_SIZE(iga1_hor_blank_start);
 		iga->timings.hblank_start.regs = iga1_hor_blank_start;
-		if (dev->pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA)
+		if (pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA)
 			iga->timings.hblank_start.count--;
 
 		iga->timings.hblank_end.count = ARRAY_SIZE(iga1_hor_blank_end);
@@ -2161,8 +2170,8 @@ static void openchrome_crtc_param_init(
 		iga->timings.vsync_end.regs = iga1_ver_sync_end;
 
 		/* Primary FIFO setup */
-		if ((dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
-			(dev->pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
+		if ((pdev->device == PCI_DEVICE_ID_VIA_CLE266) ||
+			(pdev->device == PCI_DEVICE_ID_VIA_KM400)) {
 			iga->fifo_depth.count = ARRAY_SIZE(iga1_cle266_fifo_depth_select);
 			iga->fifo_depth.regs = iga1_cle266_fifo_depth_select;
 
diff --git a/drivers/gpu/drm/openchrome/openchrome_cursor.c b/drivers/gpu/drm/openchrome/openchrome_cursor.c
index ab870ede2035..7d08533d0ad1 100644
--- a/drivers/gpu/drm/openchrome/openchrome_cursor.c
+++ b/drivers/gpu/drm/openchrome/openchrome_cursor.c
@@ -52,13 +52,14 @@
 static void openchrome_hide_cursor(struct drm_device *dev,
 					struct drm_crtc *crtc)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct via_crtc *iga = container_of(crtc,
 					struct via_crtc, base);
 	struct openchrome_drm_private *dev_private =
 					dev->dev_private;
 	uint32_t temp;
 
-	switch (dev->pdev->device) {
+	switch (pdev->device) {
 	case PCI_DEVICE_ID_VIA_VT3157:
 	case PCI_DEVICE_ID_VIA_VT3343:
 	case PCI_DEVICE_ID_VIA_P4M900:
@@ -84,12 +85,13 @@ static void openchrome_hide_cursor(struct drm_device *dev,
 static void openchrome_show_cursor(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct via_crtc *iga = container_of(crtc,
 					struct via_crtc, base);
 	struct openchrome_drm_private *dev_private =
 					crtc->dev->dev_private;
 
-	switch (dev->pdev->device) {
+	switch (pdev->device) {
 	case PCI_DEVICE_ID_VIA_VT3157:
 	case PCI_DEVICE_ID_VIA_VT3343:
 	case PCI_DEVICE_ID_VIA_P4M900:
@@ -126,7 +128,7 @@ static void openchrome_show_cursor(struct drm_crtc *crtc)
 		break;
 	}
 
-	switch (dev->pdev->device) {
+	switch (pdev->device) {
 	case PCI_DEVICE_ID_VIA_VT3157:
 	case PCI_DEVICE_ID_VIA_VT3343:
 	case PCI_DEVICE_ID_VIA_P4M900:
@@ -161,12 +163,13 @@ static void openchrome_cursor_address(struct drm_crtc *crtc,
 					struct openchrome_bo *ttm_bo)
 {
 	struct drm_device *dev = crtc->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct via_crtc *iga = container_of(crtc,
 					struct via_crtc, base);
 	struct openchrome_drm_private *dev_private =
 					crtc->dev->dev_private;
 
-	switch (dev->pdev->device) {
+	switch (pdev->device) {
 	case PCI_DEVICE_ID_VIA_VT3157:
 	case PCI_DEVICE_ID_VIA_VT3343:
 	case PCI_DEVICE_ID_VIA_P4M900:
@@ -201,6 +204,7 @@ static void openchrome_set_hi_location(struct drm_crtc *crtc,
 					int crtc_y)
 {
 	struct drm_device *dev = crtc->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct via_crtc *iga = container_of(crtc,
 					struct via_crtc, base);
 	struct openchrome_drm_private *dev_private =
@@ -220,7 +224,7 @@ static void openchrome_set_hi_location(struct drm_crtc *crtc,
 		location_y = crtc_y;
 	}
 
-	switch (dev->pdev->device) {
+	switch (pdev->device) {
 	case PCI_DEVICE_ID_VIA_VT3157:
 	case PCI_DEVICE_ID_VIA_VT3343:
 	case PCI_DEVICE_ID_VIA_P4M900:
diff --git a/drivers/gpu/drm/openchrome/openchrome_display.c b/drivers/gpu/drm/openchrome/openchrome_display.c
index e33df4f7c1a1..e687625dbb46 100644
--- a/drivers/gpu/drm/openchrome/openchrome_display.c
+++ b/drivers/gpu/drm/openchrome/openchrome_display.c
@@ -38,6 +38,7 @@ via_encoder_commit(struct drm_encoder *encoder)
 	struct openchrome_drm_private *dev_private =
 					encoder->dev->dev_private;
 	struct drm_device *dev = encoder->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct via_crtc *iga = NULL;
 	u8 value = 0;
 
@@ -54,7 +55,7 @@ via_encoder_commit(struct drm_encoder *encoder)
 		/* DVP0 Data Source Selection. */
 		svga_wcrt_mask(VGABASE, 0x96, value, BIT(4));
 		/* enable DVP0 under CX700 */
-		if (encoder->dev->pdev->device == PCI_DEVICE_ID_VIA_VT3157)
+		if (pdev->device == PCI_DEVICE_ID_VIA_VT3157)
 			svga_wcrt_mask(VGABASE, 0x91, BIT(5), BIT(5));
 		/* Turn on DVP0 clk */
 		svga_wseq_mask(VGABASE, 0x1E, 0xC0, BIT(7) | BIT(6));
@@ -64,10 +65,10 @@ via_encoder_commit(struct drm_encoder *encoder)
 		svga_wcrt_mask(VGABASE, 0x9B, value, BIT(4));
 		/* enable DVP1 under these chipset. Does DVI exist
 		 * for pre CX700 hardware */
-		if ((dev->pdev->device == PCI_DEVICE_ID_VIA_VT3157) ||
-		    (dev->pdev->device == PCI_DEVICE_ID_VIA_VT1122) ||
-		    (dev->pdev->device == PCI_DEVICE_ID_VIA_VX875) ||
-		    (dev->pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA))
+		if ((pdev->device == PCI_DEVICE_ID_VIA_VT3157) ||
+		    (pdev->device == PCI_DEVICE_ID_VIA_VT1122) ||
+		    (pdev->device == PCI_DEVICE_ID_VIA_VX875) ||
+		    (pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA))
 			svga_wcrt_mask(VGABASE, 0xD3, 0x00, BIT(5));
 		/* Turn on DVP1 clk */
 		svga_wseq_mask(VGABASE, 0x1E, 0x30, BIT(5) | BIT(4));
@@ -75,10 +76,10 @@ via_encoder_commit(struct drm_encoder *encoder)
 
 	case VIA_DI_PORT_DFPH:
 		/* Port 96 is used on older hardware for the DVP0 */
-		if ((dev->pdev->device != PCI_DEVICE_ID_VIA_VT3157) &&
-		    (dev->pdev->device != PCI_DEVICE_ID_VIA_VT1122) &&
-		    (dev->pdev->device != PCI_DEVICE_ID_VIA_VX875) &&
-		    (dev->pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA))
+		if ((pdev->device != PCI_DEVICE_ID_VIA_VT3157) &&
+		    (pdev->device != PCI_DEVICE_ID_VIA_VT1122) &&
+		    (pdev->device != PCI_DEVICE_ID_VIA_VX875) &&
+		    (pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA))
 			svga_wcrt_mask(VGABASE, 0x96, value, BIT(4));
 
 		svga_wcrt_mask(VGABASE, 0x97, value, BIT(4));
@@ -88,10 +89,10 @@ via_encoder_commit(struct drm_encoder *encoder)
 
 	case VIA_DI_PORT_DFPL:
 		/* Port 9B is used on older hardware for the DVP1 */
-		if ((dev->pdev->device != PCI_DEVICE_ID_VIA_VT3157) &&
-		    (dev->pdev->device != PCI_DEVICE_ID_VIA_VT1122) &&
-		    (dev->pdev->device != PCI_DEVICE_ID_VIA_VX875) &&
-		    (dev->pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA))
+		if ((pdev->device != PCI_DEVICE_ID_VIA_VT3157) &&
+		    (pdev->device != PCI_DEVICE_ID_VIA_VT1122) &&
+		    (pdev->device != PCI_DEVICE_ID_VIA_VX875) &&
+		    (pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA))
 			svga_wcrt_mask(VGABASE, 0x9B, value, BIT(4));
 
 		svga_wcrt_mask(VGABASE, 0x99, value, BIT(4));
@@ -100,8 +101,8 @@ via_encoder_commit(struct drm_encoder *encoder)
 		break;
 
 	case VIA_DI_PORT_DFP:
-		if ((dev->pdev->device == PCI_DEVICE_ID_VIA_K8M890) ||
-		    (dev->pdev->device == PCI_DEVICE_ID_VIA_VT3343))
+		if ((pdev->device == PCI_DEVICE_ID_VIA_K8M890) ||
+		    (pdev->device == PCI_DEVICE_ID_VIA_VT3343))
 			svga_wcrt_mask(VGABASE, 0x97, 0x84,
 					BIT(7) | BIT(2) | BIT(1) | BIT(0));
 
@@ -141,7 +142,7 @@ via_encoder_commit(struct drm_encoder *encoder)
 	/* Older chipsets only used CR91 to control all DI ports.
 	 * For newer chipsets (CX700 and above) CR91 and CRD3 are
 	 * used to control DVP0 and DVP1 seperately */
-	if (iga->index && dev->pdev->device != PCI_DEVICE_ID_VIA_VT3157)
+	if (iga->index && pdev->device != PCI_DEVICE_ID_VIA_VT3157)
 		svga_wcrt_mask(VGABASE, 0x91, 0x00, BIT(5));
 
 	/* Now turn on the display */
@@ -323,6 +324,7 @@ static struct td_timer td_timer_regs[] = {
 static void
 via_init_td_timing_regs(struct drm_device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct openchrome_drm_private *dev_private = dev->dev_private;
 	unsigned int td_timer[4] = { 500, 50, 0, 510 }, i;
 	struct vga_registers timings;
@@ -340,7 +342,7 @@ via_init_td_timing_regs(struct drm_device *dev)
 
 	/* Note: VT3353 have two hardware power sequences
 	 * other chips only have one hardware power sequence */
-	if (dev->pdev->device == PCI_DEVICE_ID_VIA_VT1122) {
+	if (pdev->device == PCI_DEVICE_ID_VIA_VT1122) {
 		/* set CRD4[0] to "1" to select 2nd LCD power sequence. */
 		svga_wcrt_mask(VGABASE, 0xD4, BIT(0), BIT(0));
 		/* Fill secondary power sequence */
@@ -388,9 +390,10 @@ via_hwcursor_init(struct openchrome_drm_private *dev_private)
 static void
 via_init_crtc_regs(struct drm_device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct openchrome_drm_private *dev_private = dev->dev_private;
 
-	via_unlock_crtc(VGABASE, dev->pdev->device);
+	via_unlock_crtc(VGABASE, pdev->device);
 
 	/* always set to 1 */
 	svga_wcrt_mask(VGABASE, 0x03, BIT(7), BIT(7));
@@ -412,11 +415,11 @@ via_init_crtc_regs(struct drm_device *dev)
 	vga_wcrt(VGABASE, 0x14, 0x00);
 
 	/* If K8M800, enable Prefetch Mode. */
-	if ((dev->pdev->device == PCI_DEVICE_ID_VIA_K8M800) ||
-	    (dev->pdev->device == PCI_DEVICE_ID_VIA_K8M890))
+	if ((pdev->device == PCI_DEVICE_ID_VIA_K8M800) ||
+	    (pdev->device == PCI_DEVICE_ID_VIA_K8M890))
 		svga_wcrt_mask(VGABASE, 0x33, 0x00, BIT(3));
 
-	if ((dev->pdev->device == PCI_DEVICE_ID_VIA_CLE266) &&
+	if ((pdev->device == PCI_DEVICE_ID_VIA_CLE266) &&
 	    (dev_private->revision == CLE266_REVISION_AX))
 		svga_wseq_mask(VGABASE, 0x1A, BIT(1), BIT(1));
 
@@ -426,11 +429,12 @@ via_init_crtc_regs(struct drm_device *dev)
 static void
 via_display_init(struct drm_device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct openchrome_drm_private *dev_private = dev->dev_private;
 	u8 index = 0x3D, value;
 
 	/* Check if spread spectrum is enabled */
-	if (dev->pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA)
+	if (pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA)
 		index = 0x2C;
 
 	value = vga_rseq(VGABASE, 0x1E);
@@ -459,6 +463,7 @@ via_display_init(struct drm_device *dev)
 int
 via_modeset_init(struct drm_device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct openchrome_drm_private *dev_private = dev->dev_private;
 	uint32_t i;
 	int ret = 0;
@@ -502,7 +507,7 @@ via_modeset_init(struct drm_device *dev)
 
 	via_fp_init(dev);
 
-	switch (dev->pdev->device) {
+	switch (pdev->device) {
 	case PCI_DEVICE_ID_VIA_VX900_VGA:
 		via_hdmi_init(dev, VIA_DI_PORT_NONE);
 		break;
diff --git a/drivers/gpu/drm/openchrome/openchrome_fp.c b/drivers/gpu/drm/openchrome/openchrome_fp.c
index 47ebf87fcc3d..5e8be68e5138 100644
--- a/drivers/gpu/drm/openchrome/openchrome_fp.c
+++ b/drivers/gpu/drm/openchrome/openchrome_fp.c
@@ -591,11 +591,12 @@ static void via_fp_dpms(struct drm_encoder *encoder, int mode)
 	struct via_encoder *enc = container_of(encoder,
 					struct via_encoder, base);
 	struct drm_device *dev = encoder->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct openchrome_drm_private *dev_private =
 					encoder->dev->dev_private;
 
 	/* PCI Device ID */
-	u16 chipset = dev->pdev->device;
+	u16 chipset = pdev->device;
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
@@ -687,11 +688,12 @@ static void via_fp_prepare(struct drm_encoder *encoder)
 	struct via_encoder *enc = container_of(encoder,
 					struct via_encoder, base);
 	struct drm_device *dev = encoder->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct openchrome_drm_private *dev_private =
 					encoder->dev->dev_private;
 
 	/* PCI Device ID */
-	u16 chipset = dev->pdev->device;
+	u16 chipset = pdev->device;
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
@@ -706,11 +708,12 @@ static void via_fp_commit(struct drm_encoder *encoder)
 	struct via_encoder *enc = container_of(encoder,
 					struct via_encoder, base);
 	struct drm_device *dev = encoder->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct openchrome_drm_private *dev_private =
 					encoder->dev->dev_private;
 
 	/* PCI Device ID */
-	u16 chipset = dev->pdev->device;
+	u16 chipset = pdev->device;
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
@@ -726,11 +729,13 @@ via_fp_mode_set(struct drm_encoder *encoder, struct drm_display_mode *mode,
 {
 	struct via_crtc *iga = container_of(encoder->crtc, struct via_crtc, base);
 	struct via_encoder *enc = container_of(encoder, struct via_encoder, base);
+	struct drm_device *dev = encoder->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct openchrome_drm_private *dev_private =
 					encoder->dev->dev_private;
 
 	/* PCI Device ID */
-	u16 chipset = encoder->dev->pdev->device;
+	u16 chipset = pdev->device;
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
@@ -771,11 +776,12 @@ static void via_fp_disable(struct drm_encoder *encoder)
 	struct via_encoder *enc = container_of(encoder,
 					struct via_encoder, base);
 	struct drm_device *dev = encoder->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct openchrome_drm_private *dev_private =
 					encoder->dev->dev_private;
 
 	/* PCI Device ID */
-	u16 chipset = dev->pdev->device;
+	u16 chipset = pdev->device;
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
@@ -802,6 +808,8 @@ const struct drm_encoder_funcs via_lvds_enc_funcs = {
 static enum drm_connector_status
 via_fp_detect(struct drm_connector *connector,  bool force)
 {
+	struct drm_device *dev = connector->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct via_connector *con = container_of(connector,
 					struct via_connector, base);
 	struct openchrome_drm_private *dev_private =
@@ -858,8 +866,7 @@ via_fp_detect(struct drm_connector *connector,  bool force)
 		i2c_bus_bit = i2c_bus_bit << 1;
 	}
 
-	if (connector->dev->pdev->device ==
-					PCI_DEVICE_ID_VIA_CLE266) {
+	if (pdev->device == PCI_DEVICE_ID_VIA_CLE266) {
 		mask = BIT(3);
 	} else {
 		mask = BIT(1);
@@ -1033,6 +1040,7 @@ via_fp_mode_valid(struct drm_connector *connector,
 	struct drm_property *prop = connector->dev->mode_config.scaling_mode_property;
 	struct drm_display_mode *native_mode = NULL, *tmp, *t;
 	struct drm_device *dev = connector->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	u64 scale_mode = DRM_MODE_SCALE_CENTER;
 
 	list_for_each_entry_safe(tmp, t, &connector->modes, head) {
@@ -1050,7 +1058,7 @@ via_fp_mode_valid(struct drm_connector *connector,
 		return MODE_PANEL;
 
 	/* Don't support mode larger than physical size */
-	if (dev->pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA) {
+	if (pdev->device != PCI_DEVICE_ID_VIA_VX900_VGA) {
 		if (mode->hdisplay > native_mode->hdisplay)
 			return MODE_PANEL;
 		if (mode->vdisplay > native_mode->vdisplay)
@@ -1085,11 +1093,12 @@ struct drm_connector_helper_funcs via_fp_connector_helper_funcs = {
  */
 void via_fp_probe(struct drm_device *dev)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct openchrome_drm_private *dev_private = dev->dev_private;
 	struct drm_connector connector;
 	struct i2c_adapter *i2c_bus;
 	struct edid *edid;
-	u16 chipset = dev->pdev->device;
+	u16 chipset = pdev->device;
 	u8 sr12, sr13, sr5a;
 	u8 cr3b;
 
diff --git a/drivers/gpu/drm/openchrome/openchrome_hdmi.c b/drivers/gpu/drm/openchrome/openchrome_hdmi.c
index 568ea2068504..abb0384e1f11 100644
--- a/drivers/gpu/drm/openchrome/openchrome_hdmi.c
+++ b/drivers/gpu/drm/openchrome/openchrome_hdmi.c
@@ -251,6 +251,7 @@ via_hdmi_enc_mode_set(struct drm_encoder *encoder,
 	struct openchrome_drm_private *dev_private = encoder->dev->dev_private;
 	struct drm_connector *connector = NULL, *con;
 	struct drm_device *dev = encoder->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 
 	list_for_each_entry(con, &dev->mode_config.connector_list, head) {
 		if (encoder ==  con->encoder) {
@@ -286,7 +287,7 @@ via_hdmi_enc_mode_set(struct drm_encoder *encoder,
 				/* FIXME VIA where do you get this value from ??? */
 				u32 v_sync_adjust = 0;
 
-				switch (dev->pdev->device) {
+				switch (pdev->device) {
 				case PCI_DEVICE_ID_VIA_VX875:
 					svga_wcrt_mask(VGABASE, 0xFB,
 							v_sync_adjust & 0xFF, 0xFF);
@@ -359,7 +360,7 @@ via_hdmi_enc_mode_set(struct drm_encoder *encoder,
 
 	/* Patch for clock skew */
 	if (enc->di_port == VIA_DI_PORT_DVP1) {
-		switch (dev->pdev->device) {
+		switch (pdev->device) {
 		case PCI_DEVICE_ID_VIA_VT3157:	/* CX700 */
 			svga_wcrt_mask(VGABASE, 0x65, 0x0B, 0x0F);
 			svga_wcrt_mask(VGABASE, 0x9B, 0x00, 0x0F);
@@ -673,6 +674,7 @@ static const struct drm_connector_helper_funcs via_hdmi_connector_helper_funcs =
 void
 via_hdmi_init(struct drm_device *dev, u32 di_port)
 {
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct via_connector *dvi, *hdmi;
 	struct via_encoder *enc;
 
@@ -703,7 +705,7 @@ via_hdmi_init(struct drm_device *dev, u32 di_port)
 	hdmi->base.doublescan_allowed = false;
 	INIT_LIST_HEAD(&hdmi->props);
 
-	switch (dev->pdev->device) {
+	switch (pdev->device) {
 	case PCI_DEVICE_ID_VIA_VT3157:
 	case PCI_DEVICE_ID_VIA_VT1122:
 		hdmi->base.interlace_allowed = false;
@@ -724,7 +726,7 @@ via_hdmi_init(struct drm_device *dev, u32 di_port)
 	dvi->base.doublescan_allowed = false;
 	INIT_LIST_HEAD(&dvi->props);
 
-	switch (dev->pdev->device) {
+	switch (pdev->device) {
 	case PCI_DEVICE_ID_VIA_VT3157:
 	case PCI_DEVICE_ID_VIA_VT3353:
 		dvi->base.interlace_allowed = false;
diff --git a/drivers/gpu/drm/openchrome/openchrome_init.c b/drivers/gpu/drm/openchrome/openchrome_init.c
index 984a238774da..e6f4948e9742 100644
--- a/drivers/gpu/drm/openchrome/openchrome_init.c
+++ b/drivers/gpu/drm/openchrome/openchrome_init.c
@@ -767,6 +767,7 @@ static int vx900_mem_type(struct openchrome_drm_private *dev_private,
 int openchrome_vram_detect(struct openchrome_drm_private *dev_private)
 {
 	struct drm_device *dev = dev_private->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	struct pci_dev *bridge = NULL;
 	struct pci_dev *fn3 = NULL;
 	char *name = "unknown";
@@ -791,19 +792,19 @@ int openchrome_vram_detect(struct openchrome_drm_private *dev_private)
 		goto out_err;
 	}
 
-	if (!fn3 && dev->pdev->device != PCI_DEVICE_ID_VIA_CLE266
-		&& dev->pdev->device != PCI_DEVICE_ID_VIA_KM400) {
+	if (!fn3 && pdev->device != PCI_DEVICE_ID_VIA_CLE266
+		&& pdev->device != PCI_DEVICE_ID_VIA_KM400) {
 		ret = -EINVAL;
 		DRM_ERROR("No function 3 on host bridge...\n");
 		goto out_err;
 	}
 
-	if (dev->pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA) {
+	if (pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA) {
 		dev_private->vram_start =
-				pci_resource_start(dev->pdev, 2);
+				pci_resource_start(pdev, 2);
 	} else {
 		dev_private->vram_start =
-				pci_resource_start(dev->pdev, 0);
+				pci_resource_start(pdev, 0);
 	}
 
 	switch (bridge->device) {
@@ -1014,6 +1015,7 @@ static void openchrome_quirks_init(
 			struct openchrome_drm_private *dev_private)
 {
 	struct drm_device *dev = dev_private->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
@@ -1026,9 +1028,9 @@ static void openchrome_quirks_init(
 	 * setting to handle DVI. As a result, the code needs to know
 	 * this in order to support DVI properly.
 	 */
-	if ((dev->pdev->device == PCI_DEVICE_ID_VIA_VT3157) &&
-		(dev->pdev->subsystem_vendor == 0x1509) &&
-		(dev->pdev->subsystem_device == 0x2d30)) {
+	if ((pdev->device == PCI_DEVICE_ID_VIA_VT3157) &&
+		(pdev->subsystem_vendor == 0x1509) &&
+		(pdev->subsystem_device == 0x2d30)) {
 		dev_private->is_via_nanobook = true;
 	} else {
 		dev_private->is_via_nanobook = false;
@@ -1039,9 +1041,9 @@ static void openchrome_quirks_init(
 	 * due to its flat panel connected to DVP1 (Digital
 	 * Video Port 1) rather than its LVDS channel.
 	 */
-	if ((dev->pdev->device == PCI_DEVICE_ID_VIA_VT1122) &&
-		(dev->pdev->subsystem_vendor == 0x152d) &&
-		(dev->pdev->subsystem_device == 0x0771)) {
+	if ((pdev->device == PCI_DEVICE_ID_VIA_VT1122) &&
+		(pdev->subsystem_vendor == 0x152d) &&
+		(pdev->subsystem_device == 0x0771)) {
 		dev_private->is_quanta_il1 = true;
 	} else {
 		dev_private->is_quanta_il1 = false;
@@ -1053,9 +1055,9 @@ static void openchrome_quirks_init(
 	 * flag register is needed for properly controlling its
 	 * FP.
 	 */
-	if ((dev->pdev->device == PCI_DEVICE_ID_VIA_VT1122) &&
-		(dev->pdev->subsystem_vendor == 0x144d) &&
-		(dev->pdev->subsystem_device == 0xc04e)) {
+	if ((pdev->device == PCI_DEVICE_ID_VIA_VT1122) &&
+		(pdev->subsystem_vendor == 0x144d) &&
+		(pdev->subsystem_device == 0xc04e)) {
 		dev_private->is_samsung_nc20 = true;
 	} else {
 		dev_private->is_samsung_nc20 = false;
@@ -1097,6 +1099,7 @@ int openchrome_mmio_init(
 			struct openchrome_drm_private *dev_private)
 {
 	struct drm_device *dev = dev_private->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	int ret = 0;
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
@@ -1107,8 +1110,8 @@ int openchrome_mmio_init(
 	 * Obtain the starting base address and size, and
 	 * map it to the OS for use.
 	 */
-	dev_private->mmio_base = pci_resource_start(dev->pdev, 1);
-	dev_private->mmio_size = pci_resource_len(dev->pdev, 1);
+	dev_private->mmio_base = pci_resource_start(pdev, 1);
+	dev_private->mmio_size = pci_resource_len(pdev, 1);
 	dev_private->mmio = ioremap(dev_private->mmio_base,
 					dev_private->mmio_size);
 	if (!dev_private->mmio) {
@@ -1165,11 +1168,12 @@ void openchrome_graphics_unlock(
 void chip_revision_info(struct openchrome_drm_private *dev_private)
 {
 	struct drm_device *dev = dev_private->dev;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
 	u8 tmp;
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
 
-	switch (dev->pdev->device) {
+	switch (pdev->device) {
 	/* CLE266 Chipset */
 	case PCI_DEVICE_ID_VIA_CLE266:
 		/* CR4F only defined in CLE266.CX chipset. */
diff --git a/drivers/gpu/drm/openchrome/openchrome_pm.c b/drivers/gpu/drm/openchrome/openchrome_pm.c
index bbfa26a2e1bd..18adb8f50abb 100644
--- a/drivers/gpu/drm/openchrome/openchrome_pm.c
+++ b/drivers/gpu/drm/openchrome/openchrome_pm.c
@@ -52,9 +52,9 @@ int openchrome_dev_pm_ops_suspend(struct device *dev)
 	 * are only available on VX800, VX855, and VX900 chipsets. This bug
 	 * was observed on VIA Embedded EPIA-M830 mainboard.
 	 */
-	if ((drm_dev->pdev->device == PCI_DEVICE_ID_VIA_VT1122) ||
-		(drm_dev->pdev->device == PCI_DEVICE_ID_VIA_VX875) ||
-		(drm_dev->pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA)) {
+	if ((pdev->device == PCI_DEVICE_ID_VIA_VT1122) ||
+		(pdev->device == PCI_DEVICE_ID_VIA_VX875) ||
+		(pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA)) {
 		dev_private->saved_sr14 = vga_rseq(VGABASE, 0x14);
 
 		dev_private->saved_sr66 = vga_rseq(VGABASE, 0x66);
@@ -147,9 +147,9 @@ int openchrome_dev_pm_ops_resume(struct device *dev)
 	 * are only available on VX800, VX855, and VX900 chipsets. This bug
 	 * was observed on VIA Embedded EPIA-M830 mainboard.
 	 */
-	if ((drm_dev->pdev->device == PCI_DEVICE_ID_VIA_VT1122) ||
-		(drm_dev->pdev->device == PCI_DEVICE_ID_VIA_VX875) ||
-		(drm_dev->pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA)) {
+	if ((pdev->device == PCI_DEVICE_ID_VIA_VT1122) ||
+		(pdev->device == PCI_DEVICE_ID_VIA_VX875) ||
+		(pdev->device == PCI_DEVICE_ID_VIA_VX900_VGA)) {
 		vga_wseq(VGABASE, 0x14, dev_private->saved_sr14);
 
 		vga_wseq(VGABASE, 0x66, dev_private->saved_sr66);
diff --git a/drivers/gpu/drm/openchrome/openchrome_tmds.c b/drivers/gpu/drm/openchrome/openchrome_tmds.c
index 920b167762b8..e9bade37e785 100644
--- a/drivers/gpu/drm/openchrome/openchrome_tmds.c
+++ b/drivers/gpu/drm/openchrome/openchrome_tmds.c
@@ -409,7 +409,8 @@ static const struct drm_connector_helper_funcs via_dvi_connector_helper_funcs =
 void via_tmds_probe(struct drm_device *dev)
 {
 	struct openchrome_drm_private *dev_private = dev->dev_private;
-	u16 chipset = dev->pdev->device;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
+	u16 chipset = pdev->device;
 	u8 sr13, sr5a;
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);
@@ -541,7 +542,8 @@ void openchrome_ext_dvi_probe(struct drm_device *dev)
 {
 	struct openchrome_drm_private *dev_private = dev->dev_private;
 	struct i2c_adapter *i2c_bus;
-	u16 chipset = dev->pdev->device;
+	struct pci_dev *pdev = to_pci_dev(dev->dev);
+	u16 chipset = pdev->device;
 	u8 sr12, sr13;
 
 	DRM_DEBUG_KMS("Entered %s.\n", __func__);


More information about the openchrome-devel mailing list