linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] usb: gadget: function: remove redundant else statement
@ 2024-11-07 13:33 Colin Ian King
  2024-11-07 13:48 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Colin Ian King @ 2024-11-07 13:33 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Takashi Iwai, linux-usb; +Cc: kernel-janitors, linux-kernel

After an initial range change on the insigned int alt being > 1
the only possible values for alt are 0 or 1. Therefore the else
statement for values other than 0 or 1 is redundant and can be
removed. Replace the else if (all == 1) check with just an else.

Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 drivers/usb/gadget/function/f_midi2.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/usb/gadget/function/f_midi2.c b/drivers/usb/gadget/function/f_midi2.c
index 8285df9ed6fd..5f3f6e7700c7 100644
--- a/drivers/usb/gadget/function/f_midi2.c
+++ b/drivers/usb/gadget/function/f_midi2.c
@@ -1282,16 +1282,14 @@ static int f_midi2_set_alt(struct usb_function *fn, unsigned int intf,
 
 	if (intf != midi2->midi_if || alt > 1)
 		return 0;
 
 	if (alt == 0)
 		op_mode = MIDI_OP_MODE_MIDI1;
-	else if (alt == 1)
+	else
 		op_mode = MIDI_OP_MODE_MIDI2;
-	else
-		op_mode = MIDI_OP_MODE_UNSET;
 
 	if (midi2->operation_mode == op_mode)
 		return 0;
 
 	midi2->operation_mode = op_mode;
 
-- 
2.39.5


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

* Re: [PATCH][next] usb: gadget: function: remove redundant else statement
  2024-11-07 13:33 [PATCH][next] usb: gadget: function: remove redundant else statement Colin Ian King
@ 2024-11-07 13:48 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2024-11-07 13:48 UTC (permalink / raw)
  To: Colin Ian King
  Cc: Greg Kroah-Hartman, Takashi Iwai, linux-usb, kernel-janitors,
	linux-kernel

On Thu, 07 Nov 2024 14:33:48 +0100,
Colin Ian King wrote:
> 
> After an initial range change on the insigned int alt being > 1
> the only possible values for alt are 0 or 1. Therefore the else
> statement for values other than 0 or 1 is redundant and can be
> removed. Replace the else if (all == 1) check with just an else.
> 
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>

Reviewed-by: Takashi Iwai <tiwai@suse.de>

Also worth to put the original discussion thread:

Link: https://lore.kernel.org/5f54ffd0-b5fe-4203-a626-c166becad362@gmail.com


thanks,

Takashi

> ---
>  drivers/usb/gadget/function/f_midi2.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/usb/gadget/function/f_midi2.c b/drivers/usb/gadget/function/f_midi2.c
> index 8285df9ed6fd..5f3f6e7700c7 100644
> --- a/drivers/usb/gadget/function/f_midi2.c
> +++ b/drivers/usb/gadget/function/f_midi2.c
> @@ -1282,16 +1282,14 @@ static int f_midi2_set_alt(struct usb_function *fn, unsigned int intf,
>  
>  	if (intf != midi2->midi_if || alt > 1)
>  		return 0;
>  
>  	if (alt == 0)
>  		op_mode = MIDI_OP_MODE_MIDI1;
> -	else if (alt == 1)
> +	else
>  		op_mode = MIDI_OP_MODE_MIDI2;
> -	else
> -		op_mode = MIDI_OP_MODE_UNSET;
>  
>  	if (midi2->operation_mode == op_mode)
>  		return 0;
>  
>  	midi2->operation_mode = op_mode;
>  
> -- 
> 2.39.5
> 

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

end of thread, other threads:[~2024-11-07 13:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-07 13:33 [PATCH][next] usb: gadget: function: remove redundant else statement Colin Ian King
2024-11-07 13:48 ` Takashi Iwai

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