* [PATCH] mwifiex: Make mwifiex_dbg a function, reduce object size
@ 2015-08-31 17:46 Joe Perches
2015-09-01 15:09 ` David Laight
2015-09-29 7:33 ` Kalle Valo
0 siblings, 2 replies; 4+ messages in thread
From: Joe Perches @ 2015-08-31 17:46 UTC (permalink / raw
To: Amitkumar Karwar, Nishant Sarmukadam
Cc: Kalle Valo, linux-wireless, netdev, linux-kernel
The mwifiex_dbg macro has two tests that could be consolidated
into a function reducing overall object size ~10KB (~4%).
So convert the macro into a function.
$ size drivers/net/wireless/mwifiex/built-in.o* (x86-64 defconfig)
text data bss dec hex filename
233102 8628 4809 246539 3c30b drivers/net/wireless/mwifiex/built-in.o.new
243949 8628 4809 257386 3ed6a drivers/net/wireless/mwifiex/built-in.o.old
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/net/wireless/mwifiex/main.c | 20 ++++++++++++++++++++
drivers/net/wireless/mwifiex/main.h | 17 ++++++++---------
2 files changed, 28 insertions(+), 9 deletions(-)
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
index 278dc94..4fa8ca3 100644
--- a/drivers/net/wireless/mwifiex/main.c
+++ b/drivers/net/wireless/mwifiex/main.c
@@ -1447,6 +1447,26 @@ exit_sem_err:
}
EXPORT_SYMBOL_GPL(mwifiex_remove_card);
+void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask,
+ const char *fmt, ...)
+{
+ struct va_format vaf;
+ va_list args;
+
+ if (!adapter->dev || !(adapter->debug_mask & mask))
+ return;
+
+ va_start(args, fmt);
+
+ vaf.fmt = fmt;
+ vaf.va = &args;
+
+ dev_info(adapter->dev, "%pV", &vaf);
+
+ va_end(args);
+}
+EXPORT_SYMBOL_GPL(_mwifiex_dbg);
+
/*
* This function initializes the module.
*
diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
index 6b95121..96663214 100644
--- a/drivers/net/wireless/mwifiex/main.h
+++ b/drivers/net/wireless/mwifiex/main.h
@@ -48,6 +48,9 @@
extern const char driver_version[];
+struct mwifiex_adapter;
+struct mwifiex_private;
+
enum {
MWIFIEX_ASYNC_CMD,
MWIFIEX_SYNC_CMD
@@ -180,12 +183,11 @@ enum MWIFIEX_DEBUG_LEVEL {
MWIFIEX_DBG_FATAL | \
MWIFIEX_DBG_ERROR)
-#define mwifiex_dbg(adapter, dbg_mask, fmt, args...) \
-do { \
- if ((adapter)->debug_mask & MWIFIEX_DBG_##dbg_mask) \
- if ((adapter)->dev) \
- dev_info((adapter)->dev, fmt, ## args); \
-} while (0)
+__printf(3, 4)
+void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask,
+ const char *fmt, ...);
+#define mwifiex_dbg(adapter, mask, fmt, ...) \
+ _mwifiex_dbg(adapter, MWIFIEX_DBG_##mask, fmt, ##__VA_ARGS__)
#define DEBUG_DUMP_DATA_MAX_LEN 128
#define mwifiex_dbg_dump(adapter, dbg_mask, str, buf, len) \
@@ -506,9 +508,6 @@ enum mwifiex_iface_work_flags {
MWIFIEX_IFACE_WORK_CARD_RESET,
};
-struct mwifiex_adapter;
-struct mwifiex_private;
-
struct mwifiex_private {
struct mwifiex_adapter *adapter;
u8 bss_type;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH] mwifiex: Make mwifiex_dbg a function, reduce object size
2015-08-31 17:46 [PATCH] mwifiex: Make mwifiex_dbg a function, reduce object size Joe Perches
@ 2015-09-01 15:09 ` David Laight
2015-09-01 15:16 ` Joe Perches
2015-09-29 7:33 ` Kalle Valo
1 sibling, 1 reply; 4+ messages in thread
From: David Laight @ 2015-09-01 15:09 UTC (permalink / raw
To: 'Joe Perches', Amitkumar Karwar, Nishant Sarmukadam
Cc: Kalle Valo, linux-wireless@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
From: Joe Perches
> Sent: 31 August 2015 18:47
>
> The mwifiex_dbg macro has two tests that could be consolidated
> into a function reducing overall object size ~10KB (~4%).
>
> So convert the macro into a function.
This looks like it will slow things down somewhat.
Maybe inline the tests and then do a call for the dev_info().
Or at least inline the test for the debug flag.
So you end up with something like:
#define mwifiex_dbg(adapter, dbg_mask, fmt, args...) \
do { \
if ((adapter)->debug_mask & MWIFIEX_DBG_##dbg_mask) \
_mwifiex_dbg(adapter, fmt, ##__VA_ARGS__)
} while (0)
David
>
> $ size drivers/net/wireless/mwifiex/built-in.o* (x86-64 defconfig)
> text data bss dec hex filename
> 233102 8628 4809 246539 3c30b drivers/net/wireless/mwifiex/built-
> in.o.new
> 243949 8628 4809 257386 3ed6a drivers/net/wireless/mwifiex/built-
> in.o.old
>
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> drivers/net/wireless/mwifiex/main.c | 20 ++++++++++++++++++++
> drivers/net/wireless/mwifiex/main.h | 17 ++++++++---------
> 2 files changed, 28 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c
> index 278dc94..4fa8ca3 100644
> --- a/drivers/net/wireless/mwifiex/main.c
> +++ b/drivers/net/wireless/mwifiex/main.c
> @@ -1447,6 +1447,26 @@ exit_sem_err:
> }
> EXPORT_SYMBOL_GPL(mwifiex_remove_card);
>
> +void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask,
> + const char *fmt, ...)
> +{
> + struct va_format vaf;
> + va_list args;
> +
> + if (!adapter->dev || !(adapter->debug_mask & mask))
> + return;
> +
> + va_start(args, fmt);
> +
> + vaf.fmt = fmt;
> + vaf.va = &args;
> +
> + dev_info(adapter->dev, "%pV", &vaf);
> +
> + va_end(args);
> +}
> +EXPORT_SYMBOL_GPL(_mwifiex_dbg);
> +
> /*
> * This function initializes the module.
> *
> diff --git a/drivers/net/wireless/mwifiex/main.h b/drivers/net/wireless/mwifiex/main.h
> index 6b95121..96663214 100644
> --- a/drivers/net/wireless/mwifiex/main.h
> +++ b/drivers/net/wireless/mwifiex/main.h
> @@ -48,6 +48,9 @@
>
> extern const char driver_version[];
>
> +struct mwifiex_adapter;
> +struct mwifiex_private;
> +
> enum {
> MWIFIEX_ASYNC_CMD,
> MWIFIEX_SYNC_CMD
> @@ -180,12 +183,11 @@ enum MWIFIEX_DEBUG_LEVEL {
> MWIFIEX_DBG_FATAL | \
> MWIFIEX_DBG_ERROR)
>
> -#define mwifiex_dbg(adapter, dbg_mask, fmt, args...) \
> -do { \
> - if ((adapter)->debug_mask & MWIFIEX_DBG_##dbg_mask) \
> - if ((adapter)->dev) \
> - dev_info((adapter)->dev, fmt, ## args); \
> -} while (0)
> +__printf(3, 4)
> +void _mwifiex_dbg(const struct mwifiex_adapter *adapter, int mask,
> + const char *fmt, ...);
> +#define mwifiex_dbg(adapter, mask, fmt, ...) \
> + _mwifiex_dbg(adapter, MWIFIEX_DBG_##mask, fmt, ##__VA_ARGS__)
>
...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mwifiex: Make mwifiex_dbg a function, reduce object size
2015-09-01 15:09 ` David Laight
@ 2015-09-01 15:16 ` Joe Perches
0 siblings, 0 replies; 4+ messages in thread
From: Joe Perches @ 2015-09-01 15:16 UTC (permalink / raw
To: David Laight
Cc: Amitkumar Karwar, Nishant Sarmukadam, Kalle Valo,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
On Tue, 2015-09-01 at 15:09 +0000, David Laight wrote:
> From: Joe Perches
> > Sent: 31 August 2015 18:47
> >
> > The mwifiex_dbg macro has two tests that could be consolidated
> > into a function reducing overall object size ~10KB (~4%).
> >
> > So convert the macro into a function.
>
> This looks like it will slow things down somewhat.
I doubt in any meaningful way.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: mwifiex: Make mwifiex_dbg a function, reduce object size
2015-08-31 17:46 [PATCH] mwifiex: Make mwifiex_dbg a function, reduce object size Joe Perches
2015-09-01 15:09 ` David Laight
@ 2015-09-29 7:33 ` Kalle Valo
1 sibling, 0 replies; 4+ messages in thread
From: Kalle Valo @ 2015-09-29 7:33 UTC (permalink / raw
To: Joe Perches
Cc: Amitkumar Karwar, Nishant Sarmukadam, linux-wireless, netdev,
linux-kernel
> The mwifiex_dbg macro has two tests that could be consolidated
> into a function reducing overall object size ~10KB (~4%).
>
> So convert the macro into a function.
>
> $ size drivers/net/wireless/mwifiex/built-in.o* (x86-64 defconfig)
> text data bss dec hex filename
> 233102 8628 4809 246539 3c30b drivers/net/wireless/mwifiex/built-in.o.new
> 243949 8628 4809 257386 3ed6a drivers/net/wireless/mwifiex/built-in.o.old
>
> Signed-off-by: Joe Perches <joe@perches.com>
Thanks, applied to wireless-drivers-next.git.
Kalle Valo
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-09-29 7:33 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-31 17:46 [PATCH] mwifiex: Make mwifiex_dbg a function, reduce object size Joe Perches
2015-09-01 15:09 ` David Laight
2015-09-01 15:16 ` Joe Perches
2015-09-29 7:33 ` Kalle Valo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.