提交 38c003b1 编写于 作者: H Heesub Shin 提交者: Greg Kroah-Hartman

staging: ion: remove struct ion_page_pool_item

The page pool uses an internal data structure, ion_page_pool_item, for
wrapping pooled pages and constructing a list. As the struct page
already provides ways for doing exactly the same thing, we do not need
to reinvent the wheel. This commit removes the data structure and slab
allocations for it.
Signed-off-by: NHeesub Shin <heesub.shin@samsung.com>
Reviewed-by: NMitchel Humpherys <mitchelh@codeaurora.org>
Tested-by: NJohn Stultz <john.stultz@linaro.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 80cb77dc
...@@ -23,11 +23,6 @@ ...@@ -23,11 +23,6 @@
#include <linux/slab.h> #include <linux/slab.h>
#include "ion_priv.h" #include "ion_priv.h"
struct ion_page_pool_item {
struct page *page;
struct list_head list;
};
static void *ion_page_pool_alloc_pages(struct ion_page_pool *pool) static void *ion_page_pool_alloc_pages(struct ion_page_pool *pool)
{ {
struct page *page = alloc_pages(pool->gfp_mask, pool->order); struct page *page = alloc_pages(pool->gfp_mask, pool->order);
...@@ -47,19 +42,12 @@ static void ion_page_pool_free_pages(struct ion_page_pool *pool, ...@@ -47,19 +42,12 @@ static void ion_page_pool_free_pages(struct ion_page_pool *pool,
static int ion_page_pool_add(struct ion_page_pool *pool, struct page *page) static int ion_page_pool_add(struct ion_page_pool *pool, struct page *page)
{ {
struct ion_page_pool_item *item;
item = kmalloc(sizeof(struct ion_page_pool_item), GFP_KERNEL);
if (!item)
return -ENOMEM;
mutex_lock(&pool->mutex); mutex_lock(&pool->mutex);
item->page = page;
if (PageHighMem(page)) { if (PageHighMem(page)) {
list_add_tail(&item->list, &pool->high_items); list_add_tail(&page->lru, &pool->high_items);
pool->high_count++; pool->high_count++;
} else { } else {
list_add_tail(&item->list, &pool->low_items); list_add_tail(&page->lru, &pool->low_items);
pool->low_count++; pool->low_count++;
} }
mutex_unlock(&pool->mutex); mutex_unlock(&pool->mutex);
...@@ -68,24 +56,19 @@ static int ion_page_pool_add(struct ion_page_pool *pool, struct page *page) ...@@ -68,24 +56,19 @@ static int ion_page_pool_add(struct ion_page_pool *pool, struct page *page)
static struct page *ion_page_pool_remove(struct ion_page_pool *pool, bool high) static struct page *ion_page_pool_remove(struct ion_page_pool *pool, bool high)
{ {
struct ion_page_pool_item *item;
struct page *page; struct page *page;
if (high) { if (high) {
BUG_ON(!pool->high_count); BUG_ON(!pool->high_count);
item = list_first_entry(&pool->high_items, page = list_first_entry(&pool->high_items, struct page, lru);
struct ion_page_pool_item, list);
pool->high_count--; pool->high_count--;
} else { } else {
BUG_ON(!pool->low_count); BUG_ON(!pool->low_count);
item = list_first_entry(&pool->low_items, page = list_first_entry(&pool->low_items, struct page, lru);
struct ion_page_pool_item, list);
pool->low_count--; pool->low_count--;
} }
list_del(&item->list); list_del(&page->lru);
page = item->page;
kfree(item);
return page; return page;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册