Patchwork [3/4] net/cpsw: optimize the for_each_slave_macro()

login
register
mail settings
Submitter Sebastian Siewior
Date April 24, 2013, 6:48 p.m.
Message ID <1366829305-9752-4-git-send-email-bigeasy@linutronix.de>
Download mbox | patch
Permalink /patch/239292/
State Accepted
Delegated to: David Miller
Headers show

Comments

Sebastian Siewior - April 24, 2013, 6:48 p.m.
text    data     bss     dec     hex filename
15530      92       4   15626    3d0a cpsw.o.before
15478      92       4   15574    3cd6 cpsw.o.after

52 bytes smaller, 13 for each invocation.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/net/ethernet/ti/cpsw.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
Mugunthan V N - April 25, 2013, 6:31 a.m.
On 4/25/2013 12:18 AM, Sebastian Andrzej Siewior wrote:
>   text    data     bss     dec     hex filename
> 15530      92       4   15626    3d0a cpsw.o.before
> 15478      92       4   15574    3cd6 cpsw.o.after
>
> 52 bytes smaller, 13 for each invocation.
>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> ---
>   drivers/net/ethernet/ti/cpsw.c |    9 ++++++---
>   1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> index 1983f23..8b643d9 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
> @@ -355,12 +355,15 @@ struct cpsw_priv {
>   #define napi_to_priv(napi)	container_of(napi, struct cpsw_priv, napi)
>   #define for_each_slave(priv, func, arg...)				\
>   	do {								\
> -		int idx;						\
> +		struct cpsw_slave *slave;				\
> +		int n;							\
>   		if (priv->data.dual_emac)				\
>   			(func)((priv)->slaves + priv->emac_port, ##arg);\
>   		else							\
> -			for (idx = 0; idx < (priv)->data.slaves; idx++)	\
> -				(func)((priv)->slaves + idx, ##arg);	\
> +			for (n = (priv)->data.slaves,			\
> +					slave = (priv)->slaves;		\
> +					n; n--)				\
> +				(func)(slave++, ##arg);			\
>   	} while (0)
>   #define cpsw_get_slave_ndev(priv, __slave_no__)				\
>   	(priv->slaves[__slave_no__].ndev)

Acked-by: Mugunthan V N <mugunthanvnm@ti.com>

Regards
Mugunthan V N
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 1983f23..8b643d9 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -355,12 +355,15 @@  struct cpsw_priv {
 #define napi_to_priv(napi)	container_of(napi, struct cpsw_priv, napi)
 #define for_each_slave(priv, func, arg...)				\
 	do {								\
-		int idx;						\
+		struct cpsw_slave *slave;				\
+		int n;							\
 		if (priv->data.dual_emac)				\
 			(func)((priv)->slaves + priv->emac_port, ##arg);\
 		else							\
-			for (idx = 0; idx < (priv)->data.slaves; idx++)	\
-				(func)((priv)->slaves + idx, ##arg);	\
+			for (n = (priv)->data.slaves,			\
+					slave = (priv)->slaves;		\
+					n; n--)				\
+				(func)(slave++, ##arg);			\
 	} while (0)
 #define cpsw_get_slave_ndev(priv, __slave_no__)				\
 	(priv->slaves[__slave_no__].ndev)