]> git.openfabrics.org - ~shefty/rdma-dev.git/commitdiff
ALSA: hda-intel: Cleanups for widget connection list handling
authorJaroslav Kysela <perex@perex.cz>
Wed, 22 Jul 2009 14:20:40 +0000 (16:20 +0200)
committerTakashi Iwai <tiwai@suse.de>
Wed, 22 Jul 2009 14:30:03 +0000 (16:30 +0200)
This patch adds a check to snd_hda_get_connections() routine for
presence of AC_WCAP_CONN_LIST. Also, make sure that negative error
codes from noted route are handled on all places as errors.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_codec.c
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_sigmatel.c

index 3ecb45ddadf7f6710df320a421c6d45f2d76aeda..aa5540786111657f88609cedd0b9b388f25d3cb3 100644 (file)
@@ -306,6 +306,12 @@ int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
        if (snd_BUG_ON(!conn_list || max_conns <= 0))
                return -EINVAL;
 
+       if ((get_wcaps(codec, nid) & AC_WCAP_CONN_LIST) == 0) {
+               snd_printk(KERN_WARNING "hda_codec: "
+                          "connection list not available for 0x%x\n", nid);
+               return -EINVAL;
+       }
+
        parm = snd_hda_param_read(codec, nid, AC_PAR_CONNLIST_LEN);
        if (parm & AC_CLIST_LONG) {
                /* long form */
index b2ea43206f182a975ca24ab45239ab36d72f3d0c..728f2a72f9b672f4baa79f8dc69cc76a06d8fb79 100644 (file)
@@ -4501,12 +4501,6 @@ static int alc880_parse_auto_config(struct hda_codec *codec)
                                              &dig_nid, 1);
                if (err < 0)
                        continue;
-               if (dig_nid > 0x7f) {
-                       printk(KERN_ERR "alc880_auto: invalid dig_nid "
-                               "connection 0x%x for NID 0x%x\n", dig_nid,
-                               spec->autocfg.dig_out_pins[i]);
-                       continue;
-               }
                if (!i)
                        spec->multiout.dig_out_nid = dig_nid;
                else {
index 00c702df721ccd0a0573e8c58b5ffbed778117d3..948600dd3b90e1a2f536bc970d61c10f1e853764 100644 (file)
@@ -3389,7 +3389,7 @@ static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
                                spec->mono_nid,
                                con_lst,
                                HDA_MAX_NUM_INPUTS);
-       if (!num_cons || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
+       if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
                return -EINVAL;
 
        for (i = 0; i < num_cons; i++) {
@@ -3535,7 +3535,7 @@ static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
                                spec->smux_nids[0],
                                con_lst,
                                HDA_MAX_NUM_INPUTS);
-       if (!num_cons)
+       if (num_cons <= 0)
                return -EINVAL;
 
        if (!labels)
@@ -3742,7 +3742,7 @@ static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out
                if (snd_hda_get_connections(codec,
                                spec->autocfg.mono_out_pin, conn_list, 1) &&
                                snd_hda_get_connections(codec, conn_list[0],
-                               conn_list, 1)) {
+                               conn_list, 1) > 0) {
 
                                int wcaps = get_wcaps(codec, conn_list[0]);
                                int wid_type = (wcaps & AC_WCAP_TYPE)
@@ -5169,6 +5169,8 @@ again:
 
        num_dacs = snd_hda_get_connections(codec, nid,
                                conn, STAC92HD83_DAC_COUNT + 1) - 1;
+       if (num_dacs < 0)
+               num_dacs = STAC92HD83_DAC_COUNT;
 
        /* set port X to select the last DAC
         */