struct hpi_control_cache *hpi_alloc_control_cache(const u32 control_count,
const u32 size_in_bytes, u8 *p_dsp_control_buffer)
{
- struct hpi_control_cache *p_cache = kmalloc_obj(*p_cache);
+ struct hpi_control_cache *p_cache;
+
+ p_cache = kzalloc_flex(*p_cache, p_info, control_count);
if (!p_cache)
return NULL;
- p_cache->p_info =
- kzalloc_objs(*p_cache->p_info, control_count);
- if (!p_cache->p_info) {
- kfree(p_cache);
- return NULL;
- }
-
p_cache->cache_size_in_bytes = size_in_bytes;
p_cache->control_count = control_count;
p_cache->p_cache = p_dsp_control_buffer;
void hpi_free_control_cache(struct hpi_control_cache *p_cache)
{
- if (p_cache) {
- kfree(p_cache->p_info);
- kfree(p_cache);
- }
+ kfree(p_cache);
}
static void subsys_message(struct hpi_message *phm, struct hpi_response *phr)
u16 adap_idx;
u32 control_count;
u32 cache_size_in_bytes;
- /** pointer to allocated memory of lookup pointers. */
- struct hpi_control_cache_info **p_info;
/** pointer to DSP's control cache. */
u8 *p_cache;
+ /** pointer to allocated memory of lookup pointers. */
+ struct hpi_control_cache_info *p_info[] __counted_by(control_count);
};
struct hpi_adapter_obj *hpi_find_adapter(u16 adapter_index);