Re: [Intel-gfx] [PATCH 4/5] drm/i915: pdev cleanup

2016-08-08 Thread Chris Wilson
On Mon, Aug 08, 2016 at 04:20:00PM +0300, David Weinehall wrote:
> In an effort to simplify things for a future push of dev_priv instead
> of dev wherever possible, always take pdev via dev_priv where
> feasible, eliminating the direct access from dev. Right now this
> only eliminates a few cases of dev, but it also obviates that we pass
> dev into a lot of functions where dev_priv would be the more obvious
> choice.
> 
> Signed-off-by: David Weinehall 

struct pci_dev *pdev improves consistency and pdev tends to be used
frequently within functions, so
Reviewed-by: Chris Wilson 
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
___
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx


[Intel-gfx] [PATCH 4/5] drm/i915: pdev cleanup

2016-08-08 Thread David Weinehall
In an effort to simplify things for a future push of dev_priv instead
of dev wherever possible, always take pdev via dev_priv where
feasible, eliminating the direct access from dev. Right now this
only eliminates a few cases of dev, but it also obviates that we pass
dev into a lot of functions where dev_priv would be the more obvious
choice.

Signed-off-by: David Weinehall 
---
 drivers/gpu/drm/i915/i915_debugfs.c |  5 +--
 drivers/gpu/drm/i915/i915_drv.c | 59 +++--
 drivers/gpu/drm/i915/i915_gem_gtt.c |  4 ++-
 drivers/gpu/drm/i915/i915_gem_stolen.c  | 17 +-
 drivers/gpu/drm/i915/i915_gpu_error.c   |  9 ++---
 drivers/gpu/drm/i915/i915_suspend.c |  6 ++--
 drivers/gpu/drm/i915/intel_display.c| 25 +-
 drivers/gpu/drm/i915/intel_fbdev.c  |  3 +-
 drivers/gpu/drm/i915/intel_guc_loader.c |  3 +-
 drivers/gpu/drm/i915/intel_i2c.c|  3 +-
 drivers/gpu/drm/i915/intel_runtime_pm.c | 30 +
 drivers/gpu/drm/i915/intel_sdvo.c   |  4 ++-
 12 files changed, 99 insertions(+), 69 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c 
b/drivers/gpu/drm/i915/i915_debugfs.c
index 9bd41581b592..ad4f7178667c 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -2787,6 +2787,7 @@ static int i915_runtime_pm_status(struct seq_file *m, 
void *unused)
struct drm_info_node *node = m->private;
struct drm_device *dev = node->minor->dev;
struct drm_i915_private *dev_priv = to_i915(dev);
+   struct pci_dev *pdev = dev_priv->drm.pdev;
 
if (!HAS_RUNTIME_PM(dev_priv))
seq_puts(m, "Runtime power management not supported\n");
@@ -2801,8 +2802,8 @@ static int i915_runtime_pm_status(struct seq_file *m, 
void *unused)
seq_printf(m, "Device Power Management (CONFIG_PM) disabled\n");
 #endif
seq_printf(m, "PCI device power state: %s [%d]\n",
-  pci_power_name(dev_priv->drm.pdev->current_state),
-  dev_priv->drm.pdev->current_state);
+  pci_power_name(pdev->current_state),
+  pdev->current_state);
 
return 0;
 }
diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 5e9325e4b1e5..7ea6b8e64681 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -232,6 +232,7 @@ static int i915_getparam(struct drm_device *dev, void *data,
 struct drm_file *file_priv)
 {
struct drm_i915_private *dev_priv = to_i915(dev);
+   struct pci_dev *pdev = dev_priv->drm.pdev;
drm_i915_getparam_t *param = data;
int value;
 
@@ -242,10 +243,10 @@ static int i915_getparam(struct drm_device *dev, void 
*data,
/* Reject all old ums/dri params. */
return -ENODEV;
case I915_PARAM_CHIPSET_ID:
-   value = dev->pdev->device;
+   value = pdev->device;
break;
case I915_PARAM_REVISION:
-   value = dev->pdev->revision;
+   value = pdev->revision;
break;
case I915_PARAM_HAS_GEM:
value = 1;
@@ -516,7 +517,7 @@ static void i915_switcheroo_set_state(struct pci_dev *pdev, 
enum vga_switcheroo_
pr_info("switched on\n");
dev->switch_power_state = DRM_SWITCH_POWER_CHANGING;
/* i915 resume handler doesn't set to D0 */
-   pci_set_power_state(dev->pdev, PCI_D0);
+   pci_set_power_state(pdev, PCI_D0);
i915_resume_switcheroo(dev);
dev->switch_power_state = DRM_SWITCH_POWER_ON;
} else {
@@ -585,6 +586,7 @@ static void i915_gem_fini(struct drm_device *dev)
 static int i915_load_modeset_init(struct drm_device *dev)
 {
struct drm_i915_private *dev_priv = to_i915(dev);
+   struct pci_dev *pdev = dev_priv->drm.pdev;
int ret;
 
if (i915_inject_load_failure())
@@ -601,13 +603,13 @@ static int i915_load_modeset_init(struct drm_device *dev)
 * then we do not take part in VGA arbitration and the
 * vga_client_register() fails with -ENODEV.
 */
-   ret = vga_client_register(dev->pdev, dev, NULL, i915_vga_set_decode);
+   ret = vga_client_register(pdev, dev, NULL, i915_vga_set_decode);
if (ret && ret != -ENODEV)
goto out;
 
intel_register_dsm_handler();
 
-   ret = vga_switcheroo_register_client(dev->pdev, _switcheroo_ops, 
false);
+   ret = vga_switcheroo_register_client(pdev, _switcheroo_ops, false);
if (ret)
goto cleanup_vga_client;
 
@@ -659,9 +661,9 @@ cleanup_irq:
 cleanup_csr:
intel_csr_ucode_fini(dev_priv);
intel_power_domains_fini(dev_priv);
-   vga_switcheroo_unregister_client(dev->pdev);
+   vga_switcheroo_unregister_client(pdev);
 cleanup_vga_client:
-