diff options
author | Takashi Iwai <tiwai@suse.de> | 2013-02-07 04:45:11 -0500 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-02-07 04:45:11 -0500 |
commit | 0186f4f4f248d00a2bfcd7c305cfec12fa8e5e30 (patch) | |
tree | 82ad54f92327772ed6fee19638b396d9eb54f0d0 /sound/pci/hda/hda_generic.c | |
parent | 46a144818acd8b340bdc6ccf12255c7fb301f0ee (diff) |
ALSA: hda - Use generic array for loopback list management
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_generic.c')
-rw-r--r-- | sound/pci/hda/hda_generic.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index c2cd3d6b6003..6af5aded1ed5 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
@@ -42,6 +42,7 @@ int snd_hda_gen_spec_init(struct hda_gen_spec *spec) | |||
42 | { | 42 | { |
43 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); | 43 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); |
44 | snd_array_init(&spec->paths, sizeof(struct nid_path), 8); | 44 | snd_array_init(&spec->paths, sizeof(struct nid_path), 8); |
45 | snd_array_init(&spec->loopback_list, sizeof(struct hda_amp_list), 8); | ||
45 | mutex_init(&spec->pcm_mutex); | 46 | mutex_init(&spec->pcm_mutex); |
46 | return 0; | 47 | return 0; |
47 | } | 48 | } |
@@ -82,6 +83,7 @@ void snd_hda_gen_spec_free(struct hda_gen_spec *spec) | |||
82 | return; | 83 | return; |
83 | free_kctls(spec); | 84 | free_kctls(spec); |
84 | snd_array_free(&spec->paths); | 85 | snd_array_free(&spec->paths); |
86 | snd_array_free(&spec->loopback_list); | ||
85 | } | 87 | } |
86 | EXPORT_SYMBOL_HDA(snd_hda_gen_spec_free); | 88 | EXPORT_SYMBOL_HDA(snd_hda_gen_spec_free); |
87 | 89 | ||
@@ -2484,18 +2486,18 @@ static int create_in_jack_mode(struct hda_codec *codec, hda_nid_t pin) | |||
2484 | */ | 2486 | */ |
2485 | 2487 | ||
2486 | /* add the powersave loopback-list entry */ | 2488 | /* add the powersave loopback-list entry */ |
2487 | static void add_loopback_list(struct hda_gen_spec *spec, hda_nid_t mix, int idx) | 2489 | static int add_loopback_list(struct hda_gen_spec *spec, hda_nid_t mix, int idx) |
2488 | { | 2490 | { |
2489 | struct hda_amp_list *list; | 2491 | struct hda_amp_list *list; |
2490 | 2492 | ||
2491 | if (spec->num_loopbacks >= ARRAY_SIZE(spec->loopback_list) - 1) | 2493 | list = snd_array_new(&spec->loopback_list); |
2492 | return; | 2494 | if (!list) |
2493 | list = spec->loopback_list + spec->num_loopbacks; | 2495 | return -ENOMEM; |
2494 | list->nid = mix; | 2496 | list->nid = mix; |
2495 | list->dir = HDA_INPUT; | 2497 | list->dir = HDA_INPUT; |
2496 | list->idx = idx; | 2498 | list->idx = idx; |
2497 | spec->num_loopbacks++; | 2499 | spec->loopback.amplist = spec->loopback_list.list; |
2498 | spec->loopback.amplist = spec->loopback_list; | 2500 | return 0; |
2499 | } | 2501 | } |
2500 | 2502 | ||
2501 | /* create input playback/capture controls for the given pin */ | 2503 | /* create input playback/capture controls for the given pin */ |
@@ -2536,7 +2538,9 @@ static int new_analog_input(struct hda_codec *codec, int input_idx, | |||
2536 | } | 2538 | } |
2537 | 2539 | ||
2538 | path->active = true; | 2540 | path->active = true; |
2539 | add_loopback_list(spec, mix_nid, idx); | 2541 | err = add_loopback_list(spec, mix_nid, idx); |
2542 | if (err < 0) | ||
2543 | return err; | ||
2540 | 2544 | ||
2541 | if (spec->mixer_nid != spec->mixer_merge_nid && | 2545 | if (spec->mixer_nid != spec->mixer_merge_nid && |
2542 | !spec->loopback_merge_path) { | 2546 | !spec->loopback_merge_path) { |