Squashfs: Restructure squashfs_readpage()
[linux-2.6-block.git] / fs / squashfs / page_actor.h
CommitLineData
846b730e
PL
1#ifndef PAGE_ACTOR_H
2#define PAGE_ACTOR_H
3/*
4 * Copyright (c) 2013
5 * Phillip Lougher <phillip@squashfs.org.uk>
6 *
7 * This work is licensed under the terms of the GNU GPL, version 2. See
8 * the COPYING file in the top-level directory.
9 */
10
11struct squashfs_page_actor {
12 void **page;
13 int pages;
14 int length;
15 int next_page;
16};
17
18static inline struct squashfs_page_actor *squashfs_page_actor_init(void **page,
19 int pages, int length)
20{
21 struct squashfs_page_actor *actor = kmalloc(sizeof(*actor), GFP_KERNEL);
22
23 if (actor == NULL)
24 return NULL;
25
26 actor->length = length ? : pages * PAGE_CACHE_SIZE;
27 actor->page = page;
28 actor->pages = pages;
29 actor->next_page = 0;
30 return actor;
31}
32
33static inline void *squashfs_first_page(struct squashfs_page_actor *actor)
34{
35 actor->next_page = 1;
36 return actor->page[0];
37}
38
39static inline void *squashfs_next_page(struct squashfs_page_actor *actor)
40{
41 return actor->next_page == actor->pages ? NULL :
42 actor->page[actor->next_page++];
43}
44
45static inline void squashfs_finish_page(struct squashfs_page_actor *actor)
46{
47 /* empty */
48}
49#endif