Commit 6a2161a1 authored by Jani Nikula's avatar Jani Nikula

drm/i915: support struct device and pci_dev in to_intel_display()

Now that both xe and i915 store struct drm_device in drvdata, we can
trivially support struct device and struct pci_dev in
to_intel_display().

We do need to check for NULL drvdata before converting it into struct
intel_device pointer, though. Do it in __drm_device_to_intel_display().

v2: Add NULL check in __drm_device_to_intel_display() (Gustavo)

Reviewed-by: Gustavo Sousa <gustavo.sousa@intel.com> # v1
Link: https://patchwork.freedesktop.org/patch/msgid/f025a3fa4422725c78baac4501ad3ecc9e5b40d5.1724942754.git.jani.nikula@intel.comSigned-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 83e5af59
...@@ -2205,7 +2205,11 @@ to_intel_frontbuffer(struct drm_framebuffer *fb) ...@@ -2205,7 +2205,11 @@ to_intel_frontbuffer(struct drm_framebuffer *fb)
* intel_display pointer. * intel_display pointer.
*/ */
#define __drm_device_to_intel_display(p) \ #define __drm_device_to_intel_display(p) \
(&to_i915(p)->display) ((p) ? &to_i915(p)->display : NULL)
#define __device_to_intel_display(p) \
__drm_device_to_intel_display(dev_get_drvdata(p))
#define __pci_dev_to_intel_display(p) \
__drm_device_to_intel_display(pci_get_drvdata(p))
#define __intel_atomic_state_to_intel_display(p) \ #define __intel_atomic_state_to_intel_display(p) \
__drm_device_to_intel_display((p)->base.dev) __drm_device_to_intel_display((p)->base.dev)
#define __intel_connector_to_intel_display(p) \ #define __intel_connector_to_intel_display(p) \
...@@ -2231,6 +2235,8 @@ to_intel_frontbuffer(struct drm_framebuffer *fb) ...@@ -2231,6 +2235,8 @@ to_intel_frontbuffer(struct drm_framebuffer *fb)
#define to_intel_display(p) \ #define to_intel_display(p) \
_Generic(*p, \ _Generic(*p, \
__assoc(drm_device, p), \ __assoc(drm_device, p), \
__assoc(device, p), \
__assoc(pci_dev, p), \
__assoc(intel_atomic_state, p), \ __assoc(intel_atomic_state, p), \
__assoc(intel_connector, p), \ __assoc(intel_connector, p), \
__assoc(intel_crtc, p), \ __assoc(intel_crtc, p), \
......
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