aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2008-11-10 10:24:26 -0500
committerTakashi Iwai <tiwai@suse.de>2008-11-10 10:24:26 -0500
commitf43aa025b7de79d6a615ea4c1e6be7e6b1cea538 (patch)
treea359813d1476c158141a3c7f9bccde850bd73aaa /sound
parent0edb94543092535a2c6ef33e7285004168ca73d7 (diff)
ALSA: hda - Fix another cache list management
Fix another silly bug in the amp cache list management. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/pci/hda/hda_codec.c7
-rw-r--r--sound/pci/hda/hda_codec.h10
2 files changed, 13 insertions, 4 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 06e99c785155..5d5e8012d6a5 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -887,11 +887,10 @@ static struct hda_cache_head *get_alloc_hash(struct hda_cache_rec *cache,
887{ 887{
888 u16 idx = key % (u16)ARRAY_SIZE(cache->hash); 888 u16 idx = key % (u16)ARRAY_SIZE(cache->hash);
889 u16 cur = cache->hash[idx]; 889 u16 cur = cache->hash[idx];
890 struct hda_cache_head *info_head = cache->buf.list;
891 struct hda_cache_head *info; 890 struct hda_cache_head *info;
892 891
893 while (cur != 0xffff) { 892 while (cur != 0xffff) {
894 info = &info_head[cur]; 893 info = snd_array_elem(&cache->buf, cur);
895 if (info->key == key) 894 if (info->key == key)
896 return info; 895 return info;
897 cur = info->next; 896 cur = info->next;
@@ -901,7 +900,7 @@ static struct hda_cache_head *get_alloc_hash(struct hda_cache_rec *cache,
901 info = snd_array_new(&cache->buf); 900 info = snd_array_new(&cache->buf);
902 if (!info) 901 if (!info)
903 return NULL; 902 return NULL;
904 cur = cache->buf.used - 1; /* the last entry */ 903 cur = snd_array_index(&cache->buf, info);
905 info->key = key; 904 info->key = key;
906 info->val = 0; 905 info->val = 0;
907 info->next = cache->hash[idx]; 906 info->next = cache->hash[idx];
@@ -3414,7 +3413,7 @@ void *snd_array_new(struct snd_array *array)
3414 array->list = nlist; 3413 array->list = nlist;
3415 array->alloced = num; 3414 array->alloced = num;
3416 } 3415 }
3417 return array->list + (array->used++ * array->elem_size); 3416 return snd_array_elem(array, array->used++);
3418} 3417}
3419 3418
3420/* free the given array elements */ 3419/* free the given array elements */
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index a73f0eb99283..ee122b009fd4 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -539,6 +539,16 @@ static inline void snd_array_init(struct snd_array *array, unsigned int size,
539 array->alloc_align = align; 539 array->alloc_align = align;
540} 540}
541 541
542static inline void *snd_array_elem(struct snd_array *array, unsigned int idx)
543{
544 return array->list + idx * array->elem_size;
545}
546
547static inline unsigned int snd_array_index(struct snd_array *array, void *ptr)
548{
549 return (unsigned long)(ptr - array->list) / array->elem_size;
550}
551
542/* 552/*
543 * Structures 553 * Structures
544 */ 554 */