ALSA: fireface: code refactoring to decide name of sound card
authorTakashi Sakamoto <o-takashi@sakamocchi.jp>
Sun, 10 May 2020 07:42:59 +0000 (16:42 +0900)
committerTakashi Iwai <tiwai@suse.de>
Sun, 10 May 2020 10:03:49 +0000 (12:03 +0200)
This commit uses enumeration constants as index of table for the
list of name of sound card.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Link: https://lore.kernel.org/r/20200510074301.116224-5-o-takashi@sakamocchi.jp
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/firewire/fireface/ff.c
sound/firewire/fireface/ff.h

index b295e40..dd3cd25 100644 (file)
@@ -16,12 +16,20 @@ MODULE_LICENSE("GPL v2");
 static void name_card(struct snd_ff *ff)
 {
        struct fw_device *fw_dev = fw_parent_device(ff->unit);
+       const char *const names[] = {
+               [SND_FF_UNIT_VERSION_FF800]     = "Fireface800",
+               [SND_FF_UNIT_VERSION_FF400]     = "Fireface400",
+               [SND_FF_UNIT_VERSION_UCX]       = "FirefaceUCX",
+       };
+       const char *name;
+
+       name = names[ff->unit_version];
 
        strcpy(ff->card->driver, "Fireface");
-       strcpy(ff->card->shortname, ff->spec->name);
-       strcpy(ff->card->mixername, ff->spec->name);
+       strcpy(ff->card->shortname, name);
+       strcpy(ff->card->mixername, name);
        snprintf(ff->card->longname, sizeof(ff->card->longname),
-                "RME %s, GUID %08x%08x at %s, S%d", ff->spec->name,
+                "RME %s, GUID %08x%08x at %s, S%d", name,
                 fw_dev->config_rom[3], fw_dev->config_rom[4],
                 dev_name(&ff->unit->device), 100 << fw_dev->max_speed);
 }
@@ -101,6 +109,7 @@ static int snd_ff_probe(struct fw_unit *unit,
        spin_lock_init(&ff->lock);
        init_waitqueue_head(&ff->hwdep_wait);
 
+       ff->unit_version = entry->version;
        ff->spec = (const struct snd_ff_spec *)entry->driver_data;
 
        /* Register this sound card later. */
@@ -145,7 +154,6 @@ static void snd_ff_remove(struct fw_unit *unit)
 }
 
 static const struct snd_ff_spec spec_ff800 = {
-       .name = "Fireface800",
        .pcm_capture_channels = {28, 20, 12},
        .pcm_playback_channels = {28, 20, 12},
        .midi_in_ports = 1,
@@ -157,7 +165,6 @@ static const struct snd_ff_spec spec_ff800 = {
 };
 
 static const struct snd_ff_spec spec_ff400 = {
-       .name = "Fireface400",
        .pcm_capture_channels = {18, 14, 10},
        .pcm_playback_channels = {18, 14, 10},
        .midi_in_ports = 2,
@@ -169,7 +176,6 @@ static const struct snd_ff_spec spec_ff400 = {
 };
 
 static const struct snd_ff_spec spec_ucx = {
-       .name = "FirefaceUCX",
        .pcm_capture_channels = {18, 14, 12},
        .pcm_playback_channels = {18, 14, 12},
        .midi_in_ports = 2,
index 62ad921..0c4fe7c 100644 (file)
@@ -49,8 +49,6 @@ enum snd_ff_stream_mode {
 
 struct snd_ff_protocol;
 struct snd_ff_spec {
-       const char *const name;
-
        const unsigned int pcm_capture_channels[SND_FF_STREAM_MODE_COUNT];
        const unsigned int pcm_playback_channels[SND_FF_STREAM_MODE_COUNT];
 
@@ -72,6 +70,7 @@ struct snd_ff {
        bool registered;
        struct delayed_work dwork;
 
+       enum snd_ff_unit_version unit_version;
        const struct snd_ff_spec *spec;
 
        /* To handle MIDI tx. */