]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
ALSA: 6fire: Reduce multi-level conditionals in usb6fire_chip_disconnect()
authorTakashi Iwai <tiwai@suse.de>
Tue, 14 Apr 2026 13:22:13 +0000 (15:22 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 15 Apr 2026 12:27:27 +0000 (14:27 +0200)
The current code has deep indentation levels because of multiple if's.
Make it returning and reduce the multi-level conditionals for
increasing the code readability.

No functional change, just but a code refactoring.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20260414132218.411013-4-tiwai@suse.de
sound/usb/6fire/chip.c

index dd787de986b1a31cdacebd248a6cdef3cfbbcf47..556882bd90227c32c8a596fae70593afb60c3b44 100644 (file)
@@ -165,26 +165,29 @@ static void usb6fire_chip_disconnect(struct usb_interface *intf)
 
        guard(mutex)(&register_mutex);
        chip = usb_get_intfdata(intf);
-       if (chip) { /* if !chip, fw upload has been performed */
-               chip->intf_count--;
-               if (!chip->intf_count) {
-                       chips[chip->regidx] = NULL;
-
-                       /*
-                        * Save card pointer before teardown.
-                        * snd_card_free_when_closed() may free card (and
-                        * the embedded chip) immediately, so it must be
-                        * called last and chip must not be accessed after.
-                        */
-                       card = chip->card;
-                       chip->shutdown = true;
-                       if (card)
-                               snd_card_disconnect(card);
-                       usb6fire_chip_abort(chip);
-                       if (card)
-                               snd_card_free_when_closed(card);
-               }
-       }
+       /* if !chip, fw upload has been performed */
+       if (!chip)
+               return;
+
+       chip->intf_count--;
+       if (chip->intf_count)
+               return;
+
+       chips[chip->regidx] = NULL;
+
+       /*
+        * Save card pointer before teardown.
+        * snd_card_free_when_closed() may free card (and
+        * the embedded chip) immediately, so it must be
+        * called last and chip must not be accessed after.
+        */
+       card = chip->card;
+       chip->shutdown = true;
+       if (card)
+               snd_card_disconnect(card);
+       usb6fire_chip_abort(chip);
+       if (card)
+               snd_card_free_when_closed(card);
 }
 
 static const struct usb_device_id device_table[] = {