diff mbox

drm/i915: Make for_each_intel_* macros typesafe

Message ID 1426510260-19251-1-git-send-email-ander.conselvan.de.oliveira@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ander Conselvan de Oliveira March 16, 2015, 12:51 p.m. UTC
So that the compiler warns if we get something wrong.

v2: Don't break 'if (foo) for_each_*' usage. (Jani & Chris)
Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h | 63 ++++++++++++++++++++++++++---------------
 1 file changed, 40 insertions(+), 23 deletions(-)

Comments

Shuang He March 16, 2015, 5:24 p.m. UTC | #1
Tested-By: PRC QA PRTS (Patch Regression Test System Contact: shuang.he@intel.com)
Task id: 5958
-------------------------------------Summary-------------------------------------
Platform          Delta          drm-intel-nightly          Series Applied
PNV                 -2              275/275              273/275
ILK                 -23              303/303              280/303
SNB                 -2              279/279              277/279
IVB                 -2              343/343              341/343
BYT                 -2              287/287              285/287
HSW                 -1              361/361              360/361
BDW                 -2              308/308              306/308
-------------------------------------Detailed-------------------------------------
Platform  Test                                drm-intel-nightly          Series Applied
*PNV  igt_drv_debugfs_reader      PASS(2)      DMESG_WARN(2)
*PNV  igt_drv_hangman_error-state-sysfs-entry      PASS(2)      TIMEOUT(2)
*ILK  igt_drv_debugfs_reader      PASS(1)      DMESG_WARN(1)
*ILK  igt_drv_hangman_error-state-sysfs-entry      PASS(1)      TIMEOUT(1)
*ILK  igt_drv_suspend_debugfs-reader      PASS(1)      DMESG_WARN(1)
*ILK  igt_gem_partial_pwrite_pread_write-snoop      PASS(1)      INIT(1)
*ILK  igt_gem_partial_pwrite_pread_write-uncached      PASS(1)      INIT(1)
*ILK  igt_gem_pwrite_pread_display-pwrite-blt-gtt_mmap-performance      PASS(1)      INIT(1)
*ILK  igt_gem_pwrite_pread_uncached-pwrite-blt-gtt_mmap-performance      PASS(1)      INIT(1)
*ILK  igt_gem_ringfill_blitter      PASS(1)      INIT(1)
*ILK  igt_gem_ringfill_blitter-interruptible      PASS(1)      INIT(1)
*ILK  igt_gem_tiled_pread_pwrite      PASS(1)      INIT(1)
*ILK  igt_gem_userptr_blits_forked-sync-mempressure-interruptible      PASS(1)      INIT(1)
*ILK  igt_gem_userptr_blits_forked-sync-mempressure-normal      PASS(1)      INIT(1)
*ILK  igt_gem_userptr_blits_forked-sync-multifd-mempressure-interruptible      PASS(1)      INIT(1)
*ILK  igt_gem_userptr_blits_forked-sync-multifd-mempressure-normal      PASS(1)      INIT(1)
*ILK  igt_gem_userptr_blits_forked-unsync-mempressure-interruptible      PASS(1)      INIT(1)
*ILK  igt_gem_userptr_blits_forked-unsync-mempressure-normal      PASS(1)      INIT(1)
*ILK  igt_gem_userptr_blits_forked-unsync-multifd-mempressure-interruptible      PASS(1)      INIT(1)
*ILK  igt_gem_userptr_blits_forked-unsync-multifd-mempressure-normal      PASS(1)      INIT(1)
*ILK  igt_kms_flip_flip-vs-dpms-interruptible      PASS(1)      INIT(1)
*ILK  igt_kms_flip_flip-vs-rmfb-interruptible      PASS(1)      INIT(1)
*ILK  igt_kms_flip_rcs-wf_vblank-vs-dpms-interruptible      PASS(1)      INIT(1)
*ILK  igt_kms_flip_vblank-vs-hang      PASS(1)      INIT(1)
*ILK  igt_kms_flip_wf_vblank-vs-modeset-interruptible      PASS(1)      NO_RESULT(1)
*SNB  igt_drv_debugfs_reader      PASS(2)      DMESG_WARN(2)
*SNB  igt_drv_hangman_error-state-sysfs-entry      PASS(2)      TIMEOUT(2)
*IVB  igt_drv_debugfs_reader      PASS(2)      DMESG_WARN(2)
*IVB  igt_drv_hangman_error-state-sysfs-entry      PASS(2)      TIMEOUT(2)
*BYT  igt_drv_debugfs_reader      PASS(2)      DMESG_WARN(2)
*BYT  igt_gem_bad_length      PASS(2)      TIMEOUT(2)
*HSW  igt_pm_rpm_debugfs-read      PASS(2)      TIMEOUT(2)
*BDW  igt_drv_debugfs_reader      PASS(2)      DMESG_WARN(2)
*BDW  igt_drv_hangman_error-state-sysfs-entry      PASS(2)      TIMEOUT(2)
Note: You need to pay more attention to line start with '*'
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index ae4ba6a..55fc10d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -232,30 +232,47 @@  enum hpd_pin {
 	     (__s) < INTEL_INFO(__dev_priv)->num_sprites[(__p)];	\
 	     (__s)++)
 
