Commit eadd2721 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Protect PIPE_CONF_CHECK macros with do {} while(0)

Make the PIPE_CONF_CHECK macros a bit more robust by wrapping them
in do {} while(0). Avoids funky sirprises when you try put an 'else'
after a PIPE_CONF_CHECK invocation...
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180316183625.16316-1-ville.syrjala@linux.intel.com
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> #irc
parent e307126a
...@@ -11141,39 +11141,42 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv, ...@@ -11141,39 +11141,42 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
(current_config->base.mode.private_flags & I915_MODE_FLAG_INHERITED) && (current_config->base.mode.private_flags & I915_MODE_FLAG_INHERITED) &&
!(pipe_config->base.mode.private_flags & I915_MODE_FLAG_INHERITED); !(pipe_config->base.mode.private_flags & I915_MODE_FLAG_INHERITED);
#define PIPE_CONF_CHECK_X(name) \ #define PIPE_CONF_CHECK_X(name) do { \
if (current_config->name != pipe_config->name) { \ if (current_config->name != pipe_config->name) { \
pipe_config_err(adjust, __stringify(name), \ pipe_config_err(adjust, __stringify(name), \
"(expected 0x%08x, found 0x%08x)\n", \ "(expected 0x%08x, found 0x%08x)\n", \
current_config->name, \ current_config->name, \
pipe_config->name); \ pipe_config->name); \
ret = false; \ ret = false; \
} } \
} while (0)
#define PIPE_CONF_CHECK_I(name) \ #define PIPE_CONF_CHECK_I(name) do { \
if (current_config->name != pipe_config->name) { \ if (current_config->name != pipe_config->name) { \
pipe_config_err(adjust, __stringify(name), \ pipe_config_err(adjust, __stringify(name), \
"(expected %i, found %i)\n", \ "(expected %i, found %i)\n", \
current_config->name, \ current_config->name, \
pipe_config->name); \ pipe_config->name); \
ret = false; \ ret = false; \
} } \
} while (0)
#define PIPE_CONF_CHECK_BOOL(name) \ #define PIPE_CONF_CHECK_BOOL(name) do { \
if (current_config->name != pipe_config->name) { \ if (current_config->name != pipe_config->name) { \
pipe_config_err(adjust, __stringify(name), \ pipe_config_err(adjust, __stringify(name), \
"(expected %s, found %s)\n", \ "(expected %s, found %s)\n", \
yesno(current_config->name), \ yesno(current_config->name), \
yesno(pipe_config->name)); \ yesno(pipe_config->name)); \
ret = false; \ ret = false; \
} } \
} while (0)
/* /*
* Checks state where we only read out the enabling, but not the entire * Checks state where we only read out the enabling, but not the entire
* state itself (like full infoframes or ELD for audio). These states * state itself (like full infoframes or ELD for audio). These states
* require a full modeset on bootup to fix up. * require a full modeset on bootup to fix up.
*/ */
#define PIPE_CONF_CHECK_BOOL_INCOMPLETE(name) \ #define PIPE_CONF_CHECK_BOOL_INCOMPLETE(name) do { \
if (!fixup_inherited || (!current_config->name && !pipe_config->name)) { \ if (!fixup_inherited || (!current_config->name && !pipe_config->name)) { \
PIPE_CONF_CHECK_BOOL(name); \ PIPE_CONF_CHECK_BOOL(name); \
} else { \ } else { \
...@@ -11182,18 +11185,20 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv, ...@@ -11182,18 +11185,20 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
yesno(current_config->name), \ yesno(current_config->name), \
yesno(pipe_config->name)); \ yesno(pipe_config->name)); \
ret = false; \ ret = false; \
} } \
} while (0)
#define PIPE_CONF_CHECK_P(name) \ #define PIPE_CONF_CHECK_P(name) do { \
if (current_config->name != pipe_config->name) { \ if (current_config->name != pipe_config->name) { \
pipe_config_err(adjust, __stringify(name), \ pipe_config_err(adjust, __stringify(name), \
"(expected %p, found %p)\n", \ "(expected %p, found %p)\n", \
current_config->name, \ current_config->name, \
pipe_config->name); \ pipe_config->name); \
ret = false; \ ret = false; \
} } \
} while (0)
#define PIPE_CONF_CHECK_M_N(name) \ #define PIPE_CONF_CHECK_M_N(name) do { \
if (!intel_compare_link_m_n(&current_config->name, \ if (!intel_compare_link_m_n(&current_config->name, \
&pipe_config->name,\ &pipe_config->name,\
adjust)) { \ adjust)) { \
...@@ -11211,14 +11216,15 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv, ...@@ -11211,14 +11216,15 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
pipe_config->name.link_m, \ pipe_config->name.link_m, \
pipe_config->name.link_n); \ pipe_config->name.link_n); \
ret = false; \ ret = false; \
} } \
} while (0)
/* This is required for BDW+ where there is only one set of registers for /* This is required for BDW+ where there is only one set of registers for
* switching between high and low RR. * switching between high and low RR.
* This macro can be used whenever a comparison has to be made between one * This macro can be used whenever a comparison has to be made between one
* hw state and multiple sw state variables. * hw state and multiple sw state variables.
*/ */
#define PIPE_CONF_CHECK_M_N_ALT(name, alt_name) \ #define PIPE_CONF_CHECK_M_N_ALT(name, alt_name) do { \
if (!intel_compare_link_m_n(&current_config->name, \ if (!intel_compare_link_m_n(&current_config->name, \
&pipe_config->name, adjust) && \ &pipe_config->name, adjust) && \
!intel_compare_link_m_n(&current_config->alt_name, \ !intel_compare_link_m_n(&current_config->alt_name, \
...@@ -11243,9 +11249,10 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv, ...@@ -11243,9 +11249,10 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
pipe_config->name.link_m, \ pipe_config->name.link_m, \
pipe_config->name.link_n); \ pipe_config->name.link_n); \
ret = false; \ ret = false; \
} } \
} while (0)
#define PIPE_CONF_CHECK_FLAGS(name, mask) \ #define PIPE_CONF_CHECK_FLAGS(name, mask) do { \
if ((current_config->name ^ pipe_config->name) & (mask)) { \ if ((current_config->name ^ pipe_config->name) & (mask)) { \
pipe_config_err(adjust, __stringify(name), \ pipe_config_err(adjust, __stringify(name), \
"(%x) (expected %i, found %i)\n", \ "(%x) (expected %i, found %i)\n", \
...@@ -11253,16 +11260,18 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv, ...@@ -11253,16 +11260,18 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
current_config->name & (mask), \ current_config->name & (mask), \
pipe_config->name & (mask)); \ pipe_config->name & (mask)); \
ret = false; \ ret = false; \
} } \
} while (0)
#define PIPE_CONF_CHECK_CLOCK_FUZZY(name) \ #define PIPE_CONF_CHECK_CLOCK_FUZZY(name) do { \
if (!intel_fuzzy_clock_check(current_config->name, pipe_config->name)) { \ if (!intel_fuzzy_clock_check(current_config->name, pipe_config->name)) { \
pipe_config_err(adjust, __stringify(name), \ pipe_config_err(adjust, __stringify(name), \
"(expected %i, found %i)\n", \ "(expected %i, found %i)\n", \
current_config->name, \ current_config->name, \
pipe_config->name); \ pipe_config->name); \
ret = false; \ ret = false; \
} } \
} while (0)
#define PIPE_CONF_QUIRK(quirk) \ #define PIPE_CONF_QUIRK(quirk) \
((current_config->quirks | pipe_config->quirks) & (quirk)) ((current_config->quirks | pipe_config->quirks) & (quirk))
......
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