public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: winbond: mds.c: converted long if-else to switch
@ 2010-03-16 22:37 Lars Lindley
  2010-03-18 16:25 ` Pekka Enberg
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Lars Lindley @ 2010-03-16 22:37 UTC (permalink / raw)
  To: gregkh, greg, penberg, pavel, diegoliz; +Cc: devel, linux-kernel, Lars Lindley

I converted the long if-else in function Mds_HeaderCopy() to a switch
instead. It compiles fine but i don't have the hardware to test.
Please check that I didn't do anything bad to it..
The patch applies on top of this patch:
Message-Id: <1268670973-6223-1-git-send-email-lindley@coyote.org>

Signed-off-by: Lars Lindley <lindley@coyote.org>
---
 drivers/staging/winbond/mds.c |   38 +++++++++++++++++++++++---------------
 1 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/winbond/mds.c b/drivers/staging/winbond/mds.c
index ef08b51..6082fa8 100644
--- a/drivers/staging/winbond/mds.c
+++ b/drivers/staging/winbond/mds.c
@@ -400,30 +400,38 @@ static void Mds_HeaderCopy(struct wbsoft_priv *adapter,
 							       * back rate
 							       */
 
-		if (ctmp1 == 108)
+		switch (ctmp1) {
+		case 108:
 			ctmp2 = 7;
-		else if (ctmp1 == 96)
+			break;
+		case 96:
 			ctmp2 = 6;	/* Rate convert for USB */
-		else if (ctmp1 == 72)
+			break;
+		case 72:
 			ctmp2 = 5;
-		else if (ctmp1 == 48)
+			break;
+		case 48:
 			ctmp2 = 4;
-		else if (ctmp1 == 36)
+			break;
+		case 36:
+		case 22:
 			ctmp2 = 3;
-		else if (ctmp1 == 24)
+			break;
+		case 24:
+		case 11:
 			ctmp2 = 2;
-		else if (ctmp1 == 18)
+			break;
+		case 18:
+		case 4:
 			ctmp2 = 1;
-		else if (ctmp1 == 12)
+			break;
+		case 12:
 			ctmp2 = 0;
-		else if (ctmp1 == 22)
-			ctmp2 = 3;
-		else if (ctmp1 == 11)
-			ctmp2 = 2;
-		else if (ctmp1 == 4)
-			ctmp2 = 1;
-		else
+			break;
+		default:
 			ctmp2 = 0;	/* if (ctmp1 == 2) or default */
+			break;
+		}
 
 		if (i == 0)
 			pT01->T01_transmit_rate = ctmp2;
-- 
1.7.0.2


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

* Re: [PATCH] staging: winbond: mds.c: converted long if-else to switch
  2010-03-16 22:37 [PATCH] staging: winbond: mds.c: converted long if-else to switch Lars Lindley
@ 2010-03-18 16:25 ` Pekka Enberg
  2010-03-21 20:02 ` Pavel Machek
  2010-04-28 22:51 ` Greg KH
  2 siblings, 0 replies; 6+ messages in thread
From: Pekka Enberg @ 2010-03-18 16:25 UTC (permalink / raw)
  To: Lars Lindley; +Cc: gregkh, greg, pavel, diegoliz, devel, linux-kernel