-#define for_each_crtc(dev, crtc) \
-	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
-
-#define for_each_intel_crtc(dev, intel_crtc) \
-	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list, base.head)
-
-#define for_each_intel_encoder(dev, intel_encoder)		\
-	list_for_each_entry(intel_encoder,			\
-			    &(dev)->mode_config.encoder_list,	\
-			    base.head)
-
-#define for_each_intel_connector(dev, intel_connector)		\
-	list_for_each_entry(intel_connector,			\
-			    &dev->mode_config.connector_list,	\
-			    base.head)
+#define __list_for_each_entry_type(pos, head, type, member) \
+	for (pos = list_first_entry(head, type, member); \
+	     &pos->member != (head); \
+	     pos = list_next_entry(pos, member))
 
-
-#define for_each_encoder_on_crtc(dev, __crtc, intel_encoder) \
-	list_for_each_entry((intel_encoder), &(dev)->mode_config.encoder_list, base.head) \
-		if ((intel_encoder)->base.crtc == (__crtc))
-
-#define for_each_connector_on_encoder(dev, __encoder, intel_connector) \
-	list_for_each_entry((intel_connector), &(dev)->mode_config.connector_list, base.head) \
-		if ((intel_connector)->base.encoder == (__encoder))
+#define for_each_crtc(dev, crtc) \
+	__list_for_each_entry_type(crtc, \
+				   &dev->mode_config.crtc_list, \
+				   struct drm_crtc, \
+				   head)
+
+#define for_each_intel_crtc(dev, crtc)				\
+	__list_for_each_entry_type(crtc,			\
+				   &dev->mode_config.crtc_list,	\
+				   struct intel_crtc, base.head)
+
+#define for_each_intel_encoder(dev, encoder)			\
+	__list_for_each_entry_type(encoder,			\
+				   &(dev)->mode_config.encoder_list, \
+				   struct intel_encoder,	\
+				   base.head)
+
+#define for_each_intel_connector(dev, connector)		\
+	__list_for_each_entry_type(connector,			\
+				   &dev->mode_config.connector_list, \
+				   struct intel_connector,	\
+				   base.head)
+
+
+#define for_each_encoder_on_crtc(dev, __crtc, encoder)		\
+	__list_for_each_entry_type((encoder),			\
+				   &(dev)->mode_config.encoder_list,\
+				   struct intel_encoder, base.head) \
+		if ((encoder)->base.crtc == (__crtc))
+
+#define for_each_connector_on_encoder(dev, __encoder, connector) \
+	__list_for_each_entry_type((connector),			\
+				    &(dev)->mode_config.connector_list, \
+				    struct intel_connector,	\
+				    base.head) \
+		if ((connector)->base.encoder == (__encoder))
 
 #define for_each_power_domain(domain, mask)				\
 	for ((domain) = 0; (domain) < POWER_DOMAIN_NUM; (domain)++)	\