summaryrefslogtreecommitdiff
path: root/sound/core
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2020-06-15 19:00:44 +0300
committerTakashi Iwai <tiwai@suse.de>2020-06-15 19:01:52 +0300
commit2a1f3368bff609504cdc984cdb7cef467bb0b2b0 (patch)
tree91b48322462746d447147f7448a886e22fbbf768 /sound/core
parent28e60dbb83f76b18acade913dfdb029cd908c9b0 (diff)
downloadlinux-2a1f3368bff609504cdc984cdb7cef467bb0b2b0.tar.xz
ALSA: memalloc: Make SG-buffer helper usable for continuous buffer, too
We have a few helper functions for making the access to the buffer address easier on SG-buffer. Those are specific to the buffer that is allocated with SG-buffer type, and it makes hard to use both SG and non-SG buffers in the same code. This patch adds a few simple checks and lets the helpers to deal with both SG- and continuous buffers gracefully. It's a preliminary step for the upcoming patch that mimics the buffer type on the fly. Link: https://lore.kernel.org/r/20200615160045.2703-4-tiwai@suse.de Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/sgbuf.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sound/core/sgbuf.c b/sound/core/sgbuf.c
index c42217e2dd19..29ddb76187e5 100644
--- a/sound/core/sgbuf.c
+++ b/sound/core/sgbuf.c
@@ -142,6 +142,9 @@ unsigned int snd_sgbuf_get_chunk_size(struct snd_dma_buffer *dmab,
struct snd_sg_buf *sg = dmab->private_data;
unsigned int start, end, pg;
+ if (!sg)
+ return size;
+
start = ofs >> PAGE_SHIFT;
end = (ofs + size - 1) >> PAGE_SHIFT;
/* check page continuity */