ipc_service: static_vrings: fix num_desc return value

currently when no enough memory is found a (1 << (-1)) value is returned
instead of 0.
Fix this by returning 0 and simplify log2 computation

Signed-off-by: Riadh Ghaddab <rghaddab@baylibre.com>
This commit is contained in:
Riadh Ghaddab 2023-08-29 14:40:46 +02:00 committed by Carles Cufí
commit 5eaace1c01

View file

@ -163,5 +163,6 @@ static inline unsigned int optimal_num_desc(size_t mem_size, unsigned int buf_si
num_desc++; num_desc++;
} }
return (1 << (find_msb_set(--num_desc) - 1)); /* if num_desc == 1 there is not enough memory */
return (--num_desc == 0) ? 0 : (1 << LOG2(num_desc));
} }