18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef _HWBM_H 38c2ecf20Sopenharmony_ci#define _HWBM_H 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_cistruct hwbm_pool { 68c2ecf20Sopenharmony_ci /* Capacity of the pool */ 78c2ecf20Sopenharmony_ci int size; 88c2ecf20Sopenharmony_ci /* Size of the buffers managed */ 98c2ecf20Sopenharmony_ci int frag_size; 108c2ecf20Sopenharmony_ci /* Number of buffers currently used by this pool */ 118c2ecf20Sopenharmony_ci int buf_num; 128c2ecf20Sopenharmony_ci /* constructor called during alocation */ 138c2ecf20Sopenharmony_ci int (*construct)(struct hwbm_pool *bm_pool, void *buf); 148c2ecf20Sopenharmony_ci /* protect acces to the buffer counter*/ 158c2ecf20Sopenharmony_ci struct mutex buf_lock; 168c2ecf20Sopenharmony_ci /* private data */ 178c2ecf20Sopenharmony_ci void *priv; 188c2ecf20Sopenharmony_ci}; 198c2ecf20Sopenharmony_ci#ifdef CONFIG_HWBM 208c2ecf20Sopenharmony_civoid hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf); 218c2ecf20Sopenharmony_ciint hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp); 228c2ecf20Sopenharmony_ciint hwbm_pool_add(struct hwbm_pool *bm_pool, unsigned int buf_num); 238c2ecf20Sopenharmony_ci#else 248c2ecf20Sopenharmony_cistatic inline void hwbm_buf_free(struct hwbm_pool *bm_pool, void *buf) {} 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cistatic inline int hwbm_pool_refill(struct hwbm_pool *bm_pool, gfp_t gfp) 278c2ecf20Sopenharmony_ci{ return 0; } 288c2ecf20Sopenharmony_ci 298c2ecf20Sopenharmony_cistatic inline int hwbm_pool_add(struct hwbm_pool *bm_pool, 308c2ecf20Sopenharmony_ci unsigned int buf_num) 318c2ecf20Sopenharmony_ci{ return 0; } 328c2ecf20Sopenharmony_ci#endif /* CONFIG_HWBM */ 338c2ecf20Sopenharmony_ci#endif /* _HWBM_H */ 34