Commit 6182a0943af2235756836ed7e021fa22b93ec68b
1 parent
399154be2d
Exists in
master
and in
7 other branches
dmapool: Tidy up includes and add comments
We were missing a copyright statement and license, so add GPLv2, David Brownell's copyright and my copyright. The asm/io.h include was superfluous, but we were missing a few other necessary includes. Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Showing 1 changed file with 30 additions and 10 deletions Side-by-side Diff
mm/dmapool.c
1 | +/* | |
2 | + * DMA Pool allocator | |
3 | + * | |
4 | + * Copyright 2001 David Brownell | |
5 | + * Copyright 2007 Intel Corporation | |
6 | + * Author: Matthew Wilcox <willy@linux.intel.com> | |
7 | + * | |
8 | + * This software may be redistributed and/or modified under the terms of | |
9 | + * the GNU General Public License ("GPL") version 2 as published by the | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * This allocator returns small blocks of a given size which are DMA-able by | |
13 | + * the given device. It uses the dma_alloc_coherent page allocator to get | |
14 | + * new pages, then splits them up into blocks of the required size. | |
15 | + * Many older drivers still have their own code to do this. | |
16 | + * | |
17 | + * The current design of this allocator is fairly simple. The pool is | |
18 | + * represented by the 'struct dma_pool' which keeps a doubly-linked list of | |
19 | + * allocated pages. Each page in the page_list is split into blocks of at | |
20 | + * least 'size' bytes. | |
21 | + */ | |
1 | 22 | |
2 | 23 | #include <linux/device.h> |
3 | -#include <linux/mm.h> | |
4 | -#include <asm/io.h> /* Needed for i386 to build */ | |
5 | 24 | #include <linux/dma-mapping.h> |
6 | 25 | #include <linux/dmapool.h> |
7 | -#include <linux/slab.h> | |
26 | +#include <linux/kernel.h> | |
27 | +#include <linux/list.h> | |
8 | 28 | #include <linux/module.h> |
29 | +#include <linux/mutex.h> | |
9 | 30 | #include <linux/poison.h> |
10 | 31 | #include <linux/sched.h> |
32 | +#include <linux/slab.h> | |
33 | +#include <linux/spinlock.h> | |
34 | +#include <linux/string.h> | |
35 | +#include <linux/types.h> | |
36 | +#include <linux/wait.h> | |
11 | 37 | |
12 | -/* | |
13 | - * Pool allocator ... wraps the dma_alloc_coherent page allocator, so | |
14 | - * small blocks are easily used by drivers for bus mastering controllers. | |
15 | - * This should probably be sharing the guts of the slab allocator. | |
16 | - */ | |
17 | - | |
18 | 38 | struct dma_pool { /* the pool */ |
19 | 39 | struct list_head page_list; |
20 | 40 | spinlock_t lock; |
... | ... | @@ -265,7 +285,7 @@ |
265 | 285 | * |
266 | 286 | * This returns the kernel virtual address of a currently unused block, |
267 | 287 | * and reports its dma address through the handle. |
268 | - * If such a memory block can't be allocated, null is returned. | |
288 | + * If such a memory block can't be allocated, %NULL is returned. | |
269 | 289 | */ |
270 | 290 | void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags, |
271 | 291 | dma_addr_t *handle) |