Lars Lindley wrote:
> I converted the long if-else in function Mds_HeaderCopy() to a switch
> instead. It compiles fine but i don't have the hardware to test.
> Please check that I didn't do anything bad to it..
> The patch applies on top of this patch:
> Message-Id: <1268670973-6223-1-git-send-email-lindley@coyote.org>
> 
> Signed-off-by: Lars Lindley <lindley@coyote.org>
> ---
>  drivers/staging/winbond/mds.c |   38 +++++++++++++++++++++++---------------
>  1 files changed, 23 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/staging/winbond/mds.c b/drivers/staging/winbond/mds.c
> index ef08b51..6082fa8 100644
> --- a/drivers/staging/winbond/mds.c
> +++ b/drivers/staging/winbond/mds.c
> @@ -400,30 +400,38 @@ static void Mds_HeaderCopy(struct wbsoft_priv *adapter,
>  							       * back rate
>  							       */
>  
> -		if (ctmp1 == 108)
> +		switch (ctmp1) {
> +		case 108:
>  			ctmp2 = 7;
> -		else if (ctmp1 == 96)
> +			break;
> +		case 96:
>  			ctmp2 = 6;	/* Rate convert for USB */
> -		else if (ctmp1 == 72)
> +			break;
> +		case 72:
>  			ctmp2 = 5;
> -		else if (ctmp1 == 48)
> +			break;
> +		case 48:
>  			ctmp2 = 4;
> -		else if (ctmp1 == 36)
> +			break;
> +		case 36:
> +		case 22:
>  			ctmp2 = 3;
> -		else if (ctmp1 == 24)
> +			break;
> +		case 24:
> +		case 11:
>  			ctmp2 = 2;
> -		else if (ctmp1 == 18)
> +			break;
> +		case 18:
> +		case 4:
>  			ctmp2 = 1;
> -		else if (ctmp1 == 12)
> +			break;
> +		case 12:
>  			ctmp2 = 0;
> -		else if (ctmp1 == 22)
> -			ctmp2 = 3;
> -		else if (ctmp1 == 11)
> -			ctmp2 = 2;
> -		else if (ctmp1 == 4)
> -			ctmp2 = 1;
> -		else
> +			break;
> +		default:
>  			ctmp2 = 0;	/* if (ctmp1 == 2) or default */
> +			break;
> +		}

Reordering the checks makes the patch harder to review but yeah, looks 
good to me.

Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>

			Pekka

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

* Re: [PATCH] staging: winbond: mds.c: converted long if-else to switch
  2010-03-16 22:37 [PATCH] staging: winbond: mds.c: converted long if-else to switch Lars Lindley
  2010-03-18 16:25 ` Pekka Enberg
@ 2010-03-21 20:02 ` Pavel Machek
  2010-04-28 22:51 ` Greg KH
  2 siblings, 0 replies; 6+ messages in thread
From: Pavel Machek @ 2010-03-21 20:02 UTC (permalink / raw)
  To: Lars Lindley; +Cc: gregkh, greg, penberg, diegoliz, devel, linux-kernel

On Tue 2010-03-16 23:37:28, Lars Lindley wrote:
> I converted the long if-else in function Mds_HeaderCopy() to a switch
> instead. It compiles fine but i don't have the hardware to test.
> Please check that I didn't do anything bad to it..
> The patch applies on top of this patch:
> Message-Id: <1268670973-6223-1-git-send-email-lindley@coyote.org>
> 
> Signed-off-by: Lars Lindley <lindley@coyote.org>

ACK.

> ---
>  drivers/staging/winbond/mds.c |   38 +++++++++++++++++++++++---------------
>  1 files changed, 23 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/staging/winbond/mds.c b/drivers/staging/winbond/mds.c
> index ef08b51..6082fa8 100644
> --- a/drivers/staging/winbond/mds.c
> +++ b/drivers/staging/winbond/mds.c
> @@ -400,30 +400,38 @@ static void Mds_HeaderCopy(struct wbsoft_priv *adapter,
>  							       * back rate
>  							       */
>  
> -		if (ctmp1 == 108)
> +		switch (ctmp1) {
> +		case 108:
>  			ctmp2 = 7;
> -		else if (ctmp1 == 96)
> +			break;
> +		case 96:
>  			ctmp2 = 6;	/* Rate convert for USB */
> -		else if (ctmp1 == 72)
> +			break;
> +		case 72:
>  			ctmp2 = 5;
> -		else if (ctmp1 == 48)
> +			break;
> +		case 48:
>  			ctmp2 = 4;
> -		else if (ctmp1 == 36)
> +			break;
> +		case 36:
> +		case 22:
>  			ctmp2 = 3;
> -		else if (ctmp1 == 24)
> +			break;
> +		case 24:
> +		case 11:
>  			ctmp2 = 2;
> -		else if (ctmp1 == 18)
> +			break;
> +		case 18:
> +		case 4:
>  			ctmp2 = 1;
> -		else if (ctmp1 == 12)
> +			break;
> +		case 12:
>  			ctmp2 = 0;
> -		else if (ctmp1 == 22)
> -			ctmp2 = 3;
> -		else if (ctmp1 == 11)
> -			ctmp2 = 2;
> -		else if (ctmp1 == 4)
> -			ctmp2 = 1;
> -		else
> +			break;
> +		default:
>  			ctmp2 = 0;	/* if (ctmp1 == 2) or default */
> +			break;
> +		}
>  
>  		if (i == 0)
>  			pT01->T01_transmit_rate = ctmp2;

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

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

* Re: [PATCH] staging: winbond: mds.c: converted long if-else to switch
  2010-03-16 22:37 [PATCH] staging: winbond: mds.c: converted long if-else to switch Lars Lindley
  2010-03-18 16:25 ` Pekka Enberg
  2010-03-21 20:02 ` Pavel Machek
@ 2010-04-28 22:51 ` Greg KH
  2010-05-02  8:35   ` Lars Lindley
  2 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2010-04-28 22:51 UTC (permalink / raw)
  To: Lars Lindley; +Cc: gregkh, penberg, pavel, diegoliz, devel, linux-kernel

On Tue, Mar 16, 2010 at 11:37:28PM +0100, Lars Lindley wrote:
> I converted the long if-else in function Mds_HeaderCopy() to a switch
> instead. It compiles fine but i don't have the hardware to test.
> Please check that I didn't do anything bad to it..
> The patch applies on top of this patch:
> Message-Id: <1268670973-6223-1-git-send-email-lindley@coyote.org>
> 
> Signed-off-by: Lars Lindley <lindley@coyote.org>

This doesn't apply on top of linux-next, care to respin it?

thanks,

greg k-h

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

* Re: [PATCH] staging: winbond: mds.c: converted long if-else to switch
  2010-04-28 22:51 ` Greg KH
@ 2010-05-02  8:35   ` Lars Lindley
  2010-05-03 18:46     ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Lars Lindley @ 2010-05-02  8:35 UTC (permalink / raw)
  To: Greg KH; +Cc: gregkh, penberg, pavel, diegoliz, devel, linux-kernel

On 2010-04-29 00:51, Greg KH wrote:
> On Tue, Mar 16, 2010 at 11:37:28PM +0100, Lars Lindley wrote:
>> I converted the long if-else in function Mds_HeaderCopy() to a switch
>> instead. It compiles fine but i don't have the hardware to test.
>> Please check that I didn't do anything bad to it..
>> The patch applies on top of this patch:
>> Message-Id: <1268670973-6223-1-git-send-email-lindley@coyote.org>
>>
>> Signed-off-by: Lars Lindley <lindley@coyote.org>
> 
> This doesn't apply on top of linux-next, care to respin it?
> 
> thanks,
> 
> greg k-h
> 
Not sure what you want me to do.. :)

Regards, Lars

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

* Re: [PATCH] staging: winbond: mds.c: converted long if-else to switch
  2010-05-02  8:35   ` Lars Lindley
@ 2010-05-03 18:46     ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2010-05-03 18:46 UTC (permalink / raw)
  To: Lars Lindley; +Cc: gregkh, penberg, pavel, diegoliz, devel, linux-kernel

On Sun, May 02, 2010 at 10:35:43AM +0200, Lars Lindley wrote:
> On 2010-04-29 00:51, Greg KH wrote:
> > On Tue, Mar 16, 2010 at 11:37:28PM +0100, Lars Lindley wrote:
> >> I converted the long if-else in function Mds_HeaderCopy() to a switch
> >> instead. It compiles fine but i don't have the hardware to test.
> >> Please check that I didn't do anything bad to it..
> >> The patch applies on top of this patch:
> >> Message-Id: <1268670973-6223-1-git-send-email-lindley@coyote.org>
> >>
> >> Signed-off-by: Lars Lindley <lindley@coyote.org>
> > 
> > This doesn't apply on top of linux-next, care to respin it?
> > 
> > thanks,
> > 
> > greg k-h
> > 
> Not sure what you want me to do.. :)

Download the linux-next tree and rebase your patch on top of that and
then resend it.

thanks,

greg k-h

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

end of thread, other threads:[~2010-05-03 19:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-16 22:37 [PATCH] staging: winbond: mds.c: converted long if-else to switch Lars Lindley
2010-03-18 16:25 ` Pekka Enberg
2010-03-21 20:02 ` Pavel Machek
2010-04-28 22:51 ` Greg KH
2010-05-02  8:35   ` Lars Lindley
2010-05-03 18:46     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox