Lines Matching defs:pool
2291 * i3c_generic_ibi_free_pool() - Free a generic IBI pool
2292 * @pool: the IBI pool to free
2294 * Free all IBI slots allated by a generic IBI pool.
2296 void i3c_generic_ibi_free_pool(struct i3c_generic_ibi_pool *pool)
2301 while (!list_empty(&pool->free_slots)) {
2302 slot = list_first_entry(&pool->free_slots,
2312 WARN_ON(nslots != pool->num_slots);
2314 kfree(pool->payload_buf);
2315 kfree(pool->slots);
2316 kfree(pool);
2321 * i3c_generic_ibi_alloc_pool() - Create a generic IBI pool
2322 * @dev: the device this pool will be used for
2325 * Create a generic IBI pool based on the information provided in @req.
2327 * Return: a valid IBI pool in case of success, an ERR_PTR() otherwise.
2333 struct i3c_generic_ibi_pool *pool;
2338 pool = kzalloc(sizeof(*pool), GFP_KERNEL);
2339 if (!pool)
2342 spin_lock_init(&pool->lock);
2343 INIT_LIST_HEAD(&pool->free_slots);
2344 INIT_LIST_HEAD(&pool->pending);
2346 pool->slots = kcalloc(req->num_slots, sizeof(*slot), GFP_KERNEL);
2347 if (!pool->slots) {
2353 pool->payload_buf = kcalloc(req->num_slots,
2355 if (!pool->payload_buf) {
2362 slot = &pool->slots[i];
2366 slot->base.data = pool->payload_buf +
2369 list_add_tail(&slot->node, &pool->free_slots);
2370 pool->num_slots++;
2373 return pool;
2376 i3c_generic_ibi_free_pool(pool);
2382 * i3c_generic_ibi_get_free_slot() - Get a free slot from a generic IBI pool
2383 * @pool: the pool to query an IBI slot on
2385 * Search for a free slot in a generic IBI pool.
2386 * The slot should be returned to the pool using i3c_generic_ibi_recycle_slot()
2392 i3c_generic_ibi_get_free_slot(struct i3c_generic_ibi_pool *pool)
2397 spin_lock_irqsave(&pool->lock, flags);
2398 slot = list_first_entry_or_null(&pool->free_slots,
2402 spin_unlock_irqrestore(&pool->lock, flags);
2409 * i3c_generic_ibi_recycle_slot() - Return a slot to a generic IBI pool
2410 * @pool: the pool to return the IBI slot to
2413 * Add an IBI slot back to its generic IBI pool. Should be called from the
2416 void i3c_generic_ibi_recycle_slot(struct i3c_generic_ibi_pool *pool,
2426 spin_lock_irqsave(&pool->lock, flags);
2427 list_add_tail(&slot->node, &pool->free_slots);
2428 spin_unlock_irqrestore(&pool->lock, flags);