Simplify module_list size calculation by doing inside modules loop.
Unified · Split
| @@ -430,7 +430,6 @@ void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct audioreach_graph_info · 429 unmodified lines | ||
| 430 | 430 | struct audioreach_sub_graph *sgs; |
| 431 | 431 | struct apm_mod_list_obj *mlobj; |
| 432 | 432 | struct list_head *sg_list; |
| 433 | − int num_modules_per_list; | |
| 434 | 433 | int num_connections = 0; |
| 435 | 434 | int num_containers = 0; |
| 436 | 435 | int num_sub_graphs = 0; |
| @@ -451,6 +450,9 @@ void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct audioreach_graph_info · 14 unmodified lines | ||
| 451 | 450 | list_for_each_entry(container, &sgs->container_list, node) { |
| 452 | 451 | num_containers++; |
| 453 | 452 | num_modules += container->num_modules; |
| 453 | + ml_sz = ml_sz + sizeof(struct apm_module_list_params) + | |
| 454 | + APM_MOD_LIST_OBJ_PSIZE(mlobj, container->num_modules); | |
| 455 | + | |
| 454 | 456 | list_for_each_entry(module, &container->modules_list, node) { |
| 455 | 457 | if (module->src_mod_inst_id) |
| 456 | 458 | num_connections++; |
| @@ -459,11 +461,11 @@ void *audioreach_alloc_graph_pkt(struct q6apm *apm, struct audioreach_graph_info · 2 unmodified lines | ||
| 459 | 461 | } |
| 460 | 462 | |
| 461 | 463 | num_modules_list = num_containers; |
| 462 | − num_modules_per_list = num_modules/num_containers; | |
| 463 | 464 | sg_sz = APM_SUB_GRAPH_PSIZE(sg_params, num_sub_graphs); |
| 464 | 465 | cont_sz = APM_CONTAINER_PSIZE(cont_params, num_containers); |
| 465 | − ml_sz = ALIGN(sizeof(struct apm_module_list_params) + | |
| 466 | − num_modules_list * APM_MOD_LIST_OBJ_PSIZE(mlobj, num_modules_per_list), 8); | |
| 466 | + | |
| 467 | + ml_sz = ALIGN(ml_sz, 8); | |
| 468 | + | |
| 467 | 469 | mp_sz = APM_MOD_PROP_PSIZE(mprop, num_modules); |
| 468 | 470 | mc_sz = APM_MOD_CONN_PSIZE(mcon, num_connections); |
| 469 | 471 | |