ALSA: hda - constify and cleanup static NodeID tables
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>
Fri, 3 Jan 2020 09:23:48 +0000 (10:23 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 3 Jan 2020 09:38:38 +0000 (10:38 +0100)
Make hda_nid_t tables static const, as they are not intended to be
modified by callees.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
Link: https://lore.kernel.org/r/5150c94101c9534f4c8e987324f6912c16d459f6.1578043216.git.mirq-linux@rere.qmqm.pl
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_generic.c
sound/pci/hda/patch_analog.c
sound/pci/hda/patch_ca0132.c
sound/pci/hda/patch_conexant.c
sound/pci/hda/patch_realtek.c
sound/pci/hda/patch_sigmatel.c
sound/pci/hda/patch_via.c

index 10d502328b76eee5e480a777f691e29fd2884d23..fc001c64ef20ff63f9a11dead2d74431782c53ce 100644 (file)
@@ -4401,7 +4401,7 @@ EXPORT_SYMBOL_GPL(snd_hda_gen_fix_pin_power);
  */
 
 /* check each pin in the given array; returns true if any of them is plugged */
-static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
+static bool detect_jacks(struct hda_codec *codec, int num_pins, const hda_nid_t *pins)
 {
        int i;
        bool present = false;
@@ -4420,7 +4420,7 @@ static bool detect_jacks(struct hda_codec *codec, int num_pins, hda_nid_t *pins)
 }
 
 /* standard HP/line-out auto-mute helper */
-static void do_automute(struct hda_codec *codec, int num_pins, hda_nid_t *pins,
+static void do_automute(struct hda_codec *codec, int num_pins, const hda_nid_t *pins,
                        int *paths, bool mute)
 {
        struct hda_gen_spec *spec = codec->spec;
index bc9dd8e6fd86900659cf10852eeefa5ed0075dcc..c64895f992996903f7ef55fc35d1c02e2de42695 100644 (file)
@@ -389,7 +389,7 @@ static int patch_ad1986a(struct hda_codec *codec)
 {
        int err;
        struct ad198x_spec *spec;
-       static hda_nid_t preferred_pairs[] = {
+       static const hda_nid_t preferred_pairs[] = {
                0x1a, 0x03,
                0x1b, 0x03,
                0x1c, 0x04,
@@ -519,9 +519,9 @@ static int ad1983_add_spdif_mux_ctl(struct hda_codec *codec)
 
 static int patch_ad1983(struct hda_codec *codec)
 {
+       static const hda_nid_t conn_0c[] = { 0x08 };
+       static const hda_nid_t conn_0d[] = { 0x09 };
        struct ad198x_spec *spec;
-       static hda_nid_t conn_0c[] = { 0x08 };
-       static hda_nid_t conn_0d[] = { 0x09 };
        int err;
 
        err = alloc_ad_spec(codec);
index 32ed46464af7ad0a3ec1197cb935db3a1571317f..250534f90ce0960605f4b4a7cf0eb6b46a282192 100644 (file)
@@ -7802,23 +7802,23 @@ static void sbz_region2_exit(struct hda_codec *codec)
 
 static void sbz_set_pin_ctl_default(struct hda_codec *codec)
 {
-       hda_nid_t pins[5] = {0x0B, 0x0C, 0x0E, 0x12, 0x13};
+       static const hda_nid_t pins[] = {0x0B, 0x0C, 0x0E, 0x12, 0x13};
        unsigned int i;
 
        snd_hda_codec_write(codec, 0x11, 0,
                        AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40);
 
-       for (i = 0; i < 5; i++)
+       for (i = 0; i < ARRAY_SIZE(pins); i++)
                snd_hda_codec_write(codec, pins[i], 0,
                                AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00);
 }
 
 static void ca0132_clear_unsolicited(struct hda_codec *codec)
 {
-       hda_nid_t pins[7] = {0x0B, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13};
+       static const hda_nid_t pins[] = {0x0B, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13};
        unsigned int i;
 
-       for (i = 0; i < 7; i++) {
+       for (i = 0; i < ARRAY_SIZE(pins); i++) {
                snd_hda_codec_write(codec, pins[i], 0,
                                AC_VERB_SET_UNSOLICITED_ENABLE, 0x00);
        }
@@ -7842,10 +7842,10 @@ static void sbz_gpio_shutdown_commands(struct hda_codec *codec, int dir,
 
 static void zxr_dbpro_power_state_shutdown(struct hda_codec *codec)
 {
-       hda_nid_t pins[7] = {0x05, 0x0c, 0x09, 0x0e, 0x08, 0x11, 0x01};
+       static const hda_nid_t pins[] = {0x05, 0x0c, 0x09, 0x0e, 0x08, 0x11, 0x01};
        unsigned int i;
 
-       for (i = 0; i < 7; i++)
+       for (i = 0; i < ARRAY_SIZE(pins); i++)
                snd_hda_codec_write(codec, pins[i], 0,
                                AC_VERB_SET_POWER_STATE, 0x03);
 }
index 90aa0f400a57ddc7145a0cb61e5c547ba73dcd75..9853e00a08166412243b1586ebb4fdb5c8b5e65b 100644 (file)
@@ -116,7 +116,7 @@ static void cx_auto_parse_eapd(struct hda_codec *codec)
 }
 
 static void cx_auto_turn_eapd(struct hda_codec *codec, int num_pins,
-                             hda_nid_t *pins, bool on)
+                             const hda_nid_t *pins, bool on)
 {
        int i;
        for (i = 0; i < num_pins; i++) {
@@ -959,10 +959,10 @@ static const struct hda_model_fixup cxt5066_fixup_models[] = {
 static void add_cx5051_fake_mutes(struct hda_codec *codec)
 {
        struct conexant_spec *spec = codec->spec;
-       static hda_nid_t out_nids[] = {
+       static const hda_nid_t out_nids[] = {
                0x10, 0x11, 0
        };
-       hda_nid_t *p;
+       const hda_nid_t *p;
 
        for (p = out_nids; *p; p++)
                snd_hda_override_amp_caps(codec, *p, HDA_OUTPUT,
index dbfafee97931a42952dd33690bc4f80209e39cde..5bb1959dae0fbf6a9a9a943ad5ecc56f2cd8cc1d 100644 (file)
@@ -464,10 +464,10 @@ static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
 static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
 {
        /* We currently only handle front, HP */
-       static hda_nid_t pins[] = {
+       static const hda_nid_t pins[] = {
                0x0f, 0x10, 0x14, 0x15, 0x17, 0
        };
-       hda_nid_t *p;
+       const hda_nid_t *p;
        for (p = pins; *p; p++)
                set_eapd(codec, *p, on);
 }
@@ -1935,19 +1935,19 @@ static void alc889_fixup_dac_route(struct hda_codec *codec,
 {
        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
                /* fake the connections during parsing the tree */
-               hda_nid_t conn1[2] = { 0x0c, 0x0d };
-               hda_nid_t conn2[2] = { 0x0e, 0x0f };
-               snd_hda_override_conn_list(codec, 0x14, 2, conn1);
-               snd_hda_override_conn_list(codec, 0x15, 2, conn1);
-               snd_hda_override_conn_list(codec, 0x18, 2, conn2);
-               snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
+               static const hda_nid_t conn1[] = { 0x0c, 0x0d };
+               static const hda_nid_t conn2[] = { 0x0e, 0x0f };
+               snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
+               snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
+               snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn2), conn2);
+               snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn2), conn2);
        } else if (action == HDA_FIXUP_ACT_PROBE) {
                /* restore the connections */
-               hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
-               snd_hda_override_conn_list(codec, 0x14, 5, conn);
-               snd_hda_override_conn_list(codec, 0x15, 5, conn);
-               snd_hda_override_conn_list(codec, 0x18, 5, conn);
-               snd_hda_override_conn_list(codec, 0x1a, 5, conn);
+               static const hda_nid_t conn[] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
+               snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn), conn);
+               snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn), conn);
+               snd_hda_override_conn_list(codec, 0x18, ARRAY_SIZE(conn), conn);
+               snd_hda_override_conn_list(codec, 0x1a, ARRAY_SIZE(conn), conn);
        }
 }
 
@@ -1955,8 +1955,8 @@ static void alc889_fixup_dac_route(struct hda_codec *codec,
 static void alc889_fixup_mbp_vref(struct hda_codec *codec,
                                  const struct hda_fixup *fix, int action)
 {
+       static const hda_nid_t nids[] = { 0x14, 0x15, 0x19 };
        struct alc_spec *spec = codec->spec;
-       static hda_nid_t nids[3] = { 0x14, 0x15, 0x19 };
        int i;
 
        if (action != HDA_FIXUP_ACT_INIT)
@@ -1992,7 +1992,7 @@ static void alc889_fixup_mac_pins(struct hda_codec *codec,
 static void alc889_fixup_imac91_vref(struct hda_codec *codec,
                                     const struct hda_fixup *fix, int action)
 {
-       static hda_nid_t nids[2] = { 0x18, 0x1a };
+       static const hda_nid_t nids[] = { 0x18, 0x1a };
 
        if (action == HDA_FIXUP_ACT_INIT)
                alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
@@ -2002,7 +2002,7 @@ static void alc889_fixup_imac91_vref(struct hda_codec *codec,
 static void alc889_fixup_mba11_vref(struct hda_codec *codec,
                                    const struct hda_fixup *fix, int action)
 {
-       static hda_nid_t nids[1] = { 0x18 };
+       static const hda_nid_t nids[] = { 0x18 };
 
        if (action == HDA_FIXUP_ACT_INIT)
                alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
@@ -2012,7 +2012,7 @@ static void alc889_fixup_mba11_vref(struct hda_codec *codec,
 static void alc889_fixup_mba21_vref(struct hda_codec *codec,
                                    const struct hda_fixup *fix, int action)
 {
-       static hda_nid_t nids[2] = { 0x18, 0x19 };
+       static const hda_nid_t nids[] = { 0x18, 0x19 };
 
        if (action == HDA_FIXUP_ACT_INIT)
                alc889_fixup_mac_pins(codec, nids, ARRAY_SIZE(nids));
@@ -2094,7 +2094,7 @@ static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
                                     const struct hda_fixup *fix,
                                     int action)
 {
-       hda_nid_t conn1[1] = { 0x0c };
+       static const hda_nid_t conn1[] = { 0x0c };
 
        if (action != HDA_FIXUP_ACT_PRE_PROBE)
                return;
@@ -2103,8 +2103,8 @@ static void alc1220_fixup_clevo_p950(struct hda_codec *codec,
        /* We therefore want to make sure 0x14 (front headphone) and
         * 0x1b (speakers) use the stereo DAC 0x02
         */
-       snd_hda_override_conn_list(codec, 0x14, 1, conn1);
-       snd_hda_override_conn_list(codec, 0x1b, 1, conn1);
+       snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
+       snd_hda_override_conn_list(codec, 0x1b, ARRAY_SIZE(conn1), conn1);
 }
 
 static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
@@ -5243,7 +5243,7 @@ static void alc_fixup_tpt470_dock(struct hda_codec *codec,
         * the speaker output becomes too low by some reason on Thinkpads with
         * ALC298 codec
         */
-       static hda_nid_t preferred_pairs[] = {
+       static const hda_nid_t preferred_pairs[] = {
                0x14, 0x03, 0x17, 0x02, 0x21, 0x02,
                0
        };
@@ -5515,9 +5515,9 @@ static void alc290_fixup_mono_speakers(struct hda_codec *codec,
                /* DAC node 0x03 is giving mono output. We therefore want to
                   make sure 0x14 (front speaker) and 0x15 (headphones) use the
                   stereo DAC, while leaving 0x17 (bass speaker) for node 0x03. */
-               hda_nid_t conn1[2] = { 0x0c };
-               snd_hda_override_conn_list(codec, 0x14, 1, conn1);
-               snd_hda_override_conn_list(codec, 0x15, 1, conn1);
+               static const hda_nid_t conn1[] = { 0x0c };
+               snd_hda_override_conn_list(codec, 0x14, ARRAY_SIZE(conn1), conn1);
+               snd_hda_override_conn_list(codec, 0x15, ARRAY_SIZE(conn1), conn1);
        }
 }
 
@@ -5532,8 +5532,8 @@ static void alc298_fixup_speaker_volume(struct hda_codec *codec,
                   Pin Complex), since Node 0x02 has Amp-out caps, we can adjust
                   speaker's volume now. */
 
-               hda_nid_t conn1[1] = { 0x0c };
-               snd_hda_override_conn_list(codec, 0x17, 1, conn1);
+               static const hda_nid_t conn1[] = { 0x0c };
+               snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn1), conn1);
        }
 }
 
@@ -5542,8 +5542,8 @@ static void alc295_fixup_disable_dac3(struct hda_codec *codec,
                                      const struct hda_fixup *fix, int action)
 {
        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
-               hda_nid_t conn[2] = { 0x02, 0x03 };
-               snd_hda_override_conn_list(codec, 0x17, 2, conn);
+               static const hda_nid_t conn[] = { 0x02, 0x03 };
+               snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
        }
 }
 
@@ -5552,8 +5552,8 @@ static void alc285_fixup_speaker2_to_dac1(struct hda_codec *codec,
                                          const struct hda_fixup *fix, int action)
 {
        if (action == HDA_FIXUP_ACT_PRE_PROBE) {
-               hda_nid_t conn[1] = { 0x02 };
-               snd_hda_override_conn_list(codec, 0x17, 1, conn);
+               static const hda_nid_t conn[] = { 0x02 };
+               snd_hda_override_conn_list(codec, 0x17, ARRAY_SIZE(conn), conn);
        }
 }
 
@@ -5631,7 +5631,7 @@ static void alc274_fixup_bind_dacs(struct hda_codec *codec,
                                    const struct hda_fixup *fix, int action)
 {
        struct alc_spec *spec = codec->spec;
-       static hda_nid_t preferred_pairs[] = {
+       static const hda_nid_t preferred_pairs[] = {
                0x21, 0x03, 0x1b, 0x03, 0x16, 0x02,
                0
        };
index 9b816b377547282c87c6c249fbcf9843bfdd922e..a608d0486ae49be77c4fdd55e99b68ed4ac35494 100644 (file)
@@ -795,7 +795,7 @@ static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
 static bool has_builtin_speaker(struct hda_codec *codec)
 {
        struct sigmatel_spec *spec = codec->spec;
-       hda_nid_t *nid_pin;
+       const hda_nid_t *nid_pin;
        int nids, i;
 
        if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) {
@@ -2182,7 +2182,7 @@ static void hp_envy_ts_fixup_dac_bind(struct hda_codec *codec,
                                            int action)
 {
        struct sigmatel_spec *spec = codec->spec;
-       static hda_nid_t preferred_pairs[] = {
+       static const hda_nid_t preferred_pairs[] = {
                0xd, 0x13,
                0
        };
index 29dcdb8b36db087564ab4128e22e3da198626a7e..b40d01e018329dce25b56822cf311bbe52dbaf74 100644 (file)
@@ -1038,8 +1038,8 @@ static const struct snd_pci_quirk vt2002p_fixups[] = {
  */
 static void fix_vt1802_connections(struct hda_codec *codec)
 {
-       static hda_nid_t conn_24[] = { 0x14, 0x1c };
-       static hda_nid_t conn_33[] = { 0x1c };
+       static const hda_nid_t conn_24[] = { 0x14, 0x1c };
+       static const hda_nid_t conn_33[] = { 0x1c };
 
        snd_hda_override_conn_list(codec, 0x24, ARRAY_SIZE(conn_24), conn_24);
        snd_hda_override_conn_list(codec, 0x33, ARRAY_SIZE(conn_33), conn_33);