summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_dsi.h
diff options
context:
space:
mode:
authorJani Nikula2015-11-24 20:21:56 +0100
committerDaniel Vetter2015-11-25 09:29:32 +0100
commit95150bdf78f330788f97364702920ad0602f92f3 (patch)
treee4466a356b70d9ef2a41e6cd8e78dc1427324ab6 /drivers/gpu/drm/i915/intel_dsi.h
parentdrm: fix potential dangling else problems in for_each_ macros (diff)
downloadkernel-qcow2-linux-95150bdf78f330788f97364702920ad0602f92f3.tar.gz
kernel-qcow2-linux-95150bdf78f330788f97364702920ad0602f92f3.tar.xz
kernel-qcow2-linux-95150bdf78f330788f97364702920ad0602f92f3.zip
drm/i915: fix potential dangling else problems in for_each_ macros
We have serious dangling else bugs waiting to happen in our for_each_ style macros with ifs. Consider, for example, #define for_each_power_domain(domain, mask) \ for ((domain) = 0; (domain) < POWER_DOMAIN_NUM; (domain)++) \ if ((1 << (domain)) & (mask)) If this is used in context: if (condition) for_each_power_domain(domain, mask); else foo(); foo() will be called for each domain *not* in mask, if condition holds, and not at all if condition doesn't hold. Fix this by reversing the conditions in the macros, and adding an else branch for the "for each" block, so that other if/else blocks can't interfere. Provide a "for_each_if" helper macro to make it easier to get this right. v2: move for_each_if to drmP.h in a separate patch. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Jani Nikula <jani.nikula@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1448392916-2281-2-git-send-email-jani.nikula@intel.com Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_dsi.h')
-rw-r--r--drivers/gpu/drm/i915/intel_dsi.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h
index e6cb25239941..02551ff228c2 100644
--- a/drivers/gpu/drm/i915/intel_dsi.h
+++ b/drivers/gpu/drm/i915/intel_dsi.h
@@ -117,7 +117,7 @@ static inline struct intel_dsi_host *to_intel_dsi_host(struct mipi_dsi_host *h)
#define for_each_dsi_port(__port, __ports_mask) \
for ((__port) = PORT_A; (__port) < I915_MAX_PORTS; (__port)++) \
- if ((__ports_mask) & (1 << (__port)))
+ for_each_if ((__ports_mask) & (1 << (__port)))
static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
{