From 723c1252e058dc854f9d031e3e6526ca62f9f5c7 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Mon, 2 Aug 2021 09:28:01 +0200 Subject: 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 Link: https://lore.kernel.org/r/20210802072815.13551-2-tiwai@suse.de Signed-off-by: Takashi Iwai --- sound/core/sgbuf.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'sound/core/sgbuf.c') 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, -- cgit 1.4.1