mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

This patch introduces the ops table to each memory allocation type (SNDRV_DMA_TYPE_XXX) and abstract the handling for the better code management. Then we get separate the page allocation, release and other tasks for each type, especially for the SG buffer. Each buffer type has now callbacks in the struct snd_malloc_ops, and the common helper functions call those ops accordingly. The former inline code that is specific to SG-buffer is moved into the local sgbuf.c, and we can simplify the PCM code without details of memory handling. Link: https://lore.kernel.org/r/20210609162551.7842-4-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
18 lines
594 B
C
18 lines
594 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
#ifndef __MEMALLOC_LOCAL_H
|
|
#define __MEMALLOC_LOCAL_H
|
|
|
|
struct snd_malloc_ops {
|
|
int (*alloc)(struct snd_dma_buffer *dmab, size_t size);
|
|
void (*free)(struct snd_dma_buffer *dmab);
|
|
dma_addr_t (*get_addr)(struct snd_dma_buffer *dmab, size_t offset);
|
|
struct page *(*get_page)(struct snd_dma_buffer *dmab, size_t offset);
|
|
unsigned int (*get_chunk_size)(struct snd_dma_buffer *dmab,
|
|
unsigned int ofs, unsigned int size);
|
|
};
|
|
|
|
#ifdef CONFIG_SND_DMA_SGBUF
|
|
extern const struct snd_malloc_ops snd_dma_sg_ops;
|
|
#endif
|
|
|
|
#endif /* __MEMALLOC_LOCAL_H */
|