diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-05-09 08:35:27 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2012-11-28 03:03:39 -0500 |
commit | 361dab3ec2c59044f420cdf232523cd4af4e833e (patch) | |
tree | a15a6119c598e83bdb5ca45676907c6c0a3645cb /sound/pci | |
parent | 04324ccc75f96b3ed7aad1c866d1b7925e977bdf (diff) |
ALSA: hda - Call snd_array_init() early and only once
This is a preliminary patch for introducing a protection to access
races of snd_array instances. Call snd_array_init() appropriately
at the initialization time and don't call it twice.
Also the allocations of codec-spec structs are cleaned up by helper
functions in patch_sigmatel.c and patch_analog.c.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 1 | ||||
-rw-r--r-- | sound/pci/hda/hda_jack.c | 1 | ||||
-rw-r--r-- | sound/pci/hda/patch_analog.c | 72 | ||||
-rw-r--r-- | sound/pci/hda/patch_realtek.c | 4 | ||||
-rw-r--r-- | sound/pci/hda/patch_sigmatel.c | 128 | ||||
-rw-r--r-- | sound/pci/hda/patch_via.c | 2 |
6 files changed, 105 insertions, 103 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index c8f6c3bcb4f3..3634bfebc008 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -1250,6 +1250,7 @@ int /*__devinit*/ snd_hda_codec_new(struct hda_bus *bus, | |||
1250 | snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8); | 1250 | snd_array_init(&codec->cvt_setups, sizeof(struct hda_cvt_setup), 8); |
1251 | snd_array_init(&codec->conn_lists, sizeof(hda_nid_t), 64); | 1251 | snd_array_init(&codec->conn_lists, sizeof(hda_nid_t), 64); |
1252 | snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16); | 1252 | snd_array_init(&codec->spdif_out, sizeof(struct hda_spdif_out), 16); |
1253 | snd_array_init(&codec->jacktbl, sizeof(struct hda_jack_tbl), 16); | ||
1253 | INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work); | 1254 | INIT_DELAYED_WORK(&codec->jackpoll_work, hda_jackpoll_work); |
1254 | 1255 | ||
1255 | #ifdef CONFIG_PM | 1256 | #ifdef CONFIG_PM |
diff --git a/sound/pci/hda/hda_jack.c b/sound/pci/hda/hda_jack.c index 4e1948001338..6e9f57bbe667 100644 --- a/sound/pci/hda/hda_jack.c +++ b/sound/pci/hda/hda_jack.c | |||
@@ -95,7 +95,6 @@ snd_hda_jack_tbl_new(struct hda_codec *codec, hda_nid_t nid) | |||
95 | struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, nid); | 95 | struct hda_jack_tbl *jack = snd_hda_jack_tbl_get(codec, nid); |
96 | if (jack) | 96 | if (jack) |
97 | return jack; | 97 | return jack; |
98 | snd_array_init(&codec->jacktbl, sizeof(*jack), 16); | ||
99 | jack = snd_array_new(&codec->jacktbl); | 98 | jack = snd_array_new(&codec->jacktbl); |
100 | if (!jack) | 99 | if (!jack) |
101 | return NULL; | 100 | return NULL; |
diff --git a/sound/pci/hda/patch_analog.c b/sound/pci/hda/patch_analog.c index eb5689df206a..89fc5030ec79 100644 --- a/sound/pci/hda/patch_analog.c +++ b/sound/pci/hda/patch_analog.c | |||
@@ -1246,16 +1246,27 @@ static int is_jack_available(struct hda_codec *codec, hda_nid_t nid) | |||
1246 | return get_defcfg_connect(conf) != AC_JACK_PORT_NONE; | 1246 | return get_defcfg_connect(conf) != AC_JACK_PORT_NONE; |
1247 | } | 1247 | } |
1248 | 1248 | ||
1249 | static int patch_ad1986a(struct hda_codec *codec) | 1249 | static int alloc_ad_spec(struct hda_codec *codec) |
1250 | { | 1250 | { |
1251 | struct ad198x_spec *spec; | 1251 | struct ad198x_spec *spec; |
1252 | int err, board_config; | ||
1253 | 1252 | ||
1254 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 1253 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); |
1255 | if (spec == NULL) | 1254 | if (!spec) |
1256 | return -ENOMEM; | 1255 | return -ENOMEM; |
1257 | |||
1258 | codec->spec = spec; | 1256 | codec->spec = spec; |
1257 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); | ||
1258 | return 0; | ||
1259 | } | ||
1260 | |||
1261 | static int patch_ad1986a(struct hda_codec *codec) | ||
1262 | { | ||
1263 | struct ad198x_spec *spec; | ||
1264 | int err, board_config; | ||
1265 | |||
1266 | err = alloc_ad_spec(codec); | ||
1267 | if (err < 0) | ||
1268 | return err; | ||
1269 | spec = codec->spec; | ||
1259 | 1270 | ||
1260 | err = snd_hda_attach_beep_device(codec, 0x19); | 1271 | err = snd_hda_attach_beep_device(codec, 0x19); |
1261 | if (err < 0) { | 1272 | if (err < 0) { |
@@ -1548,11 +1559,10 @@ static int patch_ad1983(struct hda_codec *codec) | |||
1548 | struct ad198x_spec *spec; | 1559 | struct ad198x_spec *spec; |
1549 | int err; | 1560 | int err; |
1550 | 1561 | ||
1551 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 1562 | err = alloc_ad_spec(codec); |
1552 | if (spec == NULL) | 1563 | if (err < 0) |
1553 | return -ENOMEM; | 1564 | return err; |
1554 | 1565 | spec = codec->spec; | |
1555 | codec->spec = spec; | ||
1556 | 1566 | ||
1557 | err = snd_hda_attach_beep_device(codec, 0x10); | 1567 | err = snd_hda_attach_beep_device(codec, 0x10); |
1558 | if (err < 0) { | 1568 | if (err < 0) { |
@@ -1954,11 +1964,10 @@ static int patch_ad1981(struct hda_codec *codec) | |||
1954 | struct ad198x_spec *spec; | 1964 | struct ad198x_spec *spec; |
1955 | int err, board_config; | 1965 | int err, board_config; |
1956 | 1966 | ||
1957 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 1967 | err = alloc_ad_spec(codec); |
1958 | if (spec == NULL) | 1968 | if (err < 0) |
1959 | return -ENOMEM; | 1969 | return -ENOMEM; |
1960 | 1970 | spec = codec->spec; | |
1961 | codec->spec = spec; | ||
1962 | 1971 | ||
1963 | err = snd_hda_attach_beep_device(codec, 0x10); | 1972 | err = snd_hda_attach_beep_device(codec, 0x10); |
1964 | if (err < 0) { | 1973 | if (err < 0) { |
@@ -2836,7 +2845,6 @@ static int add_control(struct ad198x_spec *spec, int type, const char *name, | |||
2836 | { | 2845 | { |
2837 | struct snd_kcontrol_new *knew; | 2846 | struct snd_kcontrol_new *knew; |
2838 | 2847 | ||
2839 | snd_array_init(&spec->kctls, sizeof(*knew), 32); | ||
2840 | knew = snd_array_new(&spec->kctls); | 2848 | knew = snd_array_new(&spec->kctls); |
2841 | if (!knew) | 2849 | if (!knew) |
2842 | return -ENOMEM; | 2850 | return -ENOMEM; |
@@ -3254,11 +3262,10 @@ static int patch_ad1988(struct hda_codec *codec) | |||
3254 | struct ad198x_spec *spec; | 3262 | struct ad198x_spec *spec; |
3255 | int err, board_config; | 3263 | int err, board_config; |
3256 | 3264 | ||
3257 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 3265 | err = alloc_ad_spec(codec); |
3258 | if (spec == NULL) | 3266 | if (err < 0) |
3259 | return -ENOMEM; | 3267 | return err; |
3260 | 3268 | spec = codec->spec; | |
3261 | codec->spec = spec; | ||
3262 | 3269 | ||
3263 | if (is_rev2(codec)) | 3270 | if (is_rev2(codec)) |
3264 | snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n"); | 3271 | snd_printk(KERN_INFO "patch_analog: AD1988A rev.2 is detected, enable workarounds\n"); |
@@ -3574,11 +3581,10 @@ static int patch_ad1884(struct hda_codec *codec) | |||
3574 | struct ad198x_spec *spec; | 3581 | struct ad198x_spec *spec; |
3575 | int err; | 3582 | int err; |
3576 | 3583 | ||
3577 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 3584 | err = alloc_ad_spec(codec); |
3578 | if (spec == NULL) | 3585 | if (err < 0) |
3579 | return -ENOMEM; | 3586 | return err; |
3580 | 3587 | spec = codec->spec; | |
3581 | codec->spec = spec; | ||
3582 | 3588 | ||
3583 | err = snd_hda_attach_beep_device(codec, 0x10); | 3589 | err = snd_hda_attach_beep_device(codec, 0x10); |
3584 | if (err < 0) { | 3590 | if (err < 0) { |
@@ -4574,11 +4580,10 @@ static int patch_ad1884a(struct hda_codec *codec) | |||
4574 | struct ad198x_spec *spec; | 4580 | struct ad198x_spec *spec; |
4575 | int err, board_config; | 4581 | int err, board_config; |
4576 | 4582 | ||
4577 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 4583 | err = alloc_ad_spec(codec); |
4578 | if (spec == NULL) | 4584 | if (err < 0) |
4579 | return -ENOMEM; | 4585 | return err; |
4580 | 4586 | spec = codec->spec; | |
4581 | codec->spec = spec; | ||
4582 | 4587 | ||
4583 | err = snd_hda_attach_beep_device(codec, 0x10); | 4588 | err = snd_hda_attach_beep_device(codec, 0x10); |
4584 | if (err < 0) { | 4589 | if (err < 0) { |
@@ -4987,11 +4992,10 @@ static int patch_ad1882(struct hda_codec *codec) | |||
4987 | struct ad198x_spec *spec; | 4992 | struct ad198x_spec *spec; |
4988 | int err, board_config; | 4993 | int err, board_config; |
4989 | 4994 | ||
4990 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 4995 | err = alloc_ad_spec(codec); |
4991 | if (spec == NULL) | 4996 | if (err < 0) |
4992 | return -ENOMEM; | 4997 | return err; |
4993 | 4998 | spec = codec->spec; | |
4994 | codec->spec = spec; | ||
4995 | 4999 | ||
4996 | err = snd_hda_attach_beep_device(codec, 0x10); | 5000 | err = snd_hda_attach_beep_device(codec, 0x10); |
4997 | if (err < 0) { | 5001 | if (err < 0) { |
diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index af0686533803..c7369a6764ef 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c | |||
@@ -905,7 +905,6 @@ static const struct snd_kcontrol_new alc_automute_mode_enum = { | |||
905 | 905 | ||
906 | static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec) | 906 | static struct snd_kcontrol_new *alc_kcontrol_new(struct alc_spec *spec) |
907 | { | 907 | { |
908 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); | ||
909 | return snd_array_new(&spec->kctls); | 908 | return snd_array_new(&spec->kctls); |
910 | } | 909 | } |
911 | 910 | ||
@@ -3605,7 +3604,6 @@ static struct hda_bind_ctls *new_bind_ctl(struct hda_codec *codec, | |||
3605 | { | 3604 | { |
3606 | struct alc_spec *spec = codec->spec; | 3605 | struct alc_spec *spec = codec->spec; |
3607 | struct hda_bind_ctls **ctlp, *ctl; | 3606 | struct hda_bind_ctls **ctlp, *ctl; |
3608 | snd_array_init(&spec->bind_ctls, sizeof(ctl), 8); | ||
3609 | ctlp = snd_array_new(&spec->bind_ctls); | 3607 | ctlp = snd_array_new(&spec->bind_ctls); |
3610 | if (!ctlp) | 3608 | if (!ctlp) |
3611 | return NULL; | 3609 | return NULL; |
@@ -4376,6 +4374,8 @@ static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid) | |||
4376 | codec->spec = spec; | 4374 | codec->spec = spec; |
4377 | spec->mixer_nid = mixer_nid; | 4375 | spec->mixer_nid = mixer_nid; |
4378 | snd_hda_gen_init(&spec->gen); | 4376 | snd_hda_gen_init(&spec->gen); |
4377 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); | ||
4378 | snd_array_init(&spec->bind_ctls, sizeof(struct hda_bind_ctls *), 8); | ||
4379 | 4379 | ||
4380 | err = alc_codec_rename_from_preset(codec); | 4380 | err = alc_codec_rename_from_preset(codec); |
4381 | if (err < 0) { | 4381 | if (err < 0) { |
diff --git a/sound/pci/hda/patch_sigmatel.c b/sound/pci/hda/patch_sigmatel.c index 1f6fd584e1c2..df13c0f84899 100644 --- a/sound/pci/hda/patch_sigmatel.c +++ b/sound/pci/hda/patch_sigmatel.c | |||
@@ -2811,7 +2811,6 @@ stac_control_new(struct sigmatel_spec *spec, | |||
2811 | { | 2811 | { |
2812 | struct snd_kcontrol_new *knew; | 2812 | struct snd_kcontrol_new *knew; |
2813 | 2813 | ||
2814 | snd_array_init(&spec->kctls, sizeof(*knew), 32); | ||
2815 | knew = snd_array_new(&spec->kctls); | 2814 | knew = snd_array_new(&spec->kctls); |
2816 | if (!knew) | 2815 | if (!knew) |
2817 | return NULL; | 2816 | return NULL; |
@@ -5159,20 +5158,34 @@ static const struct hda_codec_ops stac92xx_patch_ops = { | |||
5159 | .reboot_notify = stac92xx_shutup, | 5158 | .reboot_notify = stac92xx_shutup, |
5160 | }; | 5159 | }; |
5161 | 5160 | ||
5161 | static int alloc_stac_spec(struct hda_codec *codec, int num_pins, | ||
5162 | const hda_nid_t *pin_nids) | ||
5163 | { | ||
5164 | struct sigmatel_spec *spec; | ||
5165 | |||
5166 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | ||
5167 | if (!spec) | ||
5168 | return -ENOMEM; | ||
5169 | codec->spec = spec; | ||
5170 | codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */ | ||
5171 | spec->num_pins = num_pins; | ||
5172 | spec->pin_nids = pin_nids; | ||
5173 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); | ||
5174 | return 0; | ||
5175 | } | ||
5176 | |||
5162 | static int patch_stac9200(struct hda_codec *codec) | 5177 | static int patch_stac9200(struct hda_codec *codec) |
5163 | { | 5178 | { |
5164 | struct sigmatel_spec *spec; | 5179 | struct sigmatel_spec *spec; |
5165 | int err; | 5180 | int err; |
5166 | 5181 | ||
5167 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5182 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac9200_pin_nids), |
5168 | if (spec == NULL) | 5183 | stac9200_pin_nids); |
5169 | return -ENOMEM; | 5184 | if (err < 0) |
5185 | return err; | ||
5170 | 5186 | ||
5171 | codec->no_trigger_sense = 1; | 5187 | spec = codec->spec; |
5172 | codec->spec = spec; | ||
5173 | spec->linear_tone_beep = 1; | 5188 | spec->linear_tone_beep = 1; |
5174 | spec->num_pins = ARRAY_SIZE(stac9200_pin_nids); | ||
5175 | spec->pin_nids = stac9200_pin_nids; | ||
5176 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, | 5189 | spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS, |
5177 | stac9200_models, | 5190 | stac9200_models, |
5178 | stac9200_cfg_tbl); | 5191 | stac9200_cfg_tbl); |
@@ -5228,15 +5241,13 @@ static int patch_stac925x(struct hda_codec *codec) | |||
5228 | struct sigmatel_spec *spec; | 5241 | struct sigmatel_spec *spec; |
5229 | int err; | 5242 | int err; |
5230 | 5243 | ||
5231 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5244 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac925x_pin_nids), |
5232 | if (spec == NULL) | 5245 | stac925x_pin_nids); |
5233 | return -ENOMEM; | 5246 | if (err < 0) |
5247 | return err; | ||
5234 | 5248 | ||
5235 | codec->no_trigger_sense = 1; | 5249 | spec = codec->spec; |
5236 | codec->spec = spec; | ||
5237 | spec->linear_tone_beep = 1; | 5250 | spec->linear_tone_beep = 1; |
5238 | spec->num_pins = ARRAY_SIZE(stac925x_pin_nids); | ||
5239 | spec->pin_nids = stac925x_pin_nids; | ||
5240 | 5251 | ||
5241 | /* Check first for codec ID */ | 5252 | /* Check first for codec ID */ |
5242 | spec->board_config = snd_hda_check_board_codec_sid_config(codec, | 5253 | spec->board_config = snd_hda_check_board_codec_sid_config(codec, |
@@ -5311,19 +5322,17 @@ static int patch_stac92hd73xx(struct hda_codec *codec) | |||
5311 | { | 5322 | { |
5312 | struct sigmatel_spec *spec; | 5323 | struct sigmatel_spec *spec; |
5313 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; | 5324 | hda_nid_t conn[STAC92HD73_DAC_COUNT + 2]; |
5314 | int err = 0; | 5325 | int err; |
5315 | int num_dacs; | 5326 | int num_dacs; |
5316 | 5327 | ||
5317 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5328 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac92hd73xx_pin_nids), |
5318 | if (spec == NULL) | 5329 | stac92hd73xx_pin_nids); |
5319 | return -ENOMEM; | 5330 | if (err < 0) |
5331 | return err; | ||
5320 | 5332 | ||
5321 | codec->no_trigger_sense = 1; | 5333 | spec = codec->spec; |
5322 | codec->spec = spec; | ||
5323 | spec->linear_tone_beep = 0; | 5334 | spec->linear_tone_beep = 0; |
5324 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; | 5335 | codec->slave_dig_outs = stac92hd73xx_slave_dig_outs; |
5325 | spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids); | ||
5326 | spec->pin_nids = stac92hd73xx_pin_nids; | ||
5327 | spec->board_config = snd_hda_check_board_config(codec, | 5336 | spec->board_config = snd_hda_check_board_config(codec, |
5328 | STAC_92HD73XX_MODELS, | 5337 | STAC_92HD73XX_MODELS, |
5329 | stac92hd73xx_models, | 5338 | stac92hd73xx_models, |
@@ -5600,9 +5609,9 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) | |||
5600 | int default_polarity = -1; /* no default cfg */ | 5609 | int default_polarity = -1; /* no default cfg */ |
5601 | int err; | 5610 | int err; |
5602 | 5611 | ||
5603 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5612 | err = alloc_stac_spec(codec, 0, NULL); /* pins filled later */ |
5604 | if (spec == NULL) | 5613 | if (err < 0) |
5605 | return -ENOMEM; | 5614 | return err; |
5606 | 5615 | ||
5607 | if (hp_bnb2011_with_dock(codec)) { | 5616 | if (hp_bnb2011_with_dock(codec)) { |
5608 | snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f); | 5617 | snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f); |
@@ -5610,11 +5619,9 @@ static int patch_stac92hd83xxx(struct hda_codec *codec) | |||
5610 | } | 5619 | } |
5611 | 5620 | ||
5612 | codec->epss = 0; /* longer delay needed for D3 */ | 5621 | codec->epss = 0; /* longer delay needed for D3 */ |
5613 | codec->no_trigger_sense = 1; | ||
5614 | codec->spec = spec; | ||
5615 | |||
5616 | stac92hd8x_fill_auto_spec(codec); | 5622 | stac92hd8x_fill_auto_spec(codec); |
5617 | 5623 | ||
5624 | spec = codec->spec; | ||
5618 | spec->linear_tone_beep = 0; | 5625 | spec->linear_tone_beep = 0; |
5619 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; | 5626 | codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs; |
5620 | spec->digbeep_nid = 0x21; | 5627 | spec->digbeep_nid = 0x21; |
@@ -5783,21 +5790,19 @@ static int patch_stac92hd71bxx(struct hda_codec *codec) | |||
5783 | struct sigmatel_spec *spec; | 5790 | struct sigmatel_spec *spec; |
5784 | const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; | 5791 | const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init; |
5785 | unsigned int pin_cfg; | 5792 | unsigned int pin_cfg; |
5786 | int err = 0; | 5793 | int err; |
5787 | 5794 | ||
5788 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 5795 | err = alloc_stac_spec(codec, STAC92HD71BXX_NUM_PINS, |
5789 | if (spec == NULL) | 5796 | stac92hd71bxx_pin_nids_4port); |
5790 | return -ENOMEM; | 5797 | if (err < 0) |
5798 | return err; | ||
5791 | 5799 | ||
5792 | codec->no_trigger_sense = 1; | 5800 | spec = codec->spec; |
5793 | codec->spec = spec; | ||
5794 | spec->linear_tone_beep = 0; | 5801 | spec->linear_tone_beep = 0; |
5795 | codec->patch_ops = stac92xx_patch_ops; | 5802 | codec->patch_ops = stac92xx_patch_ops; |
5796 | spec->num_pins = STAC92HD71BXX_NUM_PINS; | ||
5797 | switch (codec->vendor_id) { | 5803 | switch (codec->vendor_id) { |
5798 | case 0x111d76b6: | 5804 | case 0x111d76b6: |
5799 | case 0x111d76b7: | 5805 | case 0x111d76b7: |
5800 | spec->pin_nids = stac92hd71bxx_pin_nids_4port; | ||
5801 | break; | 5806 | break; |
5802 | case 0x111d7603: | 5807 | case 0x111d7603: |
5803 | case 0x111d7608: | 5808 | case 0x111d7608: |
@@ -6028,15 +6033,13 @@ static int patch_stac922x(struct hda_codec *codec) | |||
6028 | struct sigmatel_spec *spec; | 6033 | struct sigmatel_spec *spec; |
6029 | int err; | 6034 | int err; |
6030 | 6035 | ||
6031 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 6036 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac922x_pin_nids), |
6032 | if (spec == NULL) | 6037 | stac922x_pin_nids); |
6033 | return -ENOMEM; | 6038 | if (err < 0) |
6039 | return err; | ||
6034 | 6040 | ||
6035 | codec->no_trigger_sense = 1; | 6041 | spec = codec->spec; |
6036 | codec->spec = spec; | ||
6037 | spec->linear_tone_beep = 1; | 6042 | spec->linear_tone_beep = 1; |
6038 | spec->num_pins = ARRAY_SIZE(stac922x_pin_nids); | ||
6039 | spec->pin_nids = stac922x_pin_nids; | ||
6040 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, | 6043 | spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS, |
6041 | stac922x_models, | 6044 | stac922x_models, |
6042 | stac922x_cfg_tbl); | 6045 | stac922x_cfg_tbl); |
@@ -6133,16 +6136,14 @@ static int patch_stac927x(struct hda_codec *codec) | |||
6133 | struct sigmatel_spec *spec; | 6136 | struct sigmatel_spec *spec; |
6134 | int err; | 6137 | int err; |
6135 | 6138 | ||
6136 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 6139 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac927x_pin_nids), |
6137 | if (spec == NULL) | 6140 | stac927x_pin_nids); |
6138 | return -ENOMEM; | 6141 | if (err < 0) |
6142 | return err; | ||
6139 | 6143 | ||
6140 | codec->no_trigger_sense = 1; | 6144 | spec = codec->spec; |
6141 | codec->spec = spec; | ||
6142 | spec->linear_tone_beep = 1; | 6145 | spec->linear_tone_beep = 1; |
6143 | codec->slave_dig_outs = stac927x_slave_dig_outs; | 6146 | codec->slave_dig_outs = stac927x_slave_dig_outs; |
6144 | spec->num_pins = ARRAY_SIZE(stac927x_pin_nids); | ||
6145 | spec->pin_nids = stac927x_pin_nids; | ||
6146 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, | 6147 | spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS, |
6147 | stac927x_models, | 6148 | stac927x_models, |
6148 | stac927x_cfg_tbl); | 6149 | stac927x_cfg_tbl); |
@@ -6269,15 +6270,13 @@ static int patch_stac9205(struct hda_codec *codec) | |||
6269 | struct sigmatel_spec *spec; | 6270 | struct sigmatel_spec *spec; |
6270 | int err; | 6271 | int err; |
6271 | 6272 | ||
6272 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 6273 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac9205_pin_nids), |
6273 | if (spec == NULL) | 6274 | stac9205_pin_nids); |
6274 | return -ENOMEM; | 6275 | if (err < 0) |
6276 | return err; | ||
6275 | 6277 | ||
6276 | codec->no_trigger_sense = 1; | 6278 | spec = codec->spec; |
6277 | codec->spec = spec; | ||
6278 | spec->linear_tone_beep = 1; | 6279 | spec->linear_tone_beep = 1; |
6279 | spec->num_pins = ARRAY_SIZE(stac9205_pin_nids); | ||
6280 | spec->pin_nids = stac9205_pin_nids; | ||
6281 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, | 6280 | spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS, |
6282 | stac9205_models, | 6281 | stac9205_models, |
6283 | stac9205_cfg_tbl); | 6282 | stac9205_cfg_tbl); |
@@ -6425,14 +6424,13 @@ static int patch_stac9872(struct hda_codec *codec) | |||
6425 | struct sigmatel_spec *spec; | 6424 | struct sigmatel_spec *spec; |
6426 | int err; | 6425 | int err; |
6427 | 6426 | ||
6428 | spec = kzalloc(sizeof(*spec), GFP_KERNEL); | 6427 | err = alloc_stac_spec(codec, ARRAY_SIZE(stac9872_pin_nids), |
6429 | if (spec == NULL) | 6428 | stac9872_pin_nids); |
6430 | return -ENOMEM; | 6429 | if (err < 0) |
6431 | codec->no_trigger_sense = 1; | 6430 | return err; |
6432 | codec->spec = spec; | 6431 | |
6432 | spec = codec->spec; | ||
6433 | spec->linear_tone_beep = 1; | 6433 | spec->linear_tone_beep = 1; |
6434 | spec->num_pins = ARRAY_SIZE(stac9872_pin_nids); | ||
6435 | spec->pin_nids = stac9872_pin_nids; | ||
6436 | 6434 | ||
6437 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, | 6435 | spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS, |
6438 | stac9872_models, | 6436 | stac9872_models, |
diff --git a/sound/pci/hda/patch_via.c b/sound/pci/hda/patch_via.c index 7ae5f85105e9..274644f6bd48 100644 --- a/sound/pci/hda/patch_via.c +++ b/sound/pci/hda/patch_via.c | |||
@@ -241,6 +241,7 @@ static struct via_spec * via_new_spec(struct hda_codec *codec) | |||
241 | if (spec == NULL) | 241 | if (spec == NULL) |
242 | return NULL; | 242 | return NULL; |
243 | 243 | ||
244 | snd_array_init(&spec->kctls, sizeof(struct snd_kcontrol_new), 32); | ||
244 | mutex_init(&spec->config_mutex); | 245 | mutex_init(&spec->config_mutex); |
245 | codec->spec = spec; | 246 | codec->spec = spec; |
246 | spec->codec = codec; | 247 | spec->codec = codec; |
@@ -387,7 +388,6 @@ static struct snd_kcontrol_new *__via_clone_ctl(struct via_spec *spec, | |||
387 | { | 388 | { |
388 | struct snd_kcontrol_new *knew; | 389 | struct snd_kcontrol_new *knew; |
389 | 390 | ||
390 | snd_array_init(&spec->kctls, sizeof(*knew), 32); | ||
391 | knew = snd_array_new(&spec->kctls); | 391 | knew = snd_array_new(&spec->kctls); |
392 | if (!knew) | 392 | if (!knew) |
393 | return NULL; | 393 | return NULL; |