@@ -1707,6 +1707,7 @@ static int parse_pin(const toml_table_t *mod_entry, struct parse_ctx *ctx,
17071707
17081708 ctx -> array_cnt ++ ;
17091709
1710+ /* Pin definitions contain 6 elements */
17101711 ext_mod_config -> header .num_pin_entries = toml_array_nelem (arr ) / 6 ;
17111712 ext_mod_config -> pin_desc = calloc (sizeof (struct fw_pin_description ),
17121713 toml_array_nelem (arr ) / 6 );
@@ -1767,12 +1768,12 @@ static int parse_mod_config(const toml_table_t *mod_entry, struct parse_ctx *ctx
17671768{
17681769 toml_array_t * arr ;
17691770 toml_raw_t raw ;
1770- int * pin_data ;
1771+ int * cfg_data ;
17711772 int64_t val ;
17721773 int ret ;
17731774 int i ;
17741775
1775- /* check "pin " key */
1776+ /* check "mod_cfg " key */
17761777 arr = toml_array_in (mod_entry , "mod_cfg" );
17771778 if (!arr ) {
17781779 mod_man -> cfg_count = 0 ;
@@ -1784,12 +1785,13 @@ static int parse_mod_config(const toml_table_t *mod_entry, struct parse_ctx *ctx
17841785
17851786 ctx -> array_cnt ++ ;
17861787
1787- pin_data = (int * )(modules -> mod_cfg + modules -> mod_cfg_count );
1788+ cfg_data = (int * )(modules -> mod_cfg + modules -> mod_cfg_count );
17881789 mod_man -> cfg_offset = modules -> mod_cfg_count ;
1789- modules -> mod_cfg_count += toml_array_nelem ( arr ) / 11 ;
1790+ /* 11 integers per configuration entry */
17901791 mod_man -> cfg_count = toml_array_nelem (arr ) / 11 ;
1792+ modules -> mod_cfg_count += mod_man -> cfg_count ;
17911793
1792- /* parse "pin " array elements */
1794+ /* parse "mod_cfg " array elements: the loop runs 11 * modules->mod_cfg_count times */
17931795 for (i = 0 ; ; ++ i ) {
17941796 raw = toml_raw_at (arr , i );
17951797 if (raw == 0 )
@@ -1798,9 +1800,14 @@ static int parse_mod_config(const toml_table_t *mod_entry, struct parse_ctx *ctx
17981800 ret = toml_rtoi (raw , & val );
17991801 if (ret < 0 )
18001802 return err_key_parse ("mod_cfg" , "can't convert element to integer" );
1801- pin_data [i ] = val ;
1803+ cfg_data [i ] = val ;
18021804 }
18031805
1806+ if (i != 11 * mod_man -> cfg_count )
1807+ return err_key_parse ("mod_cfg" ,
1808+ "can't parse configuration, only %u parsed for %u cfgs" ,
1809+ i , modules -> mod_cfg_count );
1810+
18041811 return 0 ;
18051812}
18061813
@@ -1869,13 +1876,13 @@ static int parse_module(const toml_table_t *toml, struct parse_ctx *pctx,
18691876 if (!modules -> mod_man )
18701877 return - ENOMEM ;
18711878
1872- modules -> mod_man_count = toml_array_nelem ( mod_entry_array ) ;
1879+ modules -> mod_man_count = entry_count ;
18731880
1874- tmp_cfg_count = entry_count * 32 ;
1881+ tmp_cfg_count = entry_count * MAX_MODULES ;
18751882 modules -> mod_cfg = calloc (sizeof (struct sof_man_mod_config ), tmp_cfg_count );
18761883
18771884 /* parse entry array elements */
1878- for (i = 0 ; i < toml_array_nelem ( mod_entry_array ) ; ++ i ) {
1885+ for (i = 0 ; i < entry_count ; ++ i ) {
18791886 struct fw_ext_mod_config_header * header ;
18801887 struct sof_man_module * mod_man ;
18811888 struct parse_ctx ctx_entry ;
0 commit comments