ALSA: usb-audio: reconstruct some dispatcher functions to use switch-case
Daniel Mack [Fri, 11 Feb 2011 11:34:12 +0000 (11:34 +0000)]
The number of cases has increased so use switch-case rather than
if-statements.

Signed-off-by: Daniel Mack <daniel@caiaq.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

sound/usb/mixer_quirks.c
sound/usb/quirks.c

index 3fe612a..73dcc82 100644 (file)
@@ -502,49 +502,44 @@ void snd_emuusb_set_samplerate(struct snd_usb_audio *chip,
 
 int snd_usb_mixer_apply_create_quirk(struct usb_mixer_interface *mixer)
 {
-       int err;
+       int err = 0;
        struct snd_info_entry *entry;
 
        if ((err = snd_usb_soundblaster_remote_init(mixer)) < 0)
                return err;
 
-       if (mixer->chip->usb_id == USB_ID(0x041e, 0x3020) ||
-           mixer->chip->usb_id == USB_ID(0x041e, 0x3040) ||
-           mixer->chip->usb_id == USB_ID(0x041e, 0x3042) ||
-           mixer->chip->usb_id == USB_ID(0x041e, 0x3048)) {
-               if ((err = snd_audigy2nx_controls_create(mixer)) < 0)
-                       return err;
+       switch (mixer->chip->usb_id) {
+       case USB_ID(0x041e, 0x3020):
+       case USB_ID(0x041e, 0x3040):
+       case USB_ID(0x041e, 0x3042):
+       case USB_ID(0x041e, 0x3048):
+               err = snd_audigy2nx_controls_create(mixer);
+               if (err < 0)
+                       break;
                if (!snd_card_proc_new(mixer->chip->card, "audigy2nx", &entry))
                        snd_info_set_text_ops(entry, mixer,
                                              snd_audigy2nx_proc_read);
-       }
+               break;
 
-       if (mixer->chip->usb_id == USB_ID(0x0b05, 0x1739) ||
-           mixer->chip->usb_id == USB_ID(0x0b05, 0x1743)) {
+       case USB_ID(0x0b05, 0x1739):
+       case USB_ID(0x0b05, 0x1743):
                err = snd_xonar_u1_controls_create(mixer);
-               if (err < 0)
-                       return err;
-       }
+               break;
 
-       /* Traktor Audio 6 */
-       if (mixer->chip->usb_id == USB_ID(0x17cc, 0x1011)) {
+       case USB_ID(0x17cc, 0x1011): /* Traktor Audio 6 */
                err = snd_nativeinstruments_create_mixer(mixer,
                                snd_nativeinstruments_ta6_mixers,
                                ARRAY_SIZE(snd_nativeinstruments_ta6_mixers));
-               if (err < 0)
-                       return err;
-       }
+               break;
 
-       /* Traktor Audio 10 */
-       if (mixer->chip->usb_id == USB_ID(0x17cc, 0x1021)) {
+       case USB_ID(0x17cc, 0x1021): /* Traktor Audio 10 */
                err = snd_nativeinstruments_create_mixer(mixer,
                                snd_nativeinstruments_ta10_mixers,
                                ARRAY_SIZE(snd_nativeinstruments_ta10_mixers));
-               if (err < 0)
-                       return err;
+               break;
        }
 
-       return 0;
+       return err;
 }
 
 void snd_usb_mixer_rc_memory_change(struct usb_mixer_interface *mixer,
index e55bd1c..ca860e6 100644 (file)
@@ -517,31 +517,32 @@ int snd_usb_apply_boot_quirk(struct usb_device *dev,
        u32 id = USB_ID(le16_to_cpu(dev->descriptor.idVendor),
                        le16_to_cpu(dev->descriptor.idProduct));
 
-       /* SB Extigy needs special boot-up sequence */
-       /* if more models come, this will go to the quirk list. */
-       if (id == USB_ID(0x041e, 0x3000))
+       switch (id) {
+       case USB_ID(0x041e, 0x3000):
+               /* SB Extigy needs special boot-up sequence */
+               /* if more models come, this will go to the quirk list. */
                return snd_usb_extigy_boot_quirk(dev, intf);
 
-       /* SB Audigy 2 NX needs its own boot-up magic, too */
-       if (id == USB_ID(0x041e, 0x3020))
+       case USB_ID(0x041e, 0x3020):
+               /* SB Audigy 2 NX needs its own boot-up magic, too */
                return snd_usb_audigy2nx_boot_quirk(dev);
 
-       /* C-Media CM106 / Turtle Beach Audio Advantage Roadie */
-       if (id == USB_ID(0x10f5, 0x0200))
+       case USB_ID(0x10f5, 0x0200):
+               /* C-Media CM106 / Turtle Beach Audio Advantage Roadie */
                return snd_usb_cm106_boot_quirk(dev);
 
-       /* C-Media CM6206 / CM106-Like Sound Device */
-       if (id == USB_ID(0x0d8c, 0x0102))
+       case USB_ID(0x0d8c, 0x0102):
+               /* C-Media CM6206 / CM106-Like Sound Device */
                return snd_usb_cm6206_boot_quirk(dev);
 
-       /* Access Music VirusTI Desktop */
-       if (id == USB_ID(0x133e, 0x0815))
+       case USB_ID(0x133e, 0x0815):
+               /* Access Music VirusTI Desktop */
                return snd_usb_accessmusic_boot_quirk(dev);
 
-       /* Native Instruments Devices */
-       if (id == USB_ID(0x17cc, 0x1010) || /* Traktor Audio 6 */
-               id == USB_ID(0x17cc, 0x1020)) /* Traktor Audio 10 */
+       case USB_ID(0x17cc, 0x1010): /* Traktor Audio 6 */
+       case USB_ID(0x17cc, 0x1020): /* Traktor Audio 10 */
                return snd_usb_nativeinstruments_boot_quirk(dev);
+       }
 
        return 0;
 }