120c8ccb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2846b730eSPhillip Lougher #ifndef PAGE_ACTOR_H 3846b730eSPhillip Lougher #define PAGE_ACTOR_H 4846b730eSPhillip Lougher /* 5846b730eSPhillip Lougher * Copyright (c) 2013 6846b730eSPhillip Lougher * Phillip Lougher <phillip@squashfs.org.uk> 7846b730eSPhillip Lougher */ 8846b730eSPhillip Lougher 90d455c12SPhillip Lougher struct squashfs_page_actor { 100d455c12SPhillip Lougher union { 110d455c12SPhillip Lougher void **buffer; 120d455c12SPhillip Lougher struct page **page; 130d455c12SPhillip Lougher }; 140d455c12SPhillip Lougher void *pageaddr; 15f268eeddSPhillip Lougher void *tmp_buffer; 160d455c12SPhillip Lougher void *(*squashfs_first_page)(struct squashfs_page_actor *); 170d455c12SPhillip Lougher void *(*squashfs_next_page)(struct squashfs_page_actor *); 180d455c12SPhillip Lougher void (*squashfs_finish_page)(struct squashfs_page_actor *); 19*9ef8eb61SPhillip Lougher struct page *last_page; 200d455c12SPhillip Lougher int pages; 210d455c12SPhillip Lougher int length; 220d455c12SPhillip Lougher int next_page; 23f268eeddSPhillip Lougher int alloc_buffer; 24f268eeddSPhillip Lougher int returned_pages; 25f268eeddSPhillip Lougher pgoff_t next_index; 260d455c12SPhillip Lougher }; 270d455c12SPhillip Lougher 28f268eeddSPhillip Lougher extern struct squashfs_page_actor *squashfs_page_actor_init(void **buffer, 29f268eeddSPhillip Lougher int pages, int length); 30f268eeddSPhillip Lougher extern struct squashfs_page_actor *squashfs_page_actor_init_special( 31f268eeddSPhillip Lougher struct squashfs_sb_info *msblk, 32f268eeddSPhillip Lougher struct page **page, int pages, int length); squashfs_page_actor_free(struct squashfs_page_actor * actor)33*9ef8eb61SPhillip Lougherstatic inline struct page *squashfs_page_actor_free(struct squashfs_page_actor *actor) 341f13dff0SPhillip Lougher { 35*9ef8eb61SPhillip Lougher struct page *last_page = actor->last_page; 36*9ef8eb61SPhillip Lougher 371f13dff0SPhillip Lougher kfree(actor->tmp_buffer); 381f13dff0SPhillip Lougher kfree(actor); 39*9ef8eb61SPhillip Lougher return last_page; 401f13dff0SPhillip Lougher } squashfs_first_page(struct squashfs_page_actor * actor)410d455c12SPhillip Lougherstatic inline void *squashfs_first_page(struct squashfs_page_actor *actor) 420d455c12SPhillip Lougher { 430d455c12SPhillip Lougher return actor->squashfs_first_page(actor); 440d455c12SPhillip Lougher } squashfs_next_page(struct squashfs_page_actor * actor)450d455c12SPhillip Lougherstatic inline void *squashfs_next_page(struct squashfs_page_actor *actor) 460d455c12SPhillip Lougher { 470d455c12SPhillip Lougher return actor->squashfs_next_page(actor); 480d455c12SPhillip Lougher } squashfs_finish_page(struct squashfs_page_actor * actor)490d455c12SPhillip Lougherstatic inline void squashfs_finish_page(struct squashfs_page_actor *actor) 500d455c12SPhillip Lougher { 510d455c12SPhillip Lougher actor->squashfs_finish_page(actor); 520d455c12SPhillip Lougher } squashfs_actor_nobuff(struct squashfs_page_actor * actor)53f268eeddSPhillip Lougherstatic inline void squashfs_actor_nobuff(struct squashfs_page_actor *actor) 54f268eeddSPhillip Lougher { 55f268eeddSPhillip Lougher actor->alloc_buffer = 0; 56f268eeddSPhillip Lougher } 570d455c12SPhillip Lougher #endif 58