linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: fsl-dpaa2: replace simple switch case by if statement
@ 2018-03-21 11:16 hariprasath.elango
  2018-03-21 11:48 ` David Laight
  0 siblings, 1 reply; 4+ messages in thread
From: hariprasath.elango @ 2018-03-21 11:16 UTC (permalink / raw)
  To: ruxandra.radulescu, gregkh
  Cc: gehariprasath, HariPrasath Elango, linux-kernel, devel

From: HariPrasath Elango <hariprasath.elango@gmail.com>

Replace a couple of simple switch cases by if condition

Signed-off-by: HariPrasath Elango <hariprasath.elango@gmail.com>
---
 drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
index 070a3f2..fb517cb 100644
--- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
+++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
@@ -171,8 +171,7 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset,
 	u8 *p = data;
 	int i;
 
-	switch (stringset) {
-	case ETH_SS_STATS:
+	if (stringset == ETH_SS_STATS) {
 		for (i = 0; i < DPAA2_ETH_NUM_STATS; i++) {
 			strlcpy(p, dpaa2_ethtool_stats[i], ETH_GSTRING_LEN);
 			p += ETH_GSTRING_LEN;
@@ -181,18 +180,16 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset,
 			strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN);
 			p += ETH_GSTRING_LEN;
 		}
-		break;
 	}
 }
 
 static int dpaa2_eth_get_sset_count(struct net_device *net_dev, int sset)
 {
-	switch (sset) {
-	case ETH_SS_STATS: /* ethtool_get_stats(), ethtool_get_drvinfo() */
+	if (sset == ETH_SS_STATS)
+		/* ethtool_get_stats(), ethtool_get_drvinfo() */
 		return DPAA2_ETH_NUM_STATS + DPAA2_ETH_NUM_EXTRA_STATS;
-	default:
+	else
 		return -EOPNOTSUPP;
-	}
 }
 
 /** Fill in hardware counters, as returned by MC.
-- 
2.10.0.GIT

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

* RE: [PATCH] staging: fsl-dpaa2: replace simple switch case by if statement
  2018-03-21 11:16 [PATCH] staging: fsl-dpaa2: replace simple switch case by if statement hariprasath.elango
@ 2018-03-21 11:48 ` David Laight
  2018-03-21 12:17   ` Denis Kirjanov
  0 siblings, 1 reply; 4+ messages in thread
From: David Laight @ 2018-03-21 11:48 UTC (permalink / raw)
  To: 'hariprasath.elango@gmail.com',
	ruxandra.radulescu@nxp.com, gregkh@linuxfoundation.org
  Cc: gehariprasath@gmail.com, linux-kernel@vger.kernel.org,
	devel@driverdev.osuosl.org

From: > hariprasath.elango@gmail.com
> Sent: 21 March 2018 11:16
> From: HariPrasath Elango <hariprasath.elango@gmail.com>
> 
> Replace a couple of simple switch cases by if condition

Why?
In principle extra 'case' might be needed in the future.

...
> diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c b/drivers/staging/fsl-
> dpaa2/ethernet/dpaa2-ethtool.c
> index 070a3f2..fb517cb 100644
> --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
> +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
> @@ -171,8 +171,7 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset,
>  	u8 *p = data;
>  	int i;
> 
> -	switch (stringset) {
> -	case ETH_SS_STATS:
> +	if (stringset == ETH_SS_STATS) {
>  		for (i = 0; i < DPAA2_ETH_NUM_STATS; i++) {
>  			strlcpy(p, dpaa2_ethtool_stats[i], ETH_GSTRING_LEN);
>  			p += ETH_GSTRING_LEN;
> @@ -181,18 +180,16 @@ static void dpaa2_eth_get_strings(struct net_device *netdev, u32 stringset,
>  			strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN);
>  			p += ETH_GSTRING_LEN;
>  		}
> -		break;
>  	}
>  }
...

	David

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

* Re: [PATCH] staging: fsl-dpaa2: replace simple switch case by if statement
  2018-03-21 11:48 ` David Laight
@ 2018-03-21 12:17   ` Denis Kirjanov
  2018-03-21 13:05     ` <Hariprasath Elango>
  0 siblings, 1 reply; 4+ messages in thread
From: Denis Kirjanov @ 2018-03-21 12:17 UTC (permalink / raw)
  To: David Laight
  Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
	hariprasath.elango@gmail.com, linux-kernel@vger.kernel.org

