diff mbox series

[v2,06/10] drm/i915: support struct device and pci_dev in to_intel_display()

Message ID 4a70189eed5dcc7cb7c6a11d76bc43902f90197d.1723129920.git.jani.nikula@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/xe & drm/i915: drvdata usage changes | expand

Commit Message

Jani Nikula Aug. 8, 2024, 3:15 p.m. UTC
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
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/i915/display/intel_display_types.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Gustavo Sousa Aug. 9, 2024, 12:55 p.m. UTC | #1
Quoting Jani Nikula (2024-08-08 12:15:51-03:00)
>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

And it stands for v2 as well.

--
Gustavo Sousa

>Signed-off-by: Jani Nikula <jani.nikula@intel.com>
>---
> drivers/gpu/drm/i915/display/intel_display_types.h | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
>index ea6548ceab2f..976c85446603 100644
>--- a/drivers/gpu/drm/i915/display/intel_display_types.h
>+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
>@@ -2205,7 +2205,11 @@ to_intel_frontbuffer(struct drm_framebuffer *fb)
>  * intel_display pointer.
>  */
> #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_connector_to_intel_display(p)                \
>         __drm_device_to_intel_display((p)->base.dev)
> #define __intel_crtc_to_intel_display(p)                \
>@@ -2229,6 +2233,8 @@ to_intel_frontbuffer(struct drm_framebuffer *fb)
> #define to_intel_display(p)                                \
>         _Generic(*p,                                        \
>                  __assoc(drm_device, p),                \
>+                 __assoc(device, p),                        \
>+                 __assoc(pci_dev, p),                        \
>                  __assoc(intel_connector, p),                \
>                  __assoc(intel_crtc, p),                \
>                  __assoc(intel_crtc_state, p),                \
>-- 
>2.39.2
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index ea6548ceab2f..976c85446603 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -2205,7 +2205,11 @@  to_intel_frontbuffer(struct drm_framebuffer *fb)
  * intel_display pointer.
  */
 #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_connector_to_intel_display(p)		\
 	__drm_device_to_intel_display((p)->base.dev)
 #define __intel_crtc_to_intel_display(p)		\
@@ -2229,6 +2233,8 @@  to_intel_frontbuffer(struct drm_framebuffer *fb)
 #define to_intel_display(p)				\
 	_Generic(*p,					\
 		 __assoc(drm_device, p),		\
+		 __assoc(device, p),			\
+		 __assoc(pci_dev, p),			\
 		 __assoc(intel_connector, p),		\
 		 __assoc(intel_crtc, p),		\
 		 __assoc(intel_crtc_state, p),		\