diff options
author | Takashi Iwai <tiwai@suse.de> | 2021-08-02 09:28:01 +0200 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2021-08-04 08:07:46 +0200 |
commit | 723c1252e058dc854f9d031e3e6526ca62f9f5c7 (patch) | |
tree | 63755baf3037501d5304cddc0264de2f8fa53578 /sound/core/sgbuf.c | |
parent | d1254593e705e3ef088195850959b4adc878fcee (diff) | |
download | linux-723c1252e058dc854f9d031e3e6526ca62f9f5c7.tar.gz |
ALSA: memalloc: Minor refactoring
Return the pointer directly from alloc ops instead of setting dmab->area at each place. It simplifies the code a bit. Acked-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/r/20210802072815.13551-2-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core/sgbuf.c')
-rw-r--r-- | sound/core/sgbuf.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c index 232cf3f1bcb3..a46129f3de12 100644 --- a/sound/core/sgbuf.c +++ b/sound/core/sgbuf.c @@ -63,7 +63,7 @@ static void snd_dma_sg_free(struct snd_dma_buffer *dmab) #define MAX_ALLOC_PAGES 32 -static int snd_dma_sg_alloc(struct snd_dma_buffer *dmab, size_t size) +static void *snd_dma_sg_alloc(struct snd_dma_buffer *dmab, size_t size) { struct snd_sg_buf *sgbuf; unsigned int i, pages, chunk, maxpages; @@ -72,10 +72,11 @@ static int snd_dma_sg_alloc(struct snd_dma_buffer *dmab, size_t size) struct page **pgtable; int type = SNDRV_DMA_TYPE_DEV; pgprot_t prot = PAGE_KERNEL; + void *area; dmab->private_data = sgbuf = kzalloc(sizeof(*sgbuf), GFP_KERNEL); if (!sgbuf) - return -ENOMEM; + return NULL; if (dmab->dev.type == SNDRV_DMA_TYPE_DEV_UC_SG) { type = SNDRV_DMA_TYPE_DEV_UC; #ifdef pgprot_noncached @@ -127,14 +128,14 @@ static int snd_dma_sg_alloc(struct snd_dma_buffer *dmab, size_t size) } sgbuf->size = size; - dmab->area = vmap(sgbuf->page_table, sgbuf->pages, VM_MAP, prot); - if (! dmab->area) + area = vmap(sgbuf->page_table, sgbuf->pages, VM_MAP, prot); + if (!area) goto _failed; - return 0; + return area; _failed: snd_dma_sg_free(dmab); /* free the table */ - return -ENOMEM; + return NULL; } static dma_addr_t snd_dma_sg_get_addr(struct snd_dma_buffer *dmab, |