rtlwifi: Create _rtl_dbg_trace function to reduce RT_TRACE code size
authorJoe Perches <joe@perches.com>
Sat, 25 Jun 2016 22:46:45 +0000 (15:46 -0700)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 8 Jul 2016 09:55:09 +0000 (12:55 +0300)
This debugging macro can expand to a lot of code.
Make it a function to reduce code size.

(x86-64 defconfig w/ all rtlwifi drivers and allyesconfig)
$ size drivers/net/wireless/realtek/rtlwifi/built-in.o*
   text    data     bss     dec     hex filename
 900083  200499    1907 1102489  10d299 drivers/net/wireless/realtek/rtlwifi/built-in.o.defconfig.new
1113597  200499    1907 1316003  1414a3 drivers/net/wireless/realtek/rtlwifi/built-in.o.defconfig.old
1746879  453503    8512 2208894  21b47e drivers/net/wireless/realtek/rtlwifi/built-in.o.new
2051965  503311    8512 2563788  271ecc drivers/net/wireless/realtek/rtlwifi/built-in.o.old

Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Larry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/realtek/rtlwifi/debug.c
drivers/net/wireless/realtek/rtlwifi/debug.h

index fd25abad2b9eebbe852582db0158e1436c0dd536..33905bbacad212443d33dde648f5bf10511eb9bd 100644 (file)
@@ -48,3 +48,28 @@ void rtl_dbgp_flag_init(struct ieee80211_hw *hw)
        /*Init Debug flag enable condition */
 }
 EXPORT_SYMBOL_GPL(rtl_dbgp_flag_init);
+
+#ifdef CONFIG_RTLWIFI_DEBUG
+void _rtl_dbg_trace(struct rtl_priv *rtlpriv, int comp, int level,
+                   const char *modname, const char *fmt, ...)
+{
+       if (unlikely((comp & rtlpriv->dbg.global_debugcomponents) &&
+                    (level <= rtlpriv->dbg.global_debuglevel))) {
+               struct va_format vaf;
+               va_list args;
+
+               va_start(args, fmt);
+
+               vaf.fmt = fmt;
+               vaf.va = &args;
+
+               printk(KERN_DEBUG "%s:%ps:<%lx-%x> %pV",
+                      modname, __builtin_return_address(0),
+                      in_interrupt(), in_atomic(),
+                      &vaf);
+
+               va_end(args);
+       }
+}
+EXPORT_SYMBOL_GPL(_rtl_dbg_trace);
+#endif
index fc794b3e9f4afd3f04fd2fee1b9b5c336e6e2805..6156a79328c1168086747d57812b9a5592941049 100644 (file)
@@ -174,15 +174,16 @@ do {                                                                      \
        }                                                               \
 } while (0)
 
+
+struct rtl_priv;
+
+__printf(5, 6)
+void _rtl_dbg_trace(struct rtl_priv *rtlpriv, int comp, int level,
+                   const char *modname, const char *fmt, ...);
+
 #define RT_TRACE(rtlpriv, comp, level, fmt, ...)                       \
-do {                                                                   \
-       if (unlikely(((comp) & rtlpriv->dbg.global_debugcomponents) &&  \
-                    ((level) <= rtlpriv->dbg.global_debuglevel))) {    \
-               printk(KERN_DEBUG KBUILD_MODNAME ":%s():<%lx-%x> " fmt, \
-                      __func__, in_interrupt(), in_atomic(),           \
-                      ##__VA_ARGS__);                                  \
-       }                                                               \
-} while (0)
+       _rtl_dbg_trace(rtlpriv, comp, level,                            \
+                      KBUILD_MODNAME, fmt, ##__VA_ARGS__)
 
 #define RTPRINT(rtlpriv, dbgtype, dbgflag, fmt, ...)                   \
 do {                                                                   \