Lines Matching refs:actor

24 static void *cache_first_page(struct squashfs_page_actor *actor)  in cache_first_page()  argument
26 actor->next_page = 1; in cache_first_page()
27 return actor->buffer[0]; in cache_first_page()
30 static void *cache_next_page(struct squashfs_page_actor *actor) in cache_next_page() argument
32 if (actor->next_page == actor->pages) in cache_next_page()
35 return actor->buffer[actor->next_page++]; in cache_next_page()
38 static void cache_finish_page(struct squashfs_page_actor *actor) in cache_finish_page() argument
46 struct squashfs_page_actor *actor = kmalloc(sizeof(*actor), GFP_KERNEL); in squashfs_page_actor_init() local
48 if (actor == NULL) in squashfs_page_actor_init()
51 actor->length = length ? : pages * PAGE_SIZE; in squashfs_page_actor_init()
52 actor->buffer = buffer; in squashfs_page_actor_init()
53 actor->pages = pages; in squashfs_page_actor_init()
54 actor->next_page = 0; in squashfs_page_actor_init()
55 actor->tmp_buffer = NULL; in squashfs_page_actor_init()
56 actor->squashfs_first_page = cache_first_page; in squashfs_page_actor_init()
57 actor->squashfs_next_page = cache_next_page; in squashfs_page_actor_init()
58 actor->squashfs_finish_page = cache_finish_page; in squashfs_page_actor_init()
59 return actor; in squashfs_page_actor_init()
63 static void *handle_next_page(struct squashfs_page_actor *actor) in handle_next_page() argument
65 int max_pages = (actor->length + PAGE_SIZE - 1) >> PAGE_SHIFT; in handle_next_page()
67 if (actor->returned_pages == max_pages) in handle_next_page()
70 if ((actor->next_page == actor->pages) || in handle_next_page()
71 (actor->next_index != actor->page[actor->next_page]->index)) { in handle_next_page()
72 actor->next_index++; in handle_next_page()
73 actor->returned_pages++; in handle_next_page()
74 actor->last_page = NULL; in handle_next_page()
75 return actor->alloc_buffer ? actor->tmp_buffer : ERR_PTR(-ENOMEM); in handle_next_page()
78 actor->next_index++; in handle_next_page()
79 actor->returned_pages++; in handle_next_page()
80 actor->last_page = actor->page[actor->next_page]; in handle_next_page()
81 return actor->pageaddr = kmap_local_page(actor->page[actor->next_page++]); in handle_next_page()
84 static void *direct_first_page(struct squashfs_page_actor *actor) in direct_first_page() argument
86 return handle_next_page(actor); in direct_first_page()
89 static void *direct_next_page(struct squashfs_page_actor *actor) in direct_next_page() argument
91 if (actor->pageaddr) { in direct_next_page()
92 kunmap_local(actor->pageaddr); in direct_next_page()
93 actor->pageaddr = NULL; in direct_next_page()
96 return handle_next_page(actor); in direct_next_page()
99 static void direct_finish_page(struct squashfs_page_actor *actor) in direct_finish_page() argument
101 if (actor->pageaddr) in direct_finish_page()
102 kunmap_local(actor->pageaddr); in direct_finish_page()
108 struct squashfs_page_actor *actor = kmalloc(sizeof(*actor), GFP_KERNEL); in squashfs_page_actor_init_special() local
110 if (actor == NULL) in squashfs_page_actor_init_special()
114 actor->tmp_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL); in squashfs_page_actor_init_special()
116 if (actor->tmp_buffer == NULL) { in squashfs_page_actor_init_special()
117 kfree(actor); in squashfs_page_actor_init_special()
121 actor->tmp_buffer = NULL; in squashfs_page_actor_init_special()
123 actor->length = length ? : pages * PAGE_SIZE; in squashfs_page_actor_init_special()
124 actor->page = page; in squashfs_page_actor_init_special()
125 actor->pages = pages; in squashfs_page_actor_init_special()
126 actor->next_page = 0; in squashfs_page_actor_init_special()
127 actor->returned_pages = 0; in squashfs_page_actor_init_special()
128 actor->next_index = page[0]->index & ~((1 << (msblk->block_log - PAGE_SHIFT)) - 1); in squashfs_page_actor_init_special()
129 actor->pageaddr = NULL; in squashfs_page_actor_init_special()
130 actor->last_page = NULL; in squashfs_page_actor_init_special()
131 actor->alloc_buffer = msblk->decompressor->alloc_buffer; in squashfs_page_actor_init_special()
132 actor->squashfs_first_page = direct_first_page; in squashfs_page_actor_init_special()
133 actor->squashfs_next_page = direct_next_page; in squashfs_page_actor_init_special()
134 actor->squashfs_finish_page = direct_finish_page; in squashfs_page_actor_init_special()
135 return actor; in squashfs_page_actor_init_special()