22 #include <linux/slab.h>
25 #include <linux/export.h>
30 #define SGBUF_TBL_ALIGN 32
31 #define sgbuf_align_table(tbl) ALIGN((tbl), SGBUF_TBL_ALIGN)
47 tmpb.
dev.dev = sgbuf->dev;
48 for (i = 0; i < sgbuf->pages; i++) {
51 tmpb.
area = sgbuf->table[
i].buf;
58 kfree(sgbuf->page_table);
65 #define MAX_ALLOC_PAGES 32
71 struct snd_sg_buf *sgbuf;
74 struct snd_sg_page *
table;
75 struct page **pgtable;
83 pages = snd_sgbuf_aligned_pages(size);
85 table = kcalloc(sgbuf->tblsize,
sizeof(*table),
GFP_KERNEL);
89 pgtable = kcalloc(sgbuf->tblsize,
sizeof(*pgtable),
GFP_KERNEL);
92 sgbuf->page_table = pgtable;
112 for (i = 0; i <
chunk; i++) {
113 table->buf = tmpb.
area;
114 table->addr = tmpb.
addr;
116 table->addr |=
chunk;
122 sgbuf->pages +=
chunk;
124 if (chunk < maxpages)
133 *res_size = sgbuf->size;
145 unsigned int ofs,
unsigned int size)
151 end = (ofs + size - 1) >> PAGE_SHIFT;
159 if ((sg->table[start].addr >> PAGE_SHIFT) !=
pg)
160 return (start << PAGE_SHIFT) - ofs;