1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * drivers/hyperhold/hp_space.h
4 *
5 * Copyright (c) 2020-2022 Huawei Technologies Co., Ltd.
6 */
7
8#ifndef _HP_SPACE_H_
9#define _HP_SPACE_H_
10
11#include <linux/kernel.h>
12
13struct hp_space {
14	u32 ext_size;
15	u32 nr_ext;
16	unsigned long *bitmap;
17	atomic_t last_alloc_bit;
18	atomic_t nr_alloced;
19	wait_queue_head_t empty_wq;
20};
21
22void deinit_space(struct hp_space *spc);
23bool init_space(struct hp_space *spc, u64 dev_size, u32 ext_size);
24int alloc_eid(struct hp_space *spc);
25void free_eid(struct hp_space *spc, u32 eid);
26
27bool wait_for_space_empty(struct hp_space *spc, bool force);
28
29u64 space_memory(void);
30#endif
31