ath: Reduce logging message code size
Subsystems (3)
cover ath: Reduce logging message code size
Reduces size ~5KB in an allyesconfig.
Joe Perches (2):
ath: Make ath_dbg void not int
ath: Make ath_printk void not int and remove unused struct ath_common *
drivers/net/wireless/ath/ath.h | 48 +++++++++++++++++++------------------- drivers/net/wireless/ath/main.c | 8 +----- 2 files changed, 26 insertions(+), 30 deletions(-)
Signature · 1 line
1.7.6.405.gc1be0
PATCH 1/2 ath: Make ath_dbg void not int
The return value is never used so make it void.
Reduces object size a tiny bit.
$ size drivers/net/wireless/ath/built-in.o* text data bss dec hex filename 1164175 16235 212032 1392442 153f3a drivers/net/wireless/ath/built-in.o.new 1164819 16235 212032 1393086 1541be drivers/net/wireless/ath/built-in.o.old
--- drivers/net/wireless/ath/ath.h | 29 ++++++++++++----------------- 1 files changed, 12 insertions(+), 17 deletions(-)
drivers/net/wireless/ath/ath.h +12 -17
@@ -178,8 +178,9 @@ bool ath_hw_keyreset(struct ath_common *common, u16 entry);void ath_hw_cycle_counters_update (struct ath_common *common);int32_t ath_hw_get_listen_time (struct ath_common *common); -extern __attribute__ ((format (printf,3 ,4 )))int -ath_printk (const char *level,struct ath_common *common,const char *fmt, ...); +extern __attribute__((format (printf,3 ,4 ))) +int ath_printk (const char *level,struct ath_common *common, +const char *fmt, ...);#define ath_emerg (common, fmt, ...) \ ath_printk(KERN_EMERG, common, fmt, ##__VA_ARGS__)
@@ -246,27 +247,21 @@ enum ATH_DEBUG {#ifdef CONFIG_ATH_DEBUG -#define ath_dbg (common, dbg_mask, fmt, ...) \ -({ \ - int rtn; \ - if ((common)->debug_mask & dbg_mask) \ - rtn = ath_printk(KERN_DEBUG, common, fmt, \ - ##__VA_ARGS__); \ - else \ - rtn = 0; \ - \ - rtn; \ -}) +#define ath_dbg (common, dbg_mask, fmt, ...) \ +do { \ + if ((common)->debug_mask & dbg_mask) \ + ath_printk(KERN_DEBUG, common, fmt, ##__VA_ARGS__); \ +} while (0) + #define ATH_DBG_WARN(foo, arg...) WARN(foo, arg)#define ATH_DBG_WARN_ON_ONCE (foo) WARN_ON_ONCE(foo)#else -static inline __attribute__ ((format (printf,3 ,4 )))int -ath_dbg (struct ath_common *common,enum ATH_DEBUG dbg_mask, -const char *fmt, ...) +static inline __attribute__((format (printf,3 ,4 ))) +void ath_dbg (struct ath_common *common,enum ATH_DEBUG dbg_mask, +const char *fmt, ...) { -return 0 ; } #define ATH_DBG_WARN(foo, arg...) do {} while (0)#define ATH_DBG_WARN_ON_ONCE (foo) ({ \
Signature · 1 line
1.7.6.405.gc1be0
PATCH 2/2 ath: Make ath_printk void not int and remove unused struct ath_common *
In reply to Joe PerchesChanging the return type and removing the unused argument from ath_printk reduces code size.
Add an __always_unused struct ath_common * to the macros that call ath_printk to avoid unused variable warnings.
$ size drivers/net/wireless/ath/built-in.o* text data bss dec hex filename 1159859 16235 212000 1388094 152e3e drivers/net/wireless/ath/built-in.o.new 1164175 16235 212032 1392442 153f3a drivers/net/wireless/ath/built-in.o.old
--- drivers/net/wireless/ath/ath.h | 27 ++++++++++++++++----------- drivers/net/wireless/ath/main.c | 8 ++------ 2 files changed, 18 insertions(+), 17 deletions(-)
drivers/net/wireless/ath/ath.h +16 -11
@@ -178,24 +178,29 @@ bool ath_hw_keyreset(struct ath_common *common, u16 entry);void ath_hw_cycle_counters_update (struct ath_common *common);int32_t ath_hw_get_listen_time (struct ath_common *common); -extern __attribute__((format (printf,3 ,4 ))) -int ath_printk (const char *level,struct ath_common *common, -const char *fmt, ...); +extern __attribute__((format (printf,2 ,3 ))) +void ath_printk (const char *level,const char *fmt, ...); + +#define _ath_printk (level, common, fmt, ...) \ +do { \ + __always_unused struct ath_common *unused = common; \ + ath_printk(level, fmt, ##__VA_ARGS__); \ +} while (0)#define ath_emerg (common, fmt, ...) \ - ath_printk(KERN_EMERG, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_EMERG, common, fmt, ##__VA_ARGS__)#define ath_alert (common, fmt, ...) \ - ath_printk(KERN_ALERT, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_ALERT, common, fmt, ##__VA_ARGS__)#define ath_crit (common, fmt, ...) \ - ath_printk(KERN_CRIT, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_CRIT, common, fmt, ##__VA_ARGS__)#define ath_err (common, fmt, ...) \ - ath_printk(KERN_ERR, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_ERR, common, fmt, ##__VA_ARGS__)#define ath_warn (common, fmt, ...) \ - ath_printk(KERN_WARNING, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_WARNING, common, fmt, ##__VA_ARGS__)#define ath_notice (common, fmt, ...) \ - ath_printk(KERN_NOTICE, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_NOTICE, common, fmt, ##__VA_ARGS__)#define ath_info (common, fmt, ...) \ - ath_printk(KERN_INFO, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_INFO, common, fmt, ##__VA_ARGS__)/** * enum ath_debug_level - atheros wireless debug level
@@ -250,7 +255,7 @@ enum ATH_DEBUG {#define ath_dbg (common, dbg_mask, fmt, ...) \ do { \ if ((common)->debug_mask & dbg_mask) \ - ath_printk(KERN_DEBUG, common, fmt, ##__VA_ARGS__); \ + _ath_printk(KERN_DEBUG, common, fmt, ##__VA_ARGS__); \ } while (0) #define ATH_DBG_WARN(foo, arg...) WARN(foo, arg)
drivers/net/wireless/ath/main.c +2 -6
@@ -57,22 +57,18 @@ struct sk_buff *ath_rxbuf_alloc(struct ath_common *common, }EXPORT_SYMBOL (ath_rxbuf_alloc); -int ath_printk (const char *level,struct ath_common *common, -const char *fmt, ...) +void ath_printk (const char *level,const char *fmt, ...) {struct va_format vaf;va_list args; -int rtn;va_start (args, fmt); vaf.fmt = fmt; vaf.va = &args; - rtn =printk ("%sath: %pV" , level, &vaf); +printk ("%sath: %pV" , level, &vaf);va_end (args); - -return rtn; }EXPORT_SYMBOL (ath_printk);
Signature · 1 line
1.7.6.405.gc1be0
Re: [PATCH 2/2] ath: Make ath_printk void not int and remove unused struct ath_common *
Quoted 51 lines · Joe Perches
Changing the return type and removing the unused argument from
ath_printkreduces code size.Add an
__always_unusedstructath_common* to the macros that callath_printkto avoid unused variable warnings.$ size drivers/net/wireless/ath/built-in.o* text data bss dec hex filename 1159859 16235 212000 1388094 152e3e drivers/net/wireless/ath/built-in.o.new 1164175 16235 212032 1392442 153f3a drivers/net/wireless/ath/built-in.o.oldSigned-off-by Joe Perches <[email protected]>--- drivers/net/wireless/ath/ath.h | 27 ++++++++++++++++----------- drivers/net/wireless/ath/main.c | 8 ++------ 2 files changed, 18 insertions(+), 17 deletions(-)drivers/net/wireless/ath/ath.h +12
-8@@ -178,24 +178,29 @@ bool ath_hw_keyreset(struct ath_common *common, u16 entry);void ath_hw_cycle_counters_update (struct ath_common *common);int32_t ath_hw_get_listen_time (struct ath_common *common); -extern __attribute__((format (printf,3 ,4 ))) -int ath_printk (const char *level,struct ath_common *common, -const char *fmt, ...); +extern __attribute__((format (printf,2 ,3 ))) +void ath_printk (const char *level,const char *fmt, ...); + +#define _ath_printk (level, common, fmt, ...) \ +do { \ + __always_unused struct ath_common *unused = common; \ + ath_printk(level, fmt, ##__VA_ARGS__); \ +} while (0)#define ath_emerg (common, fmt, ...) \ - ath_printk(KERN_EMERG, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_EMERG, common, fmt, ##__VA_ARGS__)#define ath_alert (common, fmt, ...) \ - ath_printk(KERN_ALERT, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_ALERT, common, fmt, ##__VA_ARGS__)#define ath_crit (common, fmt, ...) \ - ath_printk(KERN_CRIT, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_CRIT, common, fmt, ##__VA_ARGS__)#define ath_err (common, fmt, ...) \ - ath_printk(KERN_ERR, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_ERR, common, fmt, ##__VA_ARGS__)#define ath_warn (common, fmt, ...) \ - ath_printk(KERN_WARNING, common, fmt, ##__VA_ARGS__)
drivers/net/wireless/ath/ath.h bool ath_hw_keyreset(struct ath_common *common, u16 entry); · line 206
Quoted 10 lines
drivers/net/wireless/ath/ath.h +3
-2+ _ath_printk(KERN_WARNING, common, fmt, ##__VA_ARGS__)#define ath_notice (common, fmt, ...) \ - ath_printk(KERN_NOTICE, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_NOTICE, common, fmt, ##__VA_ARGS__)#define ath_info (common, fmt, ...) \ - ath_printk(KERN_INFO, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_INFO, common, fmt, ##__VA_ARGS__)/** * enum ath_debug_level - atheros wireless debug level
Any reason to preserve all these "common" args?
Signature · 2 lines
John W. Linville Someday the world will need a hero, and you [email protected] might be all we have. Be ready.
Re: [PATCH 2/2] ath: Make ath_printk void not int and remove unused struct ath_common *
Quoted 9 lines · John W. Linville
Quoted 8 lines · Joe Perches
Changing the return type and removing the unused argument from
ath_printkreduces code size.
Add an__always_unusedstructath_common* to the macros that callath_printkto avoid unused variable warnings.$ size drivers/net/wireless/ath/built-in.o* text data bss dec hex filename 1159859 16235 212000 1388094 152e3e drivers/net/wireless/ath/built-in.o.new 1164175 16235 212032 1392442 153f3a drivers/net/wireless/ath/built-in.o.old
[]
Quoted 5 lines
drivers/net/wireless/ath/ath.h bool ath_hw_keyreset(struct ath_common *common, u16 entry); · line 188
Quoted 5 lines
drivers/net/wireless/ath/ath.h +5
-0+#define _ath_printk (level, common, fmt, ...) \ +do { \ + __always_unused struct ath_common *unused = common; \ + ath_printk(level, fmt, ##__VA_ARGS__); \ +} while (0)
[]
Quoted 3 lines
drivers/net/wireless/ath/ath.h bool ath_hw_keyreset(struct ath_common *common, u16 entry); · line 191
Quoted 3 lines
#define
ath_emerg(common, fmt, ...)\drivers/net/wireless/ath/ath.h +1
-1- ath_printk(KERN_EMERG, common, fmt, ##__VA_ARGS__) + _ath_printk(KERN_EMERG, common, fmt, ##__VA_ARGS__)
[]
Quoted 1 line
Any reason to preserve all these "common" args?
ath_dbg uses common, the other ath_<level>s do not.
So, other than to avoid modifying all the current uses? Maybe just consistency or a future use case.
Or not.
I think using the macro to avoid larger line changes is an acceptable minimal change.