[PATCH 4/4] i40e: Convert pf_<level> macros to functions

From: Joe Perches
Date: Fri Aug 30 2013 - 19:07:10 EST


Reduces object size ~10KB by removing "%s: ", __func__
and using the %pf extension and __builtin_return_address(0)
to emit the function name.

$ size drivers/net/ethernet/intel/i40e/built-in.o*
text data bss dec hex filename
166271 36043 50032 252346 3d9ba drivers/net/ethernet/intel/i40e/built-in.o.new
177030 35867 49936 262833 402b1 drivers/net/ethernet/intel/i40e/built-in.o.old

Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
---
drivers/net/ethernet/intel/i40e/i40e.h | 12 ++++----
drivers/net/ethernet/intel/i40e/i40e_main.c | 45 +++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
index a39d1c6..9e61ce90 100644
--- a/drivers/net/ethernet/intel/i40e/i40e.h
+++ b/drivers/net/ethernet/intel/i40e/i40e.h
@@ -565,11 +565,11 @@ void i40e_vlan_stripping_enable(struct i40e_vsi *vsi);

/* i40e_pf message logging */

-#define pf_err(pf, fmt, ...) \
- dev_err(&(pf)->pdev->dev, "%s: " fmt, __func__, ##__VA_ARGS__)
-#define pf_warn(pf, fmt, ...) \
- dev_warn(&(pf)->pdev->dev, "%s: " fmt, __func__, ##__VA_ARGS__)
-#define pf_info(pf, fmt, ...) \
- dev_info(&(pf)->pdev->dev, "%s: " fmt, __func__, ##__VA_ARGS__)
+__printf(2, 3)
+void pf_err(const struct i40e_pf *pf, const char *fmt, ...);
+__printf(2, 3)
+void pf_warn(const struct i40e_pf *pf, const char *fmt, ...);
+__printf(2, 3)
+void pf_info(const struct i40e_pf *pf, const char *fmt, ...);

#endif /* _I40E_H_ */
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index d1f6744..4366de3 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -7340,3 +7340,48 @@ static void __exit i40e_exit_module(void)
i40e_dbg_exit();
}
module_exit(i40e_exit_module);
+
+__printf(2, 3)
+void pf_err(const struct i40e_pf *pf, const char *fmt, ...)
+{
+ struct va_format vaf;
+ va_list args;
+
+ vaf.fmt = fmt;
+ vaf.va = &args;
+
+ dev_err(&pf->pdev->dev, "%pf: %pV",
+ __builtin_return_address(0), &vaf);
+
+ va_end(args);
+}
+
+__printf(2, 3)
+void pf_warn(const struct i40e_pf *pf, const char *fmt, ...)
+{
+ struct va_format vaf;
+ va_list args;
+
+ vaf.fmt = fmt;
+ vaf.va = &args;
+
+ dev_warn(&pf->pdev->dev, "%pf: %pV",
+ __builtin_return_address(0), &vaf);
+
+ va_end(args);
+}
+
+__printf(2, 3)
+void pf_info(const struct i40e_pf *pf, const char *fmt, ...)
+{
+ struct va_format vaf;
+ va_list args;
+
+ vaf.fmt = fmt;
+ vaf.va = &args;
+
+ dev_info(&pf->pdev->dev, "%pf: %pV",
+ __builtin_return_address(0), &vaf);
+
+ va_end(args);
+}
--
1.8.1.2.459.gbcd45b4.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/