topology: add param checks to PCM macros

Abort build if not all mandatory arguments are passed to
the macros. This should help to catch invalid usage.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
This commit is contained in:
Kai Vehmanen 2019-03-26 17:34:38 +02:00 committed by Liam Girdwood
parent a10e69d2f1
commit 322fe24e95
2 changed files with 12 additions and 3 deletions

View File

@ -71,6 +71,7 @@ define(`PCM_CAPABILITIES',
dnl PCM_PLAYBACK_ADD(name, pcm_id, playback)
define(`PCM_PLAYBACK_ADD',
`ifelse(`$#', `3',
`SectionPCM.STR($1) {'
`'
` # used for binding to the PCM'
@ -84,10 +85,12 @@ define(`PCM_PLAYBACK_ADD',
`'
` capabilities STR($3)'
` }'
`}')
`}', `fatal_error(`Invalid parameters ($#) to PCM_PLAYBACK_ADD')')'
)
dnl PCM_CAPTURE_ADD(name, pcm_id, capture)
define(`PCM_CAPTURE_ADD',
`ifelse(`$#', `3',
`SectionPCM.STR($1) {'
`'
` # used for binding to the PCM'
@ -101,10 +104,12 @@ define(`PCM_CAPTURE_ADD',
`'
` capabilities STR($3)'
` }'
`}')
`}', `fatal_error(`Invalid parameters ($#) to PCM_CAPTURE_ADD')')'
)
dnl PCM_DUPLEX_ADD(name, pcm_id, playback, capture)
define(`PCM_DUPLEX_ADD',
`ifelse(`$#', `4',
`SectionPCM.STR($1) {'
`'
` # used for binding to the PCM'
@ -123,6 +128,7 @@ define(`PCM_DUPLEX_ADD',
`'
` capabilities STR($3)'
` }'
`}')
`}', `fatal_error(`Invalid parameters ($#) to PCM_DUPLEX_ADD')')'
)
divert(0)dnl

View File

@ -10,6 +10,9 @@ dnl Argument iterator.
define(`argn', `ifelse(`$1', 1, ``$2'',
`argn(decr(`$1'), shift(shift($@)))')')
define(`fatal_error', `errprint(`m4: '__file__: __line__`: fatal error: $*
')m4exit(1)')
dnl Defines a list of items from a variable number of params.
dnl Use as last argument in a macro.
dnl The first argument specifies the number of tabs to be added for formatting