Matthew Wilcox wrote:
[...]
> @@ -113,9 +133,12 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
> return NULL;
> }
>
> - if (size == 0)
> + if (size == 0) {
> return NULL;
> -
> + } else if (size < 4) {
> + size = 4;
> + }
you could do without brackets
[...]
> @@ -263,34 +288,21 @@ void dma_pool_destroy(struct dma_pool *pool)
> *
> * This returns the kernel virtual address of a currently unused block,
> * and reports its dma address through the handle.
> - * If such a memory block can't be allocated, null is returned.
> + * If such a memory block can't be allocated, %NULL is returned.
> */
> void *dma_pool_alloc(struct dma_pool *pool, gfp_t mem_flags,
> dma_addr_t * handle)
> {
> unsigned long flags;
> struct dma_page *page;
> - int map, block;
> size_t offset;
> void *retval;
>
> spin_lock_irqsave(&pool->lock, flags);
> restart:
> list_for_each_entry(page, &pool->page_list, page_list) {
> - int i;
> - /* only cachable accesses here ... */
> - for (map = 0, i = 0;
> - i < pool->blocks_per_page; i += BITS_PER_LONG, map++) {
> - if (page->bitmap[map] == 0)
> - continue;
> - block = ffz(~page->bitmap[map]);
> - if ((i + block) < pool->blocks_per_page) {
> - clear_bit(block, &page->bitmap[map]);
> - offset = (BITS_PER_LONG * map) + block;
> - offset *= pool->size;
> - goto ready;
> - }
> - }
> + if (page->offset < pool->allocation)
> + goto ready;
> }
> if (!(page = pool_alloc_page(pool, GFP_ATOMIC))) {
page = pool_alloc_page(pool, GFP_ATOMIC);
if(!page) {
[...]
> @@ -355,7 +366,7 @@ void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma)
> {
> struct dma_page *page;
> unsigned long flags;
> - int map, block;
> + unsigned int offset;
>
> if ((page = pool_find_page(pool, dma)) == 0) {
page = pool_find_page(pool, dma);
if (page == 0) {
> if (pool->dev)
> @@ -368,13 +379,9 @@ void dma_pool_free(struct dma_pool *pool, void *vaddr, dma_addr_t dma)
> return;
> }
>
> - block = dma - page->dma;
> - block /= pool->size;
> - map = block / BITS_PER_LONG;
> - block %= BITS_PER_LONG;
> -
> + offset = vaddr - page->vaddr;
> #ifdef CONFIG_DEBUG_SLAB
> - if (((dma - page->dma) + (void *)page->vaddr) != vaddr) {
> + if ((dma - page->dma) != offset) {
if (dma - page->dma != offset) {
[...]
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]