aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2006-10-09 02:13:32 -0400
committerJaroslav Kysela <perex@server.perex.cz>2006-12-20 02:55:36 -0500
commit7ab399262ee636d19db5163a35ac406d5b892a0a (patch)
tree6cfe6267feb4a8d56114e282d41b683946c6eaf0
parente7d24f0bbd0eb0d9a6d337ef67d5e2ad78900488 (diff)
[ALSA] use the ALIGN macro
Use the ALIGN macro instead of manual calculations. Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
-rw-r--r--sound/core/sgbuf.c2
-rw-r--r--sound/isa/gus/gus_mem.c7
-rw-r--r--sound/isa/wavefront/wavefront_synth.c2
-rw-r--r--sound/pci/bt87x.c2
-rw-r--r--sound/pci/es1968.c2
-rw-r--r--sound/pci/maestro3.c2
-rw-r--r--sound/pci/rme9652/hdsp.c4
-rw-r--r--sound/pci/rme9652/rme9652.c4
-rw-r--r--sound/pci/trident/trident_main.c4
-rw-r--r--sound/pci/ymfpci/ymfpci_main.c24
10 files changed, 26 insertions, 27 deletions
diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
index c30669f14ac0..cefd228cd2aa 100644
--- a/sound/core/sgbuf.c
+++ b/sound/core/sgbuf.c
@@ -27,7 +27,7 @@
27 27
28/* table entries are align to 32 */ 28/* table entries are align to 32 */
29#define SGBUF_TBL_ALIGN 32 29#define SGBUF_TBL_ALIGN 32
30#define sgbuf_align_table(tbl) ((((tbl) + SGBUF_TBL_ALIGN - 1) / SGBUF_TBL_ALIGN) * SGBUF_TBL_ALIGN) 30#define sgbuf_align_table(tbl) ALIGN((tbl), SGBUF_TBL_ALIGN)
31 31
32int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab) 32int snd_free_sgbuf_pages(struct snd_dma_buffer *dmab)
33{ 33{
diff --git a/sound/isa/gus/gus_mem.c b/sound/isa/gus/gus_mem.c
index f50c276caee8..7107753b85b5 100644
--- a/sound/isa/gus/gus_mem.c
+++ b/sound/isa/gus/gus_mem.c
@@ -143,9 +143,8 @@ static int snd_gf1_mem_find(struct snd_gf1_mem * alloc,
143 struct snd_gf1_mem_block *pblock; 143 struct snd_gf1_mem_block *pblock;
144 unsigned int ptr1, ptr2; 144 unsigned int ptr1, ptr2;
145 145
146 align--; 146 if (w_16 && align < 2)
147 if (w_16 && align < 1) 147 align = 2;
148 align = 1;
149 block->flags = w_16 ? SNDRV_GF1_MEM_BLOCK_16BIT : 0; 148 block->flags = w_16 ? SNDRV_GF1_MEM_BLOCK_16BIT : 0;
150 block->owner = SNDRV_GF1_MEM_OWNER_DRIVER; 149 block->owner = SNDRV_GF1_MEM_OWNER_DRIVER;
151 block->share = 0; 150 block->share = 0;
@@ -165,7 +164,7 @@ static int snd_gf1_mem_find(struct snd_gf1_mem * alloc,
165 if (pblock->next->ptr < boundary) 164 if (pblock->next->ptr < boundary)
166 ptr2 = pblock->next->ptr; 165 ptr2 = pblock->next->ptr;
167 } 166 }
168 ptr1 = (pblock->ptr + pblock->size + align) & ~align; 167 ptr1 = ALIGN(pblock->ptr + pblock->size, align);
169 if (ptr1 >= ptr2) 168 if (ptr1 >= ptr2)
170 continue; 169 continue;
171 size1 = ptr2 - ptr1; 170 size1 = ptr2 - ptr1;
diff --git a/sound/isa/wavefront/wavefront_synth.c b/sound/isa/wavefront/wavefront_synth.c
index bed329edbdd7..78020d832e04 100644
--- a/sound/isa/wavefront/wavefront_synth.c
+++ b/sound/isa/wavefront/wavefront_synth.c
@@ -1068,7 +1068,7 @@ wavefront_send_sample (snd_wavefront_t *dev,
1068 blocksize = max_blksize; 1068 blocksize = max_blksize;
1069 } else { 1069 } else {
1070 /* round to nearest 16-byte value */ 1070 /* round to nearest 16-byte value */
1071 blocksize = ((length-written+7)&~0x7); 1071 blocksize = ALIGN(length - written, 8);
1072 } 1072 }
1073 1073
1074 if (snd_wavefront_cmd (dev, WFC_DOWNLOAD_BLOCK, NULL, NULL)) { 1074 if (snd_wavefront_cmd (dev, WFC_DOWNLOAD_BLOCK, NULL, NULL)) {
diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c
index d33a37086df9..05e009184bfb 100644
--- a/sound/pci/bt87x.c
+++ b/sound/pci/bt87x.c
@@ -699,7 +699,7 @@ static int __devinit snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *nam
699 SNDRV_DMA_TYPE_DEV_SG, 699 SNDRV_DMA_TYPE_DEV_SG,
700 snd_dma_pci_data(chip->pci), 700 snd_dma_pci_data(chip->pci),
701 128 * 1024, 701 128 * 1024,
702 (255 * 4092 + 1023) & ~1023); 702 ALIGN(255 * 4092, 1024));
703} 703}
704 704
705static int __devinit snd_bt87x_create(struct snd_card *card, 705static int __devinit snd_bt87x_create(struct snd_card *card,
diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
index 092da53e1464..01c521d1b460 100644
--- a/sound/pci/es1968.c
+++ b/sound/pci/es1968.c
@@ -1337,7 +1337,7 @@ static struct esm_memory *snd_es1968_new_memory(struct es1968 *chip, int size)
1337 struct esm_memory *buf; 1337 struct esm_memory *buf;
1338 struct list_head *p; 1338 struct list_head *p;
1339 1339
1340 size = ((size + ESM_MEM_ALIGN - 1) / ESM_MEM_ALIGN) * ESM_MEM_ALIGN; 1340 size = ALIGN(size, ESM_MEM_ALIGN);
1341 mutex_lock(&chip->memory_mutex); 1341 mutex_lock(&chip->memory_mutex);
1342 list_for_each(p, &chip->buf_list) { 1342 list_for_each(p, &chip->buf_list) {
1343 buf = list_entry(p, struct esm_memory, list); 1343 buf = list_entry(p, struct esm_memory, list);
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 8cab342bbaaf..563c9ec49830 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -2377,7 +2377,7 @@ static int __devinit snd_m3_assp_client_init(struct snd_m3 *chip, struct m3_dma
2377 * shifted list address is aligned. 2377 * shifted list address is aligned.
2378 * list address = (mem address >> 1) >> 7; 2378 * list address = (mem address >> 1) >> 7;
2379 */ 2379 */
2380 data_bytes = (data_bytes + 255) & ~255; 2380 data_bytes = ALIGN(data_bytes, 256);
2381 address = 0x1100 + ((data_bytes/2) * index); 2381 address = 0x1100 + ((data_bytes/2) * index);
2382 2382
2383 if ((address + (data_bytes/2)) >= 0x1c00) { 2383 if ((address + (data_bytes/2)) >= 0x1c00) {
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index 694aa057ed49..e31c10e10215 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -3516,8 +3516,8 @@ static int __devinit snd_hdsp_initialize_memory(struct hdsp *hdsp)
3516 3516
3517 /* Align to bus-space 64K boundary */ 3517 /* Align to bus-space 64K boundary */
3518 3518
3519 cb_bus = (hdsp->capture_dma_buf.addr + 0xFFFF) & ~0xFFFFl; 3519 cb_bus = ALIGN(hdsp->capture_dma_buf.addr, 0x10000ul);
3520 pb_bus = (hdsp->playback_dma_buf.addr + 0xFFFF) & ~0xFFFFl; 3520 pb_bus = ALIGN(hdsp->playback_dma_buf.addr, 0x10000ul);
3521 3521
3522 /* Tell the card where it is */ 3522 /* Tell the card where it is */
3523 3523
diff --git a/sound/pci/rme9652/rme9652.c b/sound/pci/rme9652/rme9652.c
index cf0427b4bfde..dadd588dccc6 100644
--- a/sound/pci/rme9652/rme9652.c
+++ b/sound/pci/rme9652/rme9652.c
@@ -1827,8 +1827,8 @@ static int __devinit snd_rme9652_initialize_memory(struct snd_rme9652 *rme9652)
1827 1827
1828 /* Align to bus-space 64K boundary */ 1828 /* Align to bus-space 64K boundary */
1829 1829
1830 cb_bus = (rme9652->capture_dma_buf.addr + 0xFFFF) & ~0xFFFFl; 1830 cb_bus = ALIGN(rme9652->capture_dma_buf.addr, 0x10000ul);
1831 pb_bus = (rme9652->playback_dma_buf.addr + 0xFFFF) & ~0xFFFFl; 1831 pb_bus = ALIGN(rme9652->playback_dma_buf.addr, 0x10000ul);
1832 1832
1833 /* Tell the card where it is */ 1833 /* Tell the card where it is */
1834 1834
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index 1fbc4321122f..89fe5760df36 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -3380,8 +3380,8 @@ static int __devinit snd_trident_tlb_alloc(struct snd_trident *trident)
3380 snd_printk(KERN_ERR "trident: unable to allocate TLB buffer\n"); 3380 snd_printk(KERN_ERR "trident: unable to allocate TLB buffer\n");
3381 return -ENOMEM; 3381 return -ENOMEM;
3382 } 3382 }
3383 trident->tlb.entries = (unsigned int*)(((unsigned long)trident->tlb.buffer.area + SNDRV_TRIDENT_MAX_PAGES * 4 - 1) & ~(SNDRV_TRIDENT_MAX_PAGES * 4 - 1)); 3383 trident->tlb.entries = (unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4);
3384 trident->tlb.entries_dmaaddr = (trident->tlb.buffer.addr + SNDRV_TRIDENT_MAX_PAGES * 4 - 1) & ~(SNDRV_TRIDENT_MAX_PAGES * 4 - 1); 3384 trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4);
3385 /* allocate shadow TLB page table (virtual addresses) */ 3385 /* allocate shadow TLB page table (virtual addresses) */
3386 trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long)); 3386 trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long));
3387 if (trident->tlb.shadow_entries == NULL) { 3387 if (trident->tlb.shadow_entries == NULL) {
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
index a40c1085fd20..79c58f3a6b7c 100644
--- a/sound/pci/ymfpci/ymfpci_main.c
+++ b/sound/pci/ymfpci/ymfpci_main.c
@@ -2025,10 +2025,10 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip)
2025 chip->bank_size_effect = snd_ymfpci_readl(chip, YDSXGR_EFFCTRLSIZE) << 2; 2025 chip->bank_size_effect = snd_ymfpci_readl(chip, YDSXGR_EFFCTRLSIZE) << 2;
2026 chip->work_size = YDSXG_DEFAULT_WORK_SIZE; 2026 chip->work_size = YDSXG_DEFAULT_WORK_SIZE;
2027 2027
2028 size = ((playback_ctrl_size + 0x00ff) & ~0x00ff) + 2028 size = ALIGN(playback_ctrl_size, 0x100) +
2029 ((chip->bank_size_playback * 2 * YDSXG_PLAYBACK_VOICES + 0x00ff) & ~0x00ff) + 2029 ALIGN(chip->bank_size_playback * 2 * YDSXG_PLAYBACK_VOICES, 0x100) +
2030 ((chip->bank_size_capture * 2 * YDSXG_CAPTURE_VOICES + 0x00ff) & ~0x00ff) + 2030 ALIGN(chip->bank_size_capture * 2 * YDSXG_CAPTURE_VOICES, 0x100) +
2031 ((chip->bank_size_effect * 2 * YDSXG_EFFECT_VOICES + 0x00ff) & ~0x00ff) + 2031 ALIGN(chip->bank_size_effect * 2 * YDSXG_EFFECT_VOICES, 0x100) +
2032 chip->work_size; 2032 chip->work_size;
2033 /* work_ptr must be aligned to 256 bytes, but it's already 2033 /* work_ptr must be aligned to 256 bytes, but it's already
2034 covered with the kernel page allocation mechanism */ 2034 covered with the kernel page allocation mechanism */
@@ -2043,8 +2043,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip)
2043 chip->bank_base_playback_addr = ptr_addr; 2043 chip->bank_base_playback_addr = ptr_addr;
2044 chip->ctrl_playback = (u32 *)ptr; 2044 chip->ctrl_playback = (u32 *)ptr;
2045 chip->ctrl_playback[0] = cpu_to_le32(YDSXG_PLAYBACK_VOICES); 2045 chip->ctrl_playback[0] = cpu_to_le32(YDSXG_PLAYBACK_VOICES);
2046 ptr += (playback_ctrl_size + 0x00ff) & ~0x00ff; 2046 ptr += ALIGN(playback_ctrl_size, 0x100);
2047 ptr_addr += (playback_ctrl_size + 0x00ff) & ~0x00ff; 2047 ptr_addr += ALIGN(playback_ctrl_size, 0x100);
2048 for (voice = 0; voice < YDSXG_PLAYBACK_VOICES; voice++) { 2048 for (voice = 0; voice < YDSXG_PLAYBACK_VOICES; voice++) {
2049 chip->voices[voice].number = voice; 2049 chip->voices[voice].number = voice;
2050 chip->voices[voice].bank = (struct snd_ymfpci_playback_bank *)ptr; 2050 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 ptr_addr += chip->bank_size_playback; 2055 ptr_addr += chip->bank_size_playback;
2056 } 2056 }
2057 } 2057 }
2058 ptr = (char *)(((unsigned long)ptr + 0x00ff) & ~0x00ff); 2058 ptr = (char *)ALIGN((unsigned long)ptr, 0x100);
2059 ptr_addr = (ptr_addr + 0x00ff) & ~0x00ff; 2059 ptr_addr = ALIGN(ptr_addr, 0x100);
2060 chip->bank_base_capture = ptr; 2060 chip->bank_base_capture = ptr;
2061 chip->bank_base_capture_addr = ptr_addr; 2061 chip->bank_base_capture_addr = ptr_addr;
2062 for (voice = 0; voice < YDSXG_CAPTURE_VOICES; voice++) 2062 for (voice = 0; voice < YDSXG_CAPTURE_VOICES; voice++)
@@ -2065,8 +2065,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip)
2065 ptr += chip->bank_size_capture; 2065 ptr += chip->bank_size_capture;
2066 ptr_addr += chip->bank_size_capture; 2066 ptr_addr += chip->bank_size_capture;
2067 } 2067 }
2068 ptr = (char *)(((unsigned long)ptr + 0x00ff) & ~0x00ff); 2068 ptr = (char *)ALIGN((unsigned long)ptr, 0x100);
2069 ptr_addr = (ptr_addr + 0x00ff) & ~0x00ff; 2069 ptr_addr = ALIGN(ptr_addr, 0x100);
2070 chip->bank_base_effect = ptr; 2070 chip->bank_base_effect = ptr;
2071 chip->bank_base_effect_addr = ptr_addr; 2071 chip->bank_base_effect_addr = ptr_addr;
2072 for (voice = 0; voice < YDSXG_EFFECT_VOICES; voice++) 2072 for (voice = 0; voice < YDSXG_EFFECT_VOICES; voice++)
@@ -2075,8 +2075,8 @@ static int __devinit snd_ymfpci_memalloc(struct snd_ymfpci *chip)
2075 ptr += chip->bank_size_effect; 2075 ptr += chip->bank_size_effect;
2076 ptr_addr += chip->bank_size_effect; 2076 ptr_addr += chip->bank_size_effect;
2077 } 2077 }
2078 ptr = (char *)(((unsigned long)ptr + 0x00ff) & ~0x00ff); 2078 ptr = (char *)ALIGN((unsigned long)ptr, 0x100);
2079 ptr_addr = (ptr_addr + 0x00ff) & ~0x00ff; 2079 ptr_addr = ALIGN(ptr_addr, 0x100);
2080 chip->work_base = ptr; 2080 chip->work_base = ptr;
2081 chip->work_base_addr = ptr_addr; 2081 chip->work_base_addr = ptr_addr;
2082 2082