Skip to contentSkip to conversation

usb: gadget: function: remove redundant else statement

PATCH In review Colin Ian King 2 participants 2 messages Nov 7, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: gadget: function: remove redundant else statement

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.

---
 drivers/usb/gadget/function/f_midi2.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/gadget/function/f_midi2.c +1 -3
index 8285df9ed6fd..5f3f6e7700c7 100644
@@ -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;
 
Signature · 1 line
2.39.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Colin Ian King

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.

Also worth to put the original discussion thread:

thanks,

Takashi

Quoted 29 lines
---
 drivers/usb/gadget/function/f_midi2.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/gadget/function/f_midi2.c +1 -3
index 8285df9ed6fd..5f3f6e7700c7 100644
@@ -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;
 
Signature · 1 line
2.39.5