Lines Matching defs:pool
2422 * i3c_generic_ibi_free_pool() - Free a generic IBI pool
2423 * @pool: the IBI pool to free
2425 * Free all IBI slots allated by a generic IBI pool.
2427 void i3c_generic_ibi_free_pool(struct i3c_generic_ibi_pool *pool)
2432 while (!list_empty(&pool->free_slots)) {
2433 slot = list_first_entry(&pool->free_slots,
2443 WARN_ON(nslots != pool->num_slots);
2445 kfree(pool->payload_buf);
2446 kfree(pool->slots);
2447 kfree(pool);
2452 * i3c_generic_ibi_alloc_pool() - Create a generic IBI pool
2453 * @dev: the device this pool will be used for
2456 * Create a generic IBI pool based on the information provided in @req.
2458 * Return: a valid IBI pool in case of success, an ERR_PTR() otherwise.
2464 struct i3c_generic_ibi_pool *pool;
2469 pool = kzalloc(sizeof(*pool), GFP_KERNEL);
2470 if (!pool)
2473 spin_lock_init(&pool->lock);
2474 INIT_LIST_HEAD(&pool->free_slots);
2475 INIT_LIST_HEAD(&pool->pending);
2477 pool->slots = kcalloc(req->num_slots, sizeof(*slot), GFP_KERNEL);
2478 if (!pool->slots) {
2484 pool->payload_buf = kcalloc(req->num_slots,
2486 if (!pool->payload_buf) {
2493 slot = &pool->slots[i];
2497 slot->base.data = pool->payload_buf +
2500 list_add_tail(&slot->node, &pool->free_slots);
2501 pool->num_slots++;
2504 return pool;
2507 i3c_generic_ibi_free_pool(pool);
2513 * i3c_generic_ibi_get_free_slot() - Get a free slot from a generic IBI pool
2514 * @pool: the pool to query an IBI slot on
2516 * Search for a free slot in a generic IBI pool.
2517 * The slot should be returned to the pool using i3c_generic_ibi_recycle_slot()
2523 i3c_generic_ibi_get_free_slot(struct i3c_generic_ibi_pool *pool)
2528 spin_lock_irqsave(&pool->lock, flags);
2529 slot = list_first_entry_or_null(&pool->free_slots,
2533 spin_unlock_irqrestore(&pool->lock, flags);
2540 * i3c_generic_ibi_recycle_slot() - Return a slot to a generic IBI pool
2541 * @pool: the pool to return the IBI slot to
2544 * Add an IBI slot back to its generic IBI pool. Should be called from the
2547 void i3c_generic_ibi_recycle_slot(struct i3c_generic_ibi_pool *pool,
2557 spin_lock_irqsave(&pool->lock, flags);
2558 list_add_tail(&slot->node, &pool->free_slots);
2559 spin_unlock_irqrestore(&pool->lock, flags);