Commit 361f9dc2 authored by Chris Wilson's avatar Chris Wilson

drm/i915: Use drm_i915_private directly from drv_get_drvdata()

As we store a pointer to i915 in the drvdata field (as the pointer is both
an alias to the drm_device and drm_i915_private), we can use the stored
pointer directly as the i915 device.

v2: Store and use i915 inside drv_get_drvdata()
v3: Only expect i915 inside drv_get_drvdata() so drop the assumed
i915/drm equivalence.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Andi Shyti <andi.shyti@intel.com>
Reviewed-by: default avatarAndi Shyti <andi.shyti@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190806074219.11043-1-chris@chris-wilson.co.uk
parent 6c86e5ff
This diff is collapsed.
...@@ -1897,7 +1897,12 @@ static inline struct drm_i915_private *to_i915(const struct drm_device *dev) ...@@ -1897,7 +1897,12 @@ static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
static inline struct drm_i915_private *kdev_to_i915(struct device *kdev) static inline struct drm_i915_private *kdev_to_i915(struct device *kdev)
{ {
return to_i915(dev_get_drvdata(kdev)); return dev_get_drvdata(kdev);
}
static inline struct drm_i915_private *pdev_to_i915(struct pci_dev *pdev)
{
return pci_get_drvdata(pdev);
} }
static inline struct drm_i915_private *wopcm_to_i915(struct intel_wopcm *wopcm) static inline struct drm_i915_private *wopcm_to_i915(struct intel_wopcm *wopcm)
...@@ -2376,7 +2381,7 @@ long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg); ...@@ -2376,7 +2381,7 @@ long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
extern const struct dev_pm_ops i915_pm_ops; extern const struct dev_pm_ops i915_pm_ops;
int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent); int i915_driver_probe(struct pci_dev *pdev, const struct pci_device_id *ent);
void i915_driver_remove(struct drm_device *dev); void i915_driver_remove(struct drm_i915_private *i915);
void intel_engine_init_hangcheck(struct intel_engine_cs *engine); void intel_engine_init_hangcheck(struct intel_engine_cs *engine);
int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool on); int vlv_force_gfx_clock(struct drm_i915_private *dev_priv, bool on);
......
...@@ -874,16 +874,16 @@ MODULE_DEVICE_TABLE(pci, pciidlist); ...@@ -874,16 +874,16 @@ MODULE_DEVICE_TABLE(pci, pciidlist);
static void i915_pci_remove(struct pci_dev *pdev) static void i915_pci_remove(struct pci_dev *pdev)
{ {
struct drm_device *dev; struct drm_i915_private *i915;
dev = pci_get_drvdata(pdev); i915 = pci_get_drvdata(pdev);
if (!dev) /* driver load aborted, nothing to cleanup */ if (!i915) /* driver load aborted, nothing to cleanup */
return; return;
i915_driver_remove(dev); i915_driver_remove(i915);
drm_dev_put(dev);
pci_set_drvdata(pdev, NULL); pci_set_drvdata(pdev, NULL);
drm_dev_put(&i915->drm);
} }
/* is device_id present in comma separated list of ids */ /* is device_id present in comma separated list of ids */
...@@ -959,7 +959,7 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -959,7 +959,7 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
if (err) if (err)
return err; return err;
if (i915_inject_probe_failure(to_i915(pci_get_drvdata(pdev)))) { if (i915_inject_probe_failure(pci_get_drvdata(pdev))) {
i915_pci_remove(pdev); i915_pci_remove(pdev);
return -ENODEV; return -ENODEV;
} }
......
...@@ -185,7 +185,7 @@ int i915_live_selftests(struct pci_dev *pdev) ...@@ -185,7 +185,7 @@ int i915_live_selftests(struct pci_dev *pdev)
if (!i915_selftest.live) if (!i915_selftest.live)
return 0; return 0;
err = run_selftests(live, to_i915(pci_get_drvdata(pdev))); err = run_selftests(live, pdev_to_i915(pdev));
if (err) { if (err) {
i915_selftest.live = err; i915_selftest.live = err;
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment