diff options
author | Takashi Iwai <tiwai@suse.de> | 2008-11-10 16:24:26 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2008-11-10 16:24:26 +0100 |
commit | f43aa025b7de79d6a615ea4c1e6be7e6b1cea538 (patch) | |
tree | a359813d1476c158141a3c7f9bccde850bd73aaa /sound | |
parent | 0edb94543092535a2c6ef33e7285004168ca73d7 (diff) | |
download | op-kernel-dev-f43aa025b7de79d6a615ea4c1e6be7e6b1cea538.zip op-kernel-dev-f43aa025b7de79d6a615ea4c1e6be7e6b1cea538.tar.gz |
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.c | 7 | ||||
-rw-r--r-- | sound/pci/hda/hda_codec.h | 10 |
2 files changed, 13 insertions, 4 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 06e99c7..5d5e801 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, { u16 idx = key % (u16)ARRAY_SIZE(cache->hash); u16 cur = cache->hash[idx]; - struct hda_cache_head *info_head = cache->buf.list; struct hda_cache_head *info; while (cur != 0xffff) { - info = &info_head[cur]; + info = snd_array_elem(&cache->buf, cur); if (info->key == key) return info; cur = info->next; @@ -901,7 +900,7 @@ static struct hda_cache_head *get_alloc_hash(struct hda_cache_rec *cache, info = snd_array_new(&cache->buf); if (!info) return NULL; - cur = cache->buf.used - 1; /* the last entry */ + cur = snd_array_index(&cache->buf, info); info->key = key; info->val = 0; info->next = cache->hash[idx]; @@ -3414,7 +3413,7 @@ void *snd_array_new(struct snd_array *array) array->list = nlist; array->alloced = num; } - return array->list + (array->used++ * array->elem_size); + return snd_array_elem(array, array->used++); } /* free the given array elements */ diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h index a73f0eb..ee122b0 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, array->alloc_align = align; } +static inline void *snd_array_elem(struct snd_array *array, unsigned int idx) +{ + return array->list + idx * array->elem_size; +} + +static inline unsigned int snd_array_index(struct snd_array *array, void *ptr) +{ + return (unsigned long)(ptr - array->list) / array->elem_size; +} + /* * Structures */ |