[alsa-devel] [PATCH 1/6] ASoC: Intel: boards: cleanup snd_mask_set usage

Takashi Iwai tiwai at suse.de
Wed Jul 25 07:34:53 CEST 2018


On Tue, 24 Jul 2018 23:12:43 +0200,
Pierre-Louis Bossart wrote:
> 
> Sparse reports a ton of warnings when snd_mask_set is used (see
> e.g. below). Fix by adding the right typecast with the __force
> attribute. The code is less readable but with fewer warnings it's
> easier to track the real issues and improve the rest of the code.
> 
>  CHECK   sound/soc/intel/boards/skl_nau88l25_max98357a.c
> sound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27: warning: incorrect type in argument 2 (different base types)
> sound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27:    expected unsigned int [unsigned] val
> sound/soc/intel/boards/skl_nau88l25_max98357a.c:160:27:    got restricted snd_pcm_format_t [usertype] <noident>
> 
> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>
> ---
>  sound/soc/intel/boards/bdw-rt5677.c                 | 2 +-
>  sound/soc/intel/boards/bxt_da7219_max98357a.c       | 2 +-
>  sound/soc/intel/boards/bxt_rt298.c                  | 2 +-
>  sound/soc/intel/boards/glk_rt5682_max98357a.c       | 2 +-
>  sound/soc/intel/boards/kbl_da7219_max98357a.c       | 2 +-
>  sound/soc/intel/boards/kbl_rt5663_max98927.c        | 6 ++++--
>  sound/soc/intel/boards/kbl_rt5663_rt5514_max98927.c | 6 ++++--
>  sound/soc/intel/boards/skl_nau88l25_max98357a.c     | 2 +-
>  sound/soc/intel/boards/skl_nau88l25_ssm4567.c       | 2 +-
>  sound/soc/intel/boards/skl_rt286.c                  | 2 +-
>  10 files changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c
> index 6ea360f33575..17037892c16b 100644
> --- a/sound/soc/intel/boards/bdw-rt5677.c
> +++ b/sound/soc/intel/boards/bdw-rt5677.c
> @@ -156,7 +156,7 @@ static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd,
>  	/* set SSP0 to 16 bit */
>  	snd_mask_set(&params->masks[SNDRV_PCM_HW_PARAM_FORMAT -
>  				    SNDRV_PCM_HW_PARAM_FIRST_MASK],
> -				    SNDRV_PCM_FORMAT_S16_LE);
> +				(__force unsigned int)SNDRV_PCM_FORMAT_S16_LE);

I believe we should provide a specific type of snd_mask_set(), e.g.
snd_mask_set_format(), snd_mask_set_access(), etc, which receives the
right type as the argument, instead of this kind of ugly cast.

Will cook up the patch later.


thanks,

Takashi


More information about the Alsa-devel mailing list