提交 7ab39926 编写于 作者: C Clemens Ladisch 提交者: Jaroslav Kysela

[ALSA] use the ALIGN macro

Use the ALIGN macro instead of manual calculations.
Signed-off-by: NClemens Ladisch <clemens@ladisch.de>
Signed-off-by: NJaroslav Kysela <perex@suse.cz>
上级 e7d24f0b
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
/* table entries are align to 32 */ /* table entries are align to 32 */
#define SGBUF_TBL_ALIGN 32 #define SGBUF_TBL_ALIGN 32
#define sgbuf_align_table(tbl) ((((tbl) + SGBUF_TBL_ALIGN - 1) / SGBUF_TBL_ALIGN) * SGBUF_TBL_ALIGN) #define sgbuf_align_table(tbl) ALIGN((tbl), SGBUF_TBL_ALIGN)
int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab) int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
{ {
......
...@@ -143,9 +143,8 @@ static int snd_gf1_mem_find(struct snd_gf1_mem * alloc, ...@@ -143,9 +143,8 @@ static int snd_gf1_mem_find(struct snd_gf1_mem * alloc,
struct snd_gf1_mem_block *pblock; struct snd_gf1_mem_block *pblock;
unsigned int ptr1, ptr2; unsigned int ptr1, ptr2;
align--; if (w_16 && align < 2)
if (w_16 && align < 1) align = 2;
align = 1;
block->flags = w_16 ? SNDRV_GF1_MEM_BLOCK_16BIT : 0; block->flags = w_16 ? SNDRV_GF1_MEM_BLOCK_16BIT : 0;
block->owner = SNDRV_GF1_MEM_OWNER_DRIVER; block->owner = SNDRV_GF1_MEM_OWNER_DRIVER;
block->share = 0; block->share = 0;
...@@ -165,7 +164,7 @@ static int snd_gf1_mem_find(struct snd_gf1_mem * alloc, ...@@ -165,7 +164,7 @@ static int snd_gf1_mem_find(struct snd_gf1_mem * alloc,
if (pblock->next->ptr < boundary) if (pblock->next->ptr < boundary)
ptr2 = pblock->next->ptr; ptr2 = pblock->next->ptr;
} }
ptr1 = (pblock->ptr + pblock->size + align) & ~align; ptr1 = ALIGN(pblock->ptr + pblock->size, align);
if (ptr1 >= ptr2) if (ptr1 >= ptr2)
continue; continue;
size1 = ptr2 - ptr1; size1 = ptr2 - ptr1;
......
...@@ -1068,7 +1068,7 @@ wavefront_send_sample (snd_wavefront_t *dev, ...@@ -1068,7 +1068,7 @@ wavefront_send_sample (snd_wavefront_t *dev,
blocksize = max_blksize; blocksize = max_blksize;
} else { } else {
/* round to nearest 16-byte value */ /* round to nearest 16-byte value */
blocksize = ((length-written+7)&~0x7); blocksize = ALIGN(length - written, 8);
} }
if (snd_wavefront_cmd (dev, WFC_DOWNLOAD_BLOCK, NULL, NULL)) { if (snd_wavefront_cmd (dev, WFC_DOWNLOAD_BLOCK, NULL, NULL)) {
......
...@@ -699,7 +699,7 @@ static int __devinit snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *nam ...@@ -699,7 +699,7 @@ static int __devinit snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *nam
SNDRV_DMA_TYPE_DEV_SG, SNDRV_DMA_TYPE_DEV_SG,
snd_dma_pci_data(chip->pci), snd_dma_pci_data(chip->pci),
128 * 1024, 128 * 1024,
(255 * 4092 + 1023) & ~1023); ALIGN(255 * 4092, 1024));
} }
static int __devinit snd_bt87x_create(struct snd_card *card, static int __devinit snd_bt87x_create(struct snd_card *card,
......
...@@ -1337,7 +1337,7 @@ static struct esm_memory *snd_es1968_new_memory(struct es1968 *chip, int size) ...@@ -1337,7 +1337,7 @@ static struct esm_memory *snd_es1968_new_memory(struct es1968 *chip, int size)
struct esm_memory *buf; struct esm_memory *buf;
struct list_head *p; struct list_head *p;
size = ((size + ESM_MEM_ALIGN - 1) / ESM_MEM_ALIGN) * ESM_MEM_ALIGN; size = ALIGN(size, ESM_MEM_ALIGN);
mutex_lock(&chip->memory_mutex); mutex_lock(&chip->memory_mutex);
list_for_each(p, &chip->buf_list) { list_for_each(p, &chip->buf_list) {
buf = list_entry(p, struct esm_memory, list); buf = list_entry(p, struct esm_memory, list);
......
...@@ -2377,7 +2377,7 @@ static int __devinit snd_m3_assp_client_init(struct snd_m3 *chip, struct m3_dma ...@@ -2377,7 +2377,7 @@ static int __devinit snd_m3_assp_client_init(struct snd_m3 *chip, struct m3_dma
* shifted list address is aligned. * shifted list address is aligned.
* list address = (mem address >> 1) >> 7; * list address = (mem address >> 1) >> 7;
*/ */
data_bytes = (data_bytes + 255) & ~255; data_bytes = ALIGN(data_bytes, 256);
address = 0x1100 + ((data_bytes/2) * index); address = 0x1100 + ((data_bytes/2) * index);
if ((address + (data_bytes/2)) >= 0x1c00) { if ((address + (data_bytes/2)) >= 0x1c00) {
......
...@@ -3516,8 +3516,8 @@ static int __devinit snd_hdsp_initialize_memory(struct hdsp *hdsp) ...@@ -3516,8 +3516,8 @@ static int __devinit snd_hdsp_initialize_memory(struct hdsp *hdsp)
/* Align to bus-space 64K boundary */ /* Align to bus-space 64K boundary */
cb_bus = (hdsp->capture_dma_buf.addr + 0xFFFF) & ~0xFFFFl; cb_bus = ALIGN(hdsp->capture_dma_buf.addr, 0x10000ul);
pb_bus = (hdsp->playback_dma_buf.addr + 0xFFFF) & ~0xFFFFl; pb_bus = ALIGN(hdsp->playback_dma_buf.addr, 0x10000ul);
/* Tell the card where it is */ /* Tell the card where it is */
......
...@@ -1827,8 +1827,8 @@ static int __devinit snd_rme9652_initialize_memory(struct snd_rme9652 *rme9652) ...@@ -1827,8 +1827,8 @@ static int __devinit snd_rme9652_initialize_memory(struct snd_rme9652 *rme9652)
/* Align to bus-space 64K boundary */ /* Align to bus-space 64K boundary */
cb_bus = (rme9652->capture_dma_buf.addr + 0xFFFF) & ~0xFFFFl; cb_bus = ALIGN(rme9652->capture_dma_buf.addr, 0x10000ul);
pb_bus = (rme9652->playback_dma_buf.addr + 0xFFFF) & ~0xFFFFl; pb_bus = ALIGN(rme9652->playback_dma_buf.addr, 0x10000ul);
/* Tell the card where it is */ /* Tell the card where it is */
......
...@@ -3380,8 +3380,8 @@ static int __devinit snd_trident_tlb_alloc(struct snd_trident *trident) ...@@ -3380,8 +3380,8 @@ static int __devinit snd_trident_tlb_alloc(struct snd_trident *trident)
snd_printk(KERN_ERR "trident: unable to allocate TLB buffer\n"); snd_printk(KERN_ERR "trident: unable to allocate TLB buffer\n");
return -ENOMEM; return -ENOMEM;
} }
trident->tlb.entries = (unsigned int*)(((unsigned long)trident->tlb.buffer.area + SNDRV_TRIDENT_MAX_PAGES * 4 - 1) & ~(SNDRV_TRIDENT_MAX_PAGES * 4 - 1)); trident->tlb.entries = (unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4);
trident->tlb.entries_dmaaddr = (trident->tlb.buffer.addr + SNDRV_TRIDENT_MAX_PAGES * 4 - 1) & ~(SNDRV_TRIDENT_MAX_PAGES * 4 - 1); trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4);
/* allocate shadow TLB page table (virtual addresses) */ /* allocate shadow TLB page table (virtual addresses) */
trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long)); trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long));
if (trident->tlb.shadow_entries == NULL) { if (trident->tlb.shadow_entries == NULL) {
......
...@@ -2025,10 +2025,10 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip) ...@@ -2025,10 +2025,10 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip)
chip->bank_size_effect = snd_ymfpci_readl(chip, YDSXGR_EFFCTRLSIZE) << 2; chip->bank_size_effect = snd_ymfpci_readl(chip, YDSXGR_EFFCTRLSIZE) << 2;
chip->work_size = YDSXG_DEFAULT_WORK_SIZE; chip->work_size = YDSXG_DEFAULT_WORK_SIZE;
size = ((playback_ctrl_size + 0x00ff) & ~0x00ff) + size = ALIGN(playback_ctrl_size, 0x100) +
((chip->bank_size_playback * 2 * YDSXG_PLAYBACK_VOICES + 0x00ff) & ~0x00ff) + ALIGN(chip->bank_size_playback * 2 * YDSXG_PLAYBACK_VOICES, 0x100) +
((chip->bank_size_capture * 2 * YDSXG_CAPTURE_VOICES + 0x00ff) & ~0x00ff) + ALIGN(chip->bank_size_capture * 2 * YDSXG_CAPTURE_VOICES, 0x100) +
((chip->bank_size_effect * 2 * YDSXG_EFFECT_VOICES + 0x00ff) & ~0x00ff) + ALIGN(chip->bank_size_effect * 2 * YDSXG_EFFECT_VOICES, 0x100) +
chip->work_size; chip->work_size;
/* work_ptr must be aligned to 256 bytes, but it's already /* work_ptr must be aligned to 256 bytes, but it's already
covered with the kernel page allocation mechanism */ covered with the kernel page allocation mechanism */
...@@ -2043,8 +2043,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip) ...@@ -2043,8 +2043,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip)
chip->bank_base_playback_addr = ptr_addr; chip->bank_base_playback_addr = ptr_addr;
chip->ctrl_playback = (u32 *)ptr; chip->ctrl_playback = (u32 *)ptr;
chip->ctrl_playback[0] = cpu_to_le32(YDSXG_PLAYBACK_VOICES); chip->ctrl_playback[0] = cpu_to_le32(YDSXG_PLAYBACK_VOICES);
ptr += (playback_ctrl_size + 0x00ff) & ~0x00ff; ptr += ALIGN(playback_ctrl_size, 0x100);
ptr_addr += (playback_ctrl_size + 0x00ff) & ~0x00ff; ptr_addr += ALIGN(playback_ctrl_size, 0x100);
for (voice = 0; voice < YDSXG_PLAYBACK_VOICES; voice++) { for (voice = 0; voice < YDSXG_PLAYBACK_VOICES; voice++) {
chip->voices[voice].number = voice; chip->voices[voice].number = voice;
chip->voices[voice].bank = (struct snd_ymfpci_playback_bank *)ptr; chip->voices[voice].bank = (struct snd_ymfpci_playback_bank *)ptr;
...@@ -2055,8 +2055,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip) ...@@ -2055,8 +2055,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip)
ptr_addr += chip->bank_size_playback; ptr_addr += chip->bank_size_playback;
} }
} }
ptr = (char *)(((unsigned long)ptr + 0x00ff) & ~0x00ff); ptr = (char *)ALIGN((unsigned long)ptr, 0x100);
ptr_addr = (ptr_addr + 0x00ff) & ~0x00ff; ptr_addr = ALIGN(ptr_addr, 0x100);
chip->bank_base_capture = ptr; chip->bank_base_capture = ptr;
chip->bank_base_capture_addr = ptr_addr; chip->bank_base_capture_addr = ptr_addr;
for (voice = 0; voice < YDSXG_CAPTURE_VOICES; voice++) for (voice = 0; voice < YDSXG_CAPTURE_VOICES; voice++)
...@@ -2065,8 +2065,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip) ...@@ -2065,8 +2065,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip)
ptr += chip->bank_size_capture; ptr += chip->bank_size_capture;
ptr_addr += chip->bank_size_capture; ptr_addr += chip->bank_size_capture;
} }
ptr = (char *)(((unsigned long)ptr + 0x00ff) & ~0x00ff); ptr = (char *)ALIGN((unsigned long)ptr, 0x100);
ptr_addr = (ptr_addr + 0x00ff) & ~0x00ff; ptr_addr = ALIGN(ptr_addr, 0x100);
chip->bank_base_effect = ptr; chip->bank_base_effect = ptr;
chip->bank_base_effect_addr = ptr_addr; chip->bank_base_effect_addr = ptr_addr;
for (voice = 0; voice < YDSXG_EFFECT_VOICES; voice++) for (voice = 0; voice < YDSXG_EFFECT_VOICES; voice++)
...@@ -2075,8 +2075,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip) ...@@ -2075,8 +2075,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip)
ptr += chip->bank_size_effect; ptr += chip->bank_size_effect;
ptr_addr += chip->bank_size_effect; ptr_addr += chip->bank_size_effect;
} }
ptr = (char *)(((unsigned long)ptr + 0x00ff) & ~0x00ff); ptr = (char *)ALIGN((unsigned long)ptr, 0x100);
ptr_addr = (ptr_addr + 0x00ff) & ~0x00ff; ptr_addr = ALIGN(ptr_addr, 0x100);
chip->work_base = ptr; chip->work_base = ptr;
chip->work_base_addr = ptr_addr; chip->work_base_addr = ptr_addr;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册