diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-07 08:38:44 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:15:47 -0500 |
commit | d031166fecac97fc6b5c35636deace8a3c9ec5f6 (patch) | |
tree | 744500b37b37d0411eae18e69c9261810f18b696 /sound/pci/hda/hda_codec.c | |
parent | 88026842b0a760145aa71d69e74fbc9ec118ca44 (diff) |
[ALSA] hda-codec - Allocate amp hash array dynamically
Modules: HDA Codec driver
Allocate amp hash array dynamically instead of static array.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/hda/hda_codec.c')
-rw-r--r-- | sound/pci/hda/hda_codec.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 0dbeeaf6113a..e7fb182f90ed 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
@@ -465,6 +465,7 @@ static void snd_hda_codec_free(struct hda_codec *codec) | |||
465 | codec->bus->caddr_tbl[codec->addr] = NULL; | 465 | codec->bus->caddr_tbl[codec->addr] = NULL; |
466 | if (codec->patch_ops.free) | 466 | if (codec->patch_ops.free) |
467 | codec->patch_ops.free(codec); | 467 | codec->patch_ops.free(codec); |
468 | kfree(codec->amp_info); | ||
468 | kfree(codec); | 469 | kfree(codec); |
469 | } | 470 | } |
470 | 471 | ||
@@ -586,6 +587,8 @@ static void init_amp_hash(struct hda_codec *codec) | |||
586 | { | 587 | { |
587 | memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash)); | 588 | memset(codec->amp_hash, 0xff, sizeof(codec->amp_hash)); |
588 | codec->num_amp_entries = 0; | 589 | codec->num_amp_entries = 0; |
590 | codec->amp_info_size = 0; | ||
591 | codec->amp_info = NULL; | ||
589 | } | 592 | } |
590 | 593 | ||
591 | /* query the hash. allocate an entry if not found. */ | 594 | /* query the hash. allocate an entry if not found. */ |
@@ -603,9 +606,22 @@ static struct hda_amp_info *get_alloc_amp_hash(struct hda_codec *codec, u32 key) | |||
603 | } | 606 | } |
604 | 607 | ||
605 | /* add a new hash entry */ | 608 | /* add a new hash entry */ |
606 | if (codec->num_amp_entries >= ARRAY_SIZE(codec->amp_info)) { | 609 | if (codec->num_amp_entries >= codec->amp_info_size) { |
607 | snd_printk(KERN_ERR "hda_codec: Tooooo many amps!\n"); | 610 | /* reallocate the array */ |
608 | return NULL; | 611 | int new_size = codec->amp_info_size + 64; |
612 | struct hda_amp_info *new_info = kcalloc(new_size, sizeof(struct hda_amp_info), | ||
613 | GFP_KERNEL); | ||
614 | if (! new_info) { | ||
615 | snd_printk(KERN_ERR "hda_codec: can't malloc amp_info\n"); | ||
616 | return NULL; | ||
617 | } | ||
618 | if (codec->amp_info) { | ||
619 | memcpy(new_info, codec->amp_info, | ||
620 | codec->amp_info_size * sizeof(struct hda_amp_info)); | ||
621 | kfree(codec->amp_info); | ||
622 | } | ||
623 | codec->amp_info_size = new_size; | ||
624 | codec->amp_info = new_info; | ||
609 | } | 625 | } |
610 | cur = codec->num_amp_entries++; | 626 | cur = codec->num_amp_entries++; |
611 | info = &codec->amp_info[cur]; | 627 | info = &codec->amp_info[cur]; |