diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-11-30 08:31:30 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-11-30 11:49:02 +0100 |
commit | 475c3d21e8e1fe7cbec76b0f3e8d9f4dea66acd8 (patch) | |
tree | 5a83084d2c6da41edda11e73858e9e6980db58ee /sound/pci | |
parent | ALSA: hda - Refactor alc_kcontrol_new() usages (diff) | |
download | linux-475c3d21e8e1fe7cbec76b0f3e8d9f4dea66acd8.tar.xz linux-475c3d21e8e1fe7cbec76b0f3e8d9f4dea66acd8.zip |
ALSA: hda - Pass errors properly in alc_auto_check_switches()
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 59 |
1 files changed, 37 insertions, 22 deletions
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 6d57547aecac..0062c9f401c3 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -930,12 +930,12 @@ static int alc_add_automute_mode_enum(struct hda_codec *codec) * Check the availability of HP/line-out auto-mute; * Set up appropriately if really supported */ -static void alc_init_automute(struct hda_codec *codec) +static int alc_init_automute(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; int present = 0; - int i; + int i, err; if (cfg->hp_pins[0]) present++; @@ -944,7 +944,7 @@ static void alc_init_automute(struct hda_codec *codec) if (cfg->speaker_pins[0]) present++; if (present < 2) /* need two different output types */ - return; + return 0; if (!cfg->speaker_pins[0] && cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) { @@ -994,9 +994,13 @@ static void alc_init_automute(struct hda_codec *codec) spec->automute_lo = spec->automute_lo_possible; spec->automute_speaker = spec->automute_speaker_possible; - if (spec->automute_speaker_possible || spec->automute_lo_possible) + if (spec->automute_speaker_possible || spec->automute_lo_possible) { /* create a control for automute mode */ - alc_add_automute_mode_enum(codec); + err = alc_add_automute_mode_enum(codec); + if (err < 0) + return err; + } + return 0; } /* return the position of NID in the list, or -1 if not found */ @@ -1096,7 +1100,7 @@ static bool alc_auto_mic_check_imux(struct hda_codec *codec) * Check the availability of auto-mic switch; * Set up if really supported */ -static void alc_init_auto_mic(struct hda_codec *codec) +static int alc_init_auto_mic(struct hda_codec *codec) { struct alc_spec *spec = codec->spec; struct auto_pin_cfg *cfg = &spec->autocfg; @@ -1104,7 +1108,7 @@ static void alc_init_auto_mic(struct hda_codec *codec) int i; if (spec->shared_mic_hp) - return; /* no auto-mic for the shared I/O */ + return 0; /* no auto-mic for the shared I/O */ spec->ext_mic_idx = spec->int_mic_idx = spec->dock_mic_idx = -1; @@ -1116,25 +1120,25 @@ static void alc_init_auto_mic(struct hda_codec *codec) switch (snd_hda_get_input_pin_attr(defcfg)) { case INPUT_PIN_ATTR_INT: if (fixed) - return; /* already occupied */ + return 0; /* already occupied */ if (cfg->inputs[i].type != AUTO_PIN_MIC) - return; /* invalid type */ + return 0; /* invalid type */ fixed = nid; break; case INPUT_PIN_ATTR_UNUSED: - return; /* invalid entry */ + return 0; /* invalid entry */ case INPUT_PIN_ATTR_DOCK: if (dock) - return; /* already occupied */ + return 0; /* already occupied */ if (cfg->inputs[i].type > AUTO_PIN_LINE_IN) - return; /* invalid type */ + return 0; /* invalid type */ dock = nid; break; default: if (ext) - return; /* already occupied */ + return 0; /* already occupied */ if (cfg->inputs[i].type != AUTO_PIN_MIC) - return; /* invalid type */ + return 0; /* invalid type */ ext = nid; break; } @@ -1144,11 +1148,11 @@ static void alc_init_auto_mic(struct hda_codec *codec) dock = 0; } if (!ext || !fixed) - return; + return 0; if (!is_jack_detectable(codec, ext)) - return; /* no unsol support */ + return 0; /* no unsol support */ if (dock && !is_jack_detectable(codec, dock)) - return; /* no unsol support */ + return 0; /* no unsol support */ /* check imux indices */ spec->ext_mic_pin = ext; @@ -1157,17 +1161,26 @@ static void alc_init_auto_mic(struct hda_codec *codec) spec->auto_mic = 1; if (!alc_auto_mic_check_imux(codec)) - return; + return 0; snd_printdd("realtek: Enable auto-mic switch on NID 0x%x/0x%x/0x%x\n", ext, fixed, dock); + + return 0; } /* check the availabilities of auto-mute and auto-mic switches */ -static void alc_auto_check_switches(struct hda_codec *codec) +static int alc_auto_check_switches(struct hda_codec *codec) { - alc_init_automute(codec); - alc_init_auto_mic(codec); + int err; + + err = alc_init_automute(codec); + if (err < 0) + return err; + err = alc_init_auto_mic(codec); + if (err < 0) + return err; + return 0; } /* @@ -4338,7 +4351,9 @@ static int alc_parse_auto_config(struct hda_codec *codec, alc_ssid_check(codec, ssid_nids); if (!spec->no_analog) { - alc_auto_check_switches(codec); + err = alc_auto_check_switches(codec); + if (err < 0) + return err; err = alc_auto_add_mic_boost(codec); if (err < 0) return err; |