[v2,05/14] net: ethernet: ti: cpsw: don't check slave num in runtime
diff mbox

Message ID 1470480524-6851-6-git-send-email-ivan.khoronzhuk@linaro.org
State New
Headers show

Commit Message

Ivan Khoronzhuk Aug. 6, 2016, 10:48 a.m. UTC
No need to check const slave num in runtime for every packet,
and ndev for slaves w/o ndev is anyway NULL. So remove redundant
check.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 drivers/net/ethernet/ti/cpsw.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Mugunthan V N Aug. 9, 2016, 8:16 a.m. UTC | #1
On Saturday 06 August 2016 04:18 PM, Ivan Khoronzhuk wrote:
> No need to check const slave num in runtime for every packet,
> and ndev for slaves w/o ndev is anyway NULL. So remove redundant
> check.
> 
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>

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

Regards
Mugunthan V N
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Grygorii Strashko Aug. 9, 2016, 11:34 a.m. UTC | #2
On 08/06/2016 01:48 PM, Ivan Khoronzhuk wrote:
> No need to check const slave num in runtime for every packet,
> and ndev for slaves w/o ndev is anyway NULL. So remove redundant
> check.
> 
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
> ---
>  drivers/net/ethernet/ti/cpsw.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> index 70a9570..19aa4bb 100644
> --- a/drivers/net/ethernet/ti/cpsw.c
> +++ b/drivers/net/ethernet/ti/cpsw.c
> @@ -498,8 +498,7 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = {
>  				(func)(slave++, ##arg);			\
>  	} while (0)
>  #define cpsw_get_slave_ndev(priv, __slave_no__)				\
> -	((__slave_no__ < priv->data.slaves) ?				\
> -		priv->slaves[__slave_no__].ndev : NULL)
> +		priv->slaves[__slave_no__].ndev

So after this change it will be
#define cpsw_get_slave_ndev(priv, __slave_no__) priv->slaves[__slave_no__].ndev

Can we just drop cpsw_get_slave_ndev() macro?

>  #define cpsw_get_slave_priv(priv, __slave_no__)				\
>  	(((__slave_no__ < priv->data.slaves) &&				\
>  		(priv->slaves[__slave_no__].ndev)) ?			\
>
Ivan Khoronzhuk Aug. 9, 2016, 12:08 p.m. UTC | #3
On 09.08.16 14:34, Grygorii Strashko wrote:
> On 08/06/2016 01:48 PM, Ivan Khoronzhuk wrote:
>> No need to check const slave num in runtime for every packet,
>> and ndev for slaves w/o ndev is anyway NULL. So remove redundant
>> check.
>>
>> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
>> ---
>>  drivers/net/ethernet/ti/cpsw.c | 3 +--
>>  1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
>> index 70a9570..19aa4bb 100644
>> --- a/drivers/net/ethernet/ti/cpsw.c
>> +++ b/drivers/net/ethernet/ti/cpsw.c
>> @@ -498,8 +498,7 @@ static const struct cpsw_stats cpsw_gstrings_stats[] = {
>>  				(func)(slave++, ##arg);			\
>>  	} while (0)
>>  #define cpsw_get_slave_ndev(priv, __slave_no__)				\
>> -	((__slave_no__ < priv->data.slaves) ?				\
>> -		priv->slaves[__slave_no__].ndev : NULL)
>> +		priv->slaves[__slave_no__].ndev
>
> So after this change it will be
> #define cpsw_get_slave_ndev(priv, __slave_no__) priv->slaves[__slave_no__].ndev
>
> Can we just drop cpsw_get_slave_ndev() macro?
Sure. Will drop it in v3.

>
>>  #define cpsw_get_slave_priv(priv, __slave_no__)				\
>>  	(((__slave_no__ < priv->data.slaves) &&				\
>>  		(priv->slaves[__slave_no__].ndev)) ?			\
>>
>
>

Patch
diff mbox

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 70a9570..19aa4bb 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -498,8 +498,7 @@  static const struct cpsw_stats cpsw_gstrings_stats[] = {
 				(func)(slave++, ##arg);			\
 	} while (0)
 #define cpsw_get_slave_ndev(priv, __slave_no__)				\
-	((__slave_no__ < priv->data.slaves) ?				\
-		priv->slaves[__slave_no__].ndev : NULL)
+		priv->slaves[__slave_no__].ndev
 #define cpsw_get_slave_priv(priv, __slave_no__)				\
 	(((__slave_no__ < priv->data.slaves) &&				\
 		(priv->slaves[__slave_no__].ndev)) ?			\