]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Shrink pipe config checker
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Tue, 6 Dec 2016 10:50:20 +0000 (10:50 +0000)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Thu, 8 Dec 2016 10:12:04 +0000 (10:12 +0000)
Replace INTEL_ERR_OR_DBG_KMS macro with an intel_err_or_dbg_kms
function to shrink the code and rodata strings.

   text    data     bss     dec     hex filename
1271480   41831    2016 1315327  1411ff i915.ko.0
1265160   41831    2016 1309007  13f94f i915.ko.2

Total of ~6 KiB saving across text and strings.

v2:
 * Annotate the function for printf-style checking.
 * Rename to pipe_config_err. (Chris Wilson)

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: http://patchwork.freedesktop.org/patch/msgid/1481021420-5783-1-git-send-email-tvrtko.ursulin@linux.intel.com
drivers/gpu/drm/i915/intel_display.c

index 9eaf1e5bdae92ba35e52ee755d04d128546f1888..c956f342fd1912db114f2e98fa048c813507633c 100644 (file)
@@ -13210,6 +13210,31 @@ intel_compare_link_m_n(const struct intel_link_m_n *m_n,
        return false;
 }
 
+static void __printf(3, 4)
+pipe_config_err(bool adjust, const char *name, const char *format, ...)
+{
+       char *level;
+       unsigned int category;
+       struct va_format vaf;
+       va_list args;
+
+       if (adjust) {
+               level = KERN_DEBUG;
+               category = DRM_UT_KMS;
+       } else {
+               level = KERN_ERR;
+               category = DRM_UT_NONE;
+       }
+
+       va_start(args, format);
+       vaf.fmt = format;
+       vaf.va = &args;
+
+       drm_printk(level, category, "mismatch in %s %pV", name, &vaf);
+
+       va_end(args);
+}
+
 static bool
 intel_pipe_config_compare(struct drm_i915_private *dev_priv,
                          struct intel_crtc_state *current_config,
@@ -13218,17 +13243,9 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
 {
        bool ret = true;
 
-#define INTEL_ERR_OR_DBG_KMS(fmt, ...) \
-       do { \
-               if (!adjust) \
-                       DRM_ERROR(fmt, ##__VA_ARGS__); \
-               else \
-                       DRM_DEBUG_KMS(fmt, ##__VA_ARGS__); \
-       } while (0)
-
 #define PIPE_CONF_CHECK_X(name)        \
        if (current_config->name != pipe_config->name) { \
-               INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
+               pipe_config_err(adjust, __stringify(name), \
                          "(expected 0x%08x, found 0x%08x)\n", \
                          current_config->name, \
                          pipe_config->name); \
@@ -13237,7 +13254,7 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
 
 #define PIPE_CONF_CHECK_I(name)        \
        if (current_config->name != pipe_config->name) { \
-               INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
+               pipe_config_err(adjust, __stringify(name), \
                          "(expected %i, found %i)\n", \
                          current_config->name, \
                          pipe_config->name); \
@@ -13246,7 +13263,7 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
 
 #define PIPE_CONF_CHECK_P(name)        \
        if (current_config->name != pipe_config->name) { \
-               INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
+               pipe_config_err(adjust, __stringify(name), \
                          "(expected %p, found %p)\n", \
                          current_config->name, \
                          pipe_config->name); \
@@ -13257,7 +13274,7 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
        if (!intel_compare_link_m_n(&current_config->name, \
                                    &pipe_config->name,\
                                    adjust)) { \
-               INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
+               pipe_config_err(adjust, __stringify(name), \
                          "(expected tu %i gmch %i/%i link %i/%i, " \
                          "found tu %i, gmch %i/%i link %i/%i)\n", \
                          current_config->name.tu, \
@@ -13283,7 +13300,7 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
                                    &pipe_config->name, adjust) && \
            !intel_compare_link_m_n(&current_config->alt_name, \
                                    &pipe_config->name, adjust)) { \
-               INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
+               pipe_config_err(adjust, __stringify(name), \
                          "(expected tu %i gmch %i/%i link %i/%i, " \
                          "or tu %i gmch %i/%i link %i/%i, " \
                          "found tu %i, gmch %i/%i link %i/%i)\n", \
@@ -13307,8 +13324,9 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
 
 #define PIPE_CONF_CHECK_FLAGS(name, mask)      \
        if ((current_config->name ^ pipe_config->name) & (mask)) { \
-               INTEL_ERR_OR_DBG_KMS("mismatch in " #name "(" #mask ") " \
-                         "(expected %i, found %i)\n", \
+               pipe_config_err(adjust, __stringify(name), \
+                         "(%x) (expected %i, found %i)\n", \
+                         (mask), \
                          current_config->name & (mask), \
                          pipe_config->name & (mask)); \
                ret = false; \
@@ -13316,7 +13334,7 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
 
 #define PIPE_CONF_CHECK_CLOCK_FUZZY(name) \
        if (!intel_fuzzy_clock_check(current_config->name, pipe_config->name)) { \
-               INTEL_ERR_OR_DBG_KMS("mismatch in " #name " " \
+               pipe_config_err(adjust, __stringify(name), \
                          "(expected %i, found %i)\n", \
                          current_config->name, \
                          pipe_config->name); \
@@ -13433,7 +13451,6 @@ intel_pipe_config_compare(struct drm_i915_private *dev_priv,
 #undef PIPE_CONF_CHECK_FLAGS
 #undef PIPE_CONF_CHECK_CLOCK_FUZZY
 #undef PIPE_CONF_QUIRK
-#undef INTEL_ERR_OR_DBG_KMS
 
        return ret;
 }