On 3/21/18, David Laight <David.Laight@aculab.com> wrote:
> From: > hariprasath.elango@gmail.com
>> Sent: 21 March 2018 11:16
>> From: HariPrasath Elango <hariprasath.elango@gmail.com>
>>
>> Replace a couple of simple switch cases by if condition
>
> Why?
> In principle extra 'case' might be needed in the future.

I had the same question when saw it.
It's better to keep things as is.
>
> ...
>> diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
>> b/drivers/staging/fsl-
>> dpaa2/ethernet/dpaa2-ethtool.c
>> index 070a3f2..fb517cb 100644
>> --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
>> +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
>> @@ -171,8 +171,7 @@ static void dpaa2_eth_get_strings(struct net_device
>> *netdev, u32 stringset,
>>  	u8 *p = data;
>>  	int i;
>>
>> -	switch (stringset) {
>> -	case ETH_SS_STATS:
>> +	if (stringset == ETH_SS_STATS) {
>>  		for (i = 0; i < DPAA2_ETH_NUM_STATS; i++) {
>>  			strlcpy(p, dpaa2_ethtool_stats[i], ETH_GSTRING_LEN);
>>  			p += ETH_GSTRING_LEN;
>> @@ -181,18 +180,16 @@ static void dpaa2_eth_get_strings(struct net_device
>> *netdev, u32 stringset,
>>  			strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN);
>>  			p += ETH_GSTRING_LEN;
>>  		}
>> -		break;
>>  	}
>>  }
> ...
>
> 	David
>
> _______________________________________________
> devel mailing list
> devel@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
>


-- 
Regards / Mit besten Grüßen,
Denis
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: fsl-dpaa2: replace simple switch case by if statement
  2018-03-21 12:17   ` Denis Kirjanov
@ 2018-03-21 13:05     ` <Hariprasath Elango>
  0 siblings, 0 replies; 4+ messages in thread
From: <Hariprasath Elango> @ 2018-03-21 13:05 UTC (permalink / raw)
  To: Denis Kirjanov
  Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org, hariprasath.elango@gmail.com,
	David Laight

On Wed, Mar 21, 2018 at 03:17:51PM +0300, Denis Kirjanov wrote:
> On 3/21/18, David Laight <David.Laight@aculab.com> wrote:
> > From: > hariprasath.elango@gmail.com
> >> Sent: 21 March 2018 11:16
> >> From: HariPrasath Elango <hariprasath.elango@gmail.com>
> >>
> >> Replace a couple of simple switch cases by if condition
> >
> > Why?
> > In principle extra 'case' might be needed in the future.
> 
> I had the same question when saw it.
> It's better to keep things as is.
> >
> > ...

 Hi, since the switch statement had only one case,I thought of doing
 this. If there are plans to add more cases, we can leave it like
 that.

 thanks,
 hari

> >> diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
> >> b/drivers/staging/fsl-
> >> dpaa2/ethernet/dpaa2-ethtool.c
> >> index 070a3f2..fb517cb 100644
> >> --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
> >> +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-ethtool.c
> >> @@ -171,8 +171,7 @@ static void dpaa2_eth_get_strings(struct net_device
> >> *netdev, u32 stringset,
> >>  	u8 *p = data;
> >>  	int i;
> >>
> >> -	switch (stringset) {
> >> -	case ETH_SS_STATS:
> >> +	if (stringset == ETH_SS_STATS) {
> >>  		for (i = 0; i < DPAA2_ETH_NUM_STATS; i++) {
> >>  			strlcpy(p, dpaa2_ethtool_stats[i], ETH_GSTRING_LEN);
> >>  			p += ETH_GSTRING_LEN;
> >> @@ -181,18 +180,16 @@ static void dpaa2_eth_get_strings(struct net_device
> >> *netdev, u32 stringset,
> >>  			strlcpy(p, dpaa2_ethtool_extras[i], ETH_GSTRING_LEN);
> >>  			p += ETH_GSTRING_LEN;
> >>  		}
> >> -		break;
> >>  	}
> >>  }
> > ...
> >
> > 	David
> >
> > _______________________________________________
> > devel mailing list
> > devel@linuxdriverproject.org
> > http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
> >
> 
> 
> -- 
> Regards / Mit besten Grüßen,
> Denis
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

end of thread, other threads:[~2018-03-21 13:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-21 11:16 [PATCH] staging: fsl-dpaa2: replace simple switch case by if statement hariprasath.elango
2018-03-21 11:48 ` David Laight
2018-03-21 12:17   ` Denis Kirjanov
2018-03-21 13:05     ` <Hariprasath Elango>

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).