netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] liquidio: fix duplicated code for different branches
@ 2017-08-13  1:38 Gustavo A. R. Silva
  2017-08-14  7:14 ` Felix Manlunas
  2017-08-14 17:58 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2017-08-13  1:38 UTC (permalink / raw)
  To: Derek Chickles, Satanand Burla, Felix Manlunas, Raghu Vatsavayi
  Cc: netdev, linux-kernel, Gustavo A. R. Silva

Refactor code in order to avoid identical code for different branches.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
This code was tested by compilation only.

 drivers/net/ethernet/cavium/liquidio/lio_ethtool.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
index b78e296..4f65c08 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
@@ -578,23 +578,18 @@ static int lio_set_phys_id(struct net_device *netdev,
 		break;
 
 	case ETHTOOL_ID_ON:
-		if (oct->chip_id == OCTEON_CN66XX) {
+		if (oct->chip_id == OCTEON_CN66XX)
 			octnet_gpio_access(netdev, VITESSE_PHY_GPIO_CFG,
 					   VITESSE_PHY_GPIO_HIGH);
-
-		} else if (oct->chip_id == OCTEON_CN68XX) {
-			return -EINVAL;
-		} else {
+		else
 			return -EINVAL;
-		}
+
 		break;
 
 	case ETHTOOL_ID_OFF:
 		if (oct->chip_id == OCTEON_CN66XX)
 			octnet_gpio_access(netdev, VITESSE_PHY_GPIO_CFG,
 					   VITESSE_PHY_GPIO_LOW);
-		else if (oct->chip_id == OCTEON_CN68XX)
-			return -EINVAL;
 		else
 			return -EINVAL;
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] liquidio: fix duplicated code for different branches
  2017-08-13  1:38 [PATCH] liquidio: fix duplicated code for different branches Gustavo A. R. Silva
@ 2017-08-14  7:14 ` Felix Manlunas
  2017-08-14 17:58 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Felix Manlunas @ 2017-08-14  7:14 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Derek Chickles, Satanand Burla, Raghu Vatsavayi, netdev,
	linux-kernel

On Sat, Aug 12, 2017 at 08:38:55PM -0500, Gustavo A. R. Silva wrote:
> Refactor code in order to avoid identical code for different branches.
> 
> This issue was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> This code was tested by compilation only.
> 
>  drivers/net/ethernet/cavium/liquidio/lio_ethtool.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
> index b78e296..4f65c08 100644
> --- a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
> +++ b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
> @@ -578,23 +578,18 @@ static int lio_set_phys_id(struct net_device *netdev,
>  		break;
>  
>  	case ETHTOOL_ID_ON:
> -		if (oct->chip_id == OCTEON_CN66XX) {
> +		if (oct->chip_id == OCTEON_CN66XX)
>  			octnet_gpio_access(netdev, VITESSE_PHY_GPIO_CFG,
>  					   VITESSE_PHY_GPIO_HIGH);
> -
> -		} else if (oct->chip_id == OCTEON_CN68XX) {
> -			return -EINVAL;
> -		} else {
> +		else
>  			return -EINVAL;
> -		}
> +
>  		break;
>  
>  	case ETHTOOL_ID_OFF:
>  		if (oct->chip_id == OCTEON_CN66XX)
>  			octnet_gpio_access(netdev, VITESSE_PHY_GPIO_CFG,
>  					   VITESSE_PHY_GPIO_LOW);
> -		else if (oct->chip_id == OCTEON_CN68XX)
> -			return -EINVAL;
>  		else
>  			return -EINVAL;
>  
> -- 
> 2.5.0
> 

Acked-by: Felix Manlunas <felix.manlunas@cavium.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] liquidio: fix duplicated code for different branches
  2017-08-13  1:38 [PATCH] liquidio: fix duplicated code for different branches Gustavo A. R. Silva
  2017-08-14  7:14 ` Felix Manlunas
@ 2017-08-14 17:58 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2017-08-14 17:58 UTC (permalink / raw)
  To: gustavo
  Cc: derek.chickles, satananda.burla, felix.manlunas, raghu.vatsavayi,
	netdev, linux-kernel

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Sat, 12 Aug 2017 20:38:55 -0500

> Refactor code in order to avoid identical code for different branches.
> 
> This issue was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-14 17:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-13  1:38 [PATCH] liquidio: fix duplicated code for different branches Gustavo A. R. Silva
2017-08-14  7:14 ` Felix Manlunas
2017-08-14 17:58 